-
Notifications
You must be signed in to change notification settings - Fork 90
/
main.go
88 lines (73 loc) · 2.07 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
// _ "dotnetcore/hooks"
"dotnetcore/config"
"dotnetcore/project"
"dotnetcore/supply"
"os"
"path/filepath"
"time"
"github.com/cloudfoundry/libbuildpack"
)
func main() {
logger := libbuildpack.NewLogger(os.Stdout)
buildpackDir, err := libbuildpack.GetBuildpackDir()
if err != nil {
logger.Error("Unable to determine buildpack directory: %s", err.Error())
os.Exit(9)
}
manifest, err := libbuildpack.NewManifest(buildpackDir, logger, time.Now())
if err != nil {
logger.Error("Unable to load buildpack manifest: %s", err.Error())
os.Exit(10)
}
installer := libbuildpack.NewInstaller(manifest)
stager := libbuildpack.NewStager(os.Args[1:], logger, manifest)
if err := stager.CheckBuildpackValid(); err != nil {
os.Exit(11)
}
if err = installer.SetAppCacheDir(stager.CacheDir()); err != nil {
logger.Error("Unable to setup appcache: %s", err)
os.Exit(18)
}
if err = manifest.ApplyOverride(stager.DepsDir()); err != nil {
logger.Error("Unable to apply override.yml files: %s", err)
os.Exit(17)
}
err = libbuildpack.RunBeforeCompile(stager)
if err != nil {
logger.Error("Before Compile: %s", err.Error())
os.Exit(12)
}
if err := os.MkdirAll(filepath.Join(stager.DepDir(), "bin"), 0755); err != nil {
logger.Error("Unable to create bin directory: %s", err.Error())
os.Exit(13)
}
err = stager.SetStagingEnvironment()
if err != nil {
logger.Error("Unable to setup environment variables: %s", err.Error())
os.Exit(14)
}
cfg := &config.Config{}
s := supply.Supplier{
Stager: stager,
Installer: installer,
Manifest: manifest,
Log: logger,
Command: &libbuildpack.Command{},
Config: cfg,
Project: project.New(stager.BuildDir(), stager.DepDir(), stager.DepsIdx(), manifest, installer, logger),
}
err = supply.Run(&s)
if err != nil {
os.Exit(15)
}
if err := stager.WriteConfigYml(cfg); err != nil {
logger.Error("Error writing config.yml: %s", err.Error())
os.Exit(16)
}
if err = installer.CleanupAppCache(); err != nil {
logger.Error("Unable to clean up app cache: %s", err)
os.Exit(19)
}
}