diff --git a/cmd/detect/main.go b/cmd/detect/main.go index c60d9c2a..8052329d 100644 --- a/cmd/detect/main.go +++ b/cmd/detect/main.go @@ -24,7 +24,7 @@ import ( "github.com/buildpack/libbuildpack/buildplan" "github.com/cloudfoundry/httpd-cnb/httpd" "github.com/cloudfoundry/libcfbuildpack/helper" - "github.com/cloudfoundry/php-cnb/php" + "github.com/cloudfoundry/php-dist-cnb/php" "github.com/cloudfoundry/libcfbuildpack/detect" ) diff --git a/cmd/detect/main_test.go b/cmd/detect/main_test.go index bf7b9cde..a3176dae 100644 --- a/cmd/detect/main_test.go +++ b/cmd/detect/main_test.go @@ -22,7 +22,7 @@ import ( "github.com/buildpack/libbuildpack/buildplan" "github.com/cloudfoundry/httpd-cnb/httpd" - "github.com/cloudfoundry/php-cnb/php" + "github.com/cloudfoundry/php-dist-cnb/php" "github.com/cloudfoundry/libcfbuildpack/detect" "github.com/cloudfoundry/libcfbuildpack/test" diff --git a/go.mod b/go.mod index 89213d4c..0ff01a09 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/buildpack/libbuildpack v1.20.0 github.com/cloudfoundry/dagger v0.0.0-20190708210935-79ba5190b629 github.com/cloudfoundry/libcfbuildpack v1.79.1-0.20190730020126-e0a6cc8afb24 - github.com/cloudfoundry/php-cnb v0.0.2 + github.com/cloudfoundry/php-dist-cnb v0.0.15 github.com/onsi/gomega v1.5.0 github.com/sclevine/spec v1.2.0 gopkg.in/yaml.v2 v2.2.2 diff --git a/go.sum b/go.sum index 22894c6f..4591afac 100644 --- a/go.sum +++ b/go.sum @@ -3,30 +3,28 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc= github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= -github.com/buildpack/libbuildpack v1.11.0/go.mod h1:tKGgGnBYfOL23Ma4JWM8ucBcGX6Im3p1WTmKPixDPPM= github.com/buildpack/libbuildpack v1.19.0 h1:HUkaIwuGmPbQhujBjYNpd+E4f0NdAgAgHq7skydiL5s= github.com/buildpack/libbuildpack v1.19.0/go.mod h1:oxgSTzPbWscHs27iuYrctEZpSak2m/qPThA+9JM0Boo= github.com/buildpack/libbuildpack v1.20.0 h1:0Jxd8UaZsIjUR/7b2FAyqYYof1Gk5GesuhHKxFKDv4I= github.com/buildpack/libbuildpack v1.20.0/go.mod h1:GNN9x3mIGqolLBXj5z1K5kA22WvrC7uU7zYWt0d/GUs= github.com/cloudfoundry/dagger v0.0.0-20190708210935-79ba5190b629 h1:Ij34QrApV5nmYopclohIhB3EFFV76faK+7bhNGpkGRs= github.com/cloudfoundry/dagger v0.0.0-20190708210935-79ba5190b629/go.mod h1:PXeUHc4d2vAVO/31jFE6uD09w/yFfzs4kcayAVEvnEI= -github.com/cloudfoundry/libcfbuildpack v1.48.0/go.mod h1:Dq7Sg12rmsfJld22pGTvHRKHNGBfauXqgIzcPrPGbD4= github.com/cloudfoundry/libcfbuildpack v1.76.0 h1:oMTv35mjk5Jogzy2sshVXHyolDWnWHMfANQ0UooXJq0= github.com/cloudfoundry/libcfbuildpack v1.76.0/go.mod h1:QGm+nzixn579dvQNlS7ZQET541y2hEpZ0/5uNxkQ04Y= github.com/cloudfoundry/libcfbuildpack v1.79.1-0.20190730020126-e0a6cc8afb24 h1:3Ovh6qeGAMJvRFCWQTt8cUOHsb2D9srA3sqYIWJtfg8= github.com/cloudfoundry/libcfbuildpack v1.79.1-0.20190730020126-e0a6cc8afb24/go.mod h1:nqxdAEdvcSYRZqsFL+uV1+coatU1pqz3EyPST4/e8Ls= -github.com/cloudfoundry/php-cnb v0.0.2 h1:9K+mqBT0f+yxKac0bfj/okD3H2R6dbFG269c0jiZHSU= -github.com/cloudfoundry/php-cnb v0.0.2/go.mod h1:wmL8/TWUhD4B6ssS3Lh+JuQLCNtqFxXC78cNF7T0Zuo= +github.com/cloudfoundry/php-dist-cnb v0.0.15 h1:jA351Fdi2yOvXJF4+HUVkEi75ngnA+7KTRzxqIrhqlg= +github.com/cloudfoundry/php-dist-cnb v0.0.15/go.mod h1:sZEOcXI+kZ4vfcS1MiPmhyglMFKR6A/NVzlGzzr3x5w= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= @@ -39,21 +37,15 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg= -github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= @@ -66,7 +58,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190226215741-afe646ca25a4/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU= @@ -78,19 +69,16 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190226215855-775f8194d0f9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb h1:fgwFCsaw9buMuxNd6+DQfAuSFqbNiQZpcgJQAgJsK6k= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542 h1:6ZQFf1D2YYDDI7eSwW8adlkkavTB9sw5I24FVtEvNUQ= golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/vendor/github.com/cloudfoundry/php-cnb/LICENSE b/vendor/github.com/cloudfoundry/php-dist-cnb/LICENSE similarity index 100% rename from vendor/github.com/cloudfoundry/php-cnb/LICENSE rename to vendor/github.com/cloudfoundry/php-dist-cnb/LICENSE diff --git a/vendor/github.com/cloudfoundry/php-cnb/NOTICE b/vendor/github.com/cloudfoundry/php-dist-cnb/NOTICE similarity index 100% rename from vendor/github.com/cloudfoundry/php-cnb/NOTICE rename to vendor/github.com/cloudfoundry/php-dist-cnb/NOTICE diff --git a/vendor/github.com/cloudfoundry/php-cnb/php/contributor.go b/vendor/github.com/cloudfoundry/php-dist-cnb/php/contributor.go similarity index 69% rename from vendor/github.com/cloudfoundry/php-cnb/php/contributor.go rename to vendor/github.com/cloudfoundry/php-dist-cnb/php/contributor.go index 98bb727c..d38aace8 100644 --- a/vendor/github.com/cloudfoundry/php-cnb/php/contributor.go +++ b/vendor/github.com/cloudfoundry/php-dist-cnb/php/contributor.go @@ -17,7 +17,9 @@ package php import ( + "errors" "path/filepath" + "strings" "github.com/cloudfoundry/libcfbuildpack/build" "github.com/cloudfoundry/libcfbuildpack/helper" @@ -40,16 +42,7 @@ func NewContributor(context build.Build) (c Contributor, willContribute bool, er return Contributor{}, false, nil } - deps, err := context.Buildpack.Dependencies() - if err != nil { - return Contributor{}, false, err - } - - if plan.Version == "" { - context.Logger.SubsequentLine("Dependency version not specified, but is required") - return Contributor{}, false, nil - } - dep, err := deps.Best(Dependency, plan.Version, context.Stack) + dep, err := context.Buildpack.RuntimeDependency(Dependency, plan.Version, context.Stack) if err != nil { return Contributor{}, false, err } @@ -59,13 +52,8 @@ func NewContributor(context build.Build) (c Contributor, willContribute bool, er phpLayer: context.Layers.DependencyLayer(dep), } - if _, ok := plan.Metadata["launch"]; ok { - contributor.launchContribution = true - } - - if _, ok := plan.Metadata["build"]; ok { - contributor.buildContribution = true - } + contributor.buildContribution, _ = plan.Metadata["build"].(bool) + contributor.launchContribution, _ = plan.Metadata["launch"].(bool) return contributor, true, nil } @@ -86,6 +74,23 @@ func (c Contributor) Contribute() error { return err } + if err := layer.OverrideSharedEnv("PHP_HOME", layer.Root); err != nil { + return err + } + + extensionsFolder, apiVersion, err := extensions(layer.Root) + if err != nil { + return err + } + + if err := layer.OverrideSharedEnv("PHP_EXTENSION_DIR", extensionsFolder); err != nil { + return err + } + + if err := layer.OverrideSharedEnv("PHP_API", apiVersion); err != nil { + return err + } + return nil }, c.flags()...) } @@ -103,3 +108,21 @@ func (c Contributor) flags() []layers.Flag { return flags } + + +func extensions(root string) (extensionsFolder, apiVersion string, err error) { + folders, err := filepath.Glob(filepath.Join(root, "lib/php/extensions/no-debug-non-zts*")) + if err != nil { + return "", "", err + } + + if len(folders) == 0 { + return "", "", errors.New("php extensions folder not found") + } + + extensionsFolder = folders[0] + extensionFolderChunks := strings.Split(extensionsFolder, "-") + apiVersion = extensionFolderChunks[len(extensionFolderChunks) - 1] + + return extensionsFolder, apiVersion, nil +} diff --git a/vendor/github.com/cloudfoundry/php-cnb/php/php.go b/vendor/github.com/cloudfoundry/php-dist-cnb/php/php.go similarity index 100% rename from vendor/github.com/cloudfoundry/php-cnb/php/php.go rename to vendor/github.com/cloudfoundry/php-dist-cnb/php/php.go diff --git a/vendor/modules.txt b/vendor/modules.txt index c635021c..136ce216 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -27,8 +27,8 @@ github.com/cloudfoundry/libcfbuildpack/runner github.com/cloudfoundry/libcfbuildpack/services github.com/cloudfoundry/libcfbuildpack/test github.com/cloudfoundry/libcfbuildpack/internal -# github.com/cloudfoundry/php-cnb v0.0.2 -github.com/cloudfoundry/php-cnb/php +# github.com/cloudfoundry/php-dist-cnb v0.0.15 +github.com/cloudfoundry/php-dist-cnb/php # github.com/fatih/color v1.7.0 github.com/fatih/color # github.com/golang/protobuf v1.3.2