-
Notifications
You must be signed in to change notification settings - Fork 160
/
main.go
72 lines (58 loc) · 1.76 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
package main
import (
"io"
"io/ioutil"
"os"
"time"
"github.com/cloudfoundry/libbuildpack"
"github.com/cloudfoundry/ruby-buildpack/src/ruby/finalize"
"github.com/cloudfoundry/ruby-buildpack/src/ruby/versions"
)
func main() {
logfile, err := ioutil.TempFile("", "cloudfoundry.ruby-buildpack.finalize")
defer logfile.Close()
if err != nil {
logger := libbuildpack.NewLogger(os.Stdout)
logger.Error("Unable to create log file: %s", err.Error())
os.Exit(8)
}
stdout := io.MultiWriter(os.Stdout, logfile)
logger := libbuildpack.NewLogger(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)
}
stager := libbuildpack.NewStager(os.Args[1:], logger, manifest)
if err = manifest.ApplyOverride(stager.DepsDir()); err != nil {
logger.Error("Unable to apply override.yml files: %s", err)
os.Exit(17)
}
if err := stager.SetStagingEnvironment(); err != nil {
logger.Error("Unable to setup environment variables: %s", err.Error())
os.Exit(11)
}
f := finalize.Finalizer{
Stager: stager,
Log: logger,
Versions: versions.New(stager.BuildDir(), stager.DepDir(), manifest),
Command: &libbuildpack.Command{},
}
if err := finalize.Run(&f); err != nil {
os.Exit(12)
}
if err := libbuildpack.RunAfterCompile(stager); err != nil {
logger.Error("After Compile: %s", err.Error())
os.Exit(13)
}
if err := stager.SetLaunchEnvironment(); err != nil {
logger.Error("Unable to setup launch environment: %s", err.Error())
os.Exit(14)
}
stager.StagingComplete()
}