diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c6cf6d375..c7116b9a2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ All pull request authors must have a Contributor License Agreement (CLA) on-file with us. Please sign the Contributor License Agreements for Cloud Foundry ([Individual or Corporate](https://www.cloudfoundry.org/community/cla/)) via the EasyCLA application when you submit your first Pull Request. -When sending signed CLA please provide your github username in case of individual CLA or the list of github usernames that can make pull requests on behalf of your organization. +When sending signed CLA please provide your Github username in case of individual CLA or the list of Github usernames that can make pull requests on behalf of your organization. If you are confident that you're covered under a Corporate CLA, please make sure you've publicized your membership in the appropriate Github Org, per these instructions. diff --git a/README.md b/README.md index 897a55aba..eda068e0b 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,20 @@ This buildpack supports running Django and Flask apps. Official buildpack documentation can be found at [python buildpack docs](http://docs.cloudfoundry.org/buildpacks/python/index.html). +## Adding new dependencies + +If you want to add a new dependency to the buildpack, please add it to the [config.yml](https://github.com/cloudfoundry/buildpacks-ci/blob/5a63d13df09f83d5dff7c71d0a12c3e2dc798d39/pipelines/dependency-builds/config.yml#L272) file. For example, if you want to add a new version of Python, add an entry like the following: + +```yaml +python: + lines: + - line: 3.14.X + deprecation_date: 2030-10-07 + link: https://peps.python.org/pep-0745/ +``` + +The new dependency will be automatically added to the buildpack [manifest.yml](manifest.yml) file. + ### Building the Buildpack To build this buildpack, run the following commands from the buildpack's directory: @@ -24,7 +38,7 @@ To build this buildpack, run the following commands from the buildpack's directo 1. Install buildpack-packager ```bash - go install github.com/cloudfoundry/libbuildpack/packager/buildpack-packager + go install github.com/cloudfoundry/libbuildpack/packager/buildpack-packager@latest ``` 1. Build the buildpack diff --git a/VERSION b/VERSION index f8e233b27..f0a2883d6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.9.0 +1.9.10 diff --git a/go.mod b/go.mod index f5933bf0b..2913eed45 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/cloudfoundry/python-buildpack go 1.24.0 require ( - github.com/Dynatrace/libbuildpack-dynatrace v1.8.0 + github.com/Dynatrace/libbuildpack-dynatrace v1.10.0 github.com/blang/semver v3.5.1+incompatible - github.com/cloudfoundry/libbuildpack v0.0.0-20260306125332-dcaf55eb6f33 + github.com/cloudfoundry/libbuildpack v0.0.0-20261012122722-6cd465089938 github.com/cloudfoundry/switchblade v0.9.5 github.com/golang/mock v1.6.0 github.com/kr/text v0.2.0 diff --git a/go.sum b/go.sum index 537e7c725..9772fc7d3 100644 --- a/go.sum +++ b/go.sum @@ -560,8 +560,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/CycloneDX/cyclonedx-go v0.7.1/go.mod h1:N/nrdWQI2SIjaACyyDs/u7+ddCkyl/zkNs8xFsHF2Ps= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/Dynatrace/libbuildpack-dynatrace v1.8.0 h1:VNcd8+rurUUdY12emGfLGUUj5cMH4hkNgrdk8LO3dHE= -github.com/Dynatrace/libbuildpack-dynatrace v1.8.0/go.mod h1:Uu9aa5UFAk1Ua+zZXnvzo+avDXuEi+GtegeOyja9xg4= +github.com/Dynatrace/libbuildpack-dynatrace v1.10.0 h1:8S8wgGPNgHamzaX+zzUjVPkjhWlRPxQC6nV7ChHHd+o= +github.com/Dynatrace/libbuildpack-dynatrace v1.10.0/go.mod h1:Uu9aa5UFAk1Ua+zZXnvzo+avDXuEi+GtegeOyja9xg4= github.com/GoogleCloudPlatform/docker-credential-gcr v2.0.5+incompatible/go.mod h1:BB1eHdMLYEFuFdBlRMb0N7YGVdM5s6Pt0njxgvfbGGs= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= @@ -746,8 +746,8 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= -github.com/cloudfoundry/libbuildpack v0.0.0-20260306125332-dcaf55eb6f33 h1:O3uSzqYH1x5yK/awqNJiwcxohLHfPkXO4KOgVHgCg4o= -github.com/cloudfoundry/libbuildpack v0.0.0-20260306125332-dcaf55eb6f33/go.mod h1:Qtj1XicpoDn88w2cvVCYtw1Whq+kK3bouin0xNZ9lIU= +github.com/cloudfoundry/libbuildpack v0.0.0-20261012122722-6cd465089938 h1:hKWGdn8UAnlVtkNG+HnvEK9f8s2NDTpq48/HxKd0SSc= +github.com/cloudfoundry/libbuildpack v0.0.0-20261012122722-6cd465089938/go.mod h1:Qtj1XicpoDn88w2cvVCYtw1Whq+kK3bouin0xNZ9lIU= github.com/cloudfoundry/switchblade v0.9.5 h1:GTga1Uu6kGOL+n1TRTHyZm170N5/B/ou6wU90MiKKys= github.com/cloudfoundry/switchblade v0.9.5/go.mod h1:hIEQdGAsuNnzlyQfsD5OIORt38weSBar6Wq5/JX6Omo= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= diff --git a/manifest.yml b/manifest.yml index 0347326cf..09bf9cbd7 100644 --- a/manifest.yml +++ b/manifest.yml @@ -26,14 +26,21 @@ dependency_deprecation_dates: link: https://peps.python.org/pep-0745/ dependencies: - name: flit-core - version: 3.12.0 - uri: https://buildpacks.cloudfoundry.org/dependencies/flit-core/flit-core_3.12.0_linux_noarch_any-stack_ce08b8fa.tgz - sha256: ce08b8faf08c0be08c4c8c5617442bf36641e8c1cc26e9c3ad295d70252edffb + version: 4.1.0 + uri: https://buildpacks.cloudfoundry.org/dependencies/flit-core/flit-core_4.1.0_linux_noarch_cflinuxfs4_ce54b91e.tgz + sha256: ce54b91e705926623657e7c18a40e965b381fcf141ccafce05fac82fb8562fd1 cf_stacks: - cflinuxfs4 + source: https://files.pythonhosted.org/packages/e7/91/add211b38c357bf1b94900b4f79c34661a92be65c0243d2b0a3393c5092d/flit_core-4.1.0.tar.gz + source_sha256: 62e12b63ead8335b37f59fabb977c7167fe476dafb5e41785dfa8c9aff843bc6 +- name: flit-core + version: 4.1.0 + uri: https://buildpacks.cloudfoundry.org/dependencies/flit-core/flit-core_4.1.0_linux_noarch_cflinuxfs5_0c64c560.tgz + sha256: 0c64c560d4b5d0aeb2a82f171ed9164bc022902432b8df9e6a331116d636e916 + cf_stacks: - cflinuxfs5 - source: https://files.pythonhosted.org/packages/69/59/b6fc2188dfc7ea4f936cd12b49d707f66a1cb7a1d2c16172963534db741b/flit_core-3.12.0.tar.gz - source_sha256: 18f63100d6f94385c6ed57a72073443e1a71a4acb4339491615d0f16d6ff01b2 + source: https://files.pythonhosted.org/packages/e7/91/add211b38c357bf1b94900b4f79c34661a92be65c0243d2b0a3393c5092d/flit_core-4.1.0.tar.gz + source_sha256: 62e12b63ead8335b37f59fabb977c7167fe476dafb5e41785dfa8c9aff843bc6 - name: libffi version: 3.2.1 cf_stacks: @@ -77,18 +84,25 @@ dependencies: uri: https://buildpacks.cloudfoundry.org/dependencies/pip/pip_25.2_linux_noarch_any-stack_7dc1e988.tgz sha256: 7dc1e9882eb18f53150261c3a0cde7d5a39cdb18843c930ee01db8582f6b4f27 cf_stacks: - - cflinuxfs5 - - cflinuxfs4 - cflinuxfs3 source: https://files.pythonhosted.org/packages/20/16/650289cd3f43d5a2fadfd98c68bd1e1e7f2550a1a5326768cddfbcedb2c5/pip-25.2.tar.gz source_sha256: 578283f006390f85bb6282dffb876454593d637f5d1be494b5202ce4877e71f2 - name: pip - version: 26.0.1 - uri: https://buildpacks.cloudfoundry.org/dependencies/pip/pip_26.0.1_linux_noarch_any-stack_0750a38b.tgz - sha256: 0750a38b65c6038a0415a4ff15ef2df61fcaa6c1e5ec9d8c6678222dbac91306 - cf_stacks: [] - source: https://files.pythonhosted.org/packages/48/83/0d7d4e9efe3344b8e2fe25d93be44f64b65364d3c8d7bc6dc90198d5422e/pip-26.0.1.tar.gz - source_sha256: c4037d8a277c89b320abe636d59f91e6d0922d08a05b60e85e53b296613346d8 + version: 26.2.2 + uri: https://buildpacks.cloudfoundry.org/dependencies/pip/pip_26.2.2_linux_noarch_cflinuxfs4_d876df6b.tgz + sha256: d876df6b58ea3264950a319c11d4d98e9a4095a774ae9b6d98edec1563a98679 + cf_stacks: + - cflinuxfs4 + source: https://files.pythonhosted.org/packages/fa/e8/0842d757e483e895e670f655084cfe8b8c72580c6769a76b30b2789a0608/pip-26.2.2.tar.gz + source_sha256: 3a8e5c800492787f33a4114ef54444546c340df428974ebba17e0fd47e11af2f +- name: pip + version: 26.2.2 + uri: https://buildpacks.cloudfoundry.org/dependencies/pip/pip_26.2.2_linux_noarch_cflinuxfs5_94205d18.tgz + sha256: 94205d18befb483e86afe50f75cd7a48a019da986af57d77330c0f446e8f5415 + cf_stacks: + - cflinuxfs5 + source: https://files.pythonhosted.org/packages/fa/e8/0842d757e483e895e670f655084cfe8b8c72580c6769a76b30b2789a0608/pip-26.2.2.tar.gz + source_sha256: 3a8e5c800492787f33a4114ef54444546c340df428974ebba17e0fd47e11af2f - name: pipenv version: 2024.4.1 uri: https://buildpacks.cloudfoundry.org/dependencies/pipenv/pipenv_2024.4.1_linux_noarch_cflinuxfs3_b3c74c78.tgz @@ -98,21 +112,37 @@ dependencies: source: https://files.pythonhosted.org/packages/ca/5b/8ce5227713d692913c186d9a3164eee0236fbc3eaca87d7e2bd5dbb1da36/pipenv-2024.4.1.tar.gz source_sha256: e8ea6105c1cdda7d5c19df7bd6439a006751f3d4e017602c791e7b51314adf84 - name: pipenv - version: 2026.5.2 - uri: https://buildpacks.cloudfoundry.org/dependencies/pipenv/pipenv_2026.5.2_linux_noarch_cflinuxfs4_74c1a3ab.tgz - sha256: 74c1a3ab922ae87de22698eeec0aaa7ba54a1b7af767144eb52d34ef0c7acab5 + version: 2026.10.3 + uri: https://buildpacks.cloudfoundry.org/dependencies/pipenv/pipenv_2026.10.3_linux_noarch_cflinuxfs4_c0d825fc.tgz + sha256: c0d825fc1da55c11d8a23b4372a13d505dcbfd63b14472cabc5dfc21428fd5db cf_stacks: - cflinuxfs4 - source: https://files.pythonhosted.org/packages/00/bf/9e5a536eae91adcbed6ee9c44861250bdfdc42bf2663680ce44cf5253fdb/pipenv-2026.5.2.tar.gz - source_sha256: cf5985038a4cc4a1ffe9b48a2e580d2595245823dcc5684d07b1a53929ab47cc + source: https://files.pythonhosted.org/packages/38/c5/b0aa6c9d106c47a5493b547b76587b3e0909a14c9ebf29b9c4340968df0c/pipenv-2026.10.3.tar.gz + source_sha256: 2c18e3a76d23e53bc439e8d67ce48da1ce03f6002e378359c4f31dbd137f142e - name: pipenv - version: 2026.5.2 - uri: https://buildpacks.cloudfoundry.org/dependencies/pipenv/pipenv_2026.5.2_linux_noarch_cflinuxfs5_569f70b0.tgz - sha256: 569f70b09c3b3440c6385aad160bef6b3539fd7b6211a73bfe41600d8b3fdfad + version: 2026.10.3 + uri: https://buildpacks.cloudfoundry.org/dependencies/pipenv/pipenv_2026.10.3_linux_noarch_cflinuxfs5_035008df.tgz + sha256: '035008df6c56296d81b54037e7ead06f50e646ccc53e828692cc9dcc621546a1' cf_stacks: - cflinuxfs5 - source: https://files.pythonhosted.org/packages/00/bf/9e5a536eae91adcbed6ee9c44861250bdfdc42bf2663680ce44cf5253fdb/pipenv-2026.5.2.tar.gz - source_sha256: cf5985038a4cc4a1ffe9b48a2e580d2595245823dcc5684d07b1a53929ab47cc + source: https://files.pythonhosted.org/packages/38/c5/b0aa6c9d106c47a5493b547b76587b3e0909a14c9ebf29b9c4340968df0c/pipenv-2026.10.3.tar.gz + source_sha256: 2c18e3a76d23e53bc439e8d67ce48da1ce03f6002e378359c4f31dbd137f142e +- name: poetry-core + version: 2.5.0 + uri: https://buildpacks.cloudfoundry.org/dependencies/poetry-core/poetry-core_2.5.0_linux_noarch_cflinuxfs4_481925ca.tgz + sha256: 481925cae99083d07df7a5141848aaa8ae5828f8641830e51f502eda5d543ca0 + cf_stacks: + - cflinuxfs4 + source: https://files.pythonhosted.org/packages/42/b5/50f1fda26c4fe5b1d6ce5cdf0391bdfa1ca12fdcb8ad68344d5cf678fc90/poetry_core-2.5.0.tar.gz + source_sha256: 81d04c9253b19d0604718268d781867c8f7b2128e5b25bbf1e84141eec6b89c4 +- name: poetry-core + version: 2.5.0 + uri: https://buildpacks.cloudfoundry.org/dependencies/poetry-core/poetry-core_2.5.0_linux_noarch_cflinuxfs5_76a19635.tgz + sha256: 76a19635e5e54c32d89fa44f4175c01a6b5db45f0d8b4a7fcbee6a47a6e01e5a + cf_stacks: + - cflinuxfs5 + source: https://files.pythonhosted.org/packages/42/b5/50f1fda26c4fe5b1d6ce5cdf0391bdfa1ca12fdcb8ad68344d5cf678fc90/poetry_core-2.5.0.tar.gz + source_sha256: 81d04c9253b19d0604718268d781867c8f7b2128e5b25bbf1e84141eec6b89c4 - name: python version: 3.10.19 uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.10.19_linux_x64_cflinuxfs3_d754b71d.tgz @@ -122,21 +152,21 @@ dependencies: source: https://www.python.org/ftp/python/3.10.19/Python-3.10.19.tgz source_sha256: a078fb2d7a216071ebbe2e34b5f5355dd6b6e9b0cd1bacc4a41c63990c5a0eec - name: python - version: 3.10.20 - uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.10.20_linux_x64_cflinuxfs4_b4c18ea7.tgz - sha256: b4c18ea789c68f583899138a65f08dc1a576376239002cf1b01519e445fb7164 + version: 3.10.22 + uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.10.22_linux_x64_cflinuxfs4_e1af3723.tgz + sha256: e1af372322dcbf05a0458bfb792b811abafd944d40035c63ce367f6ee334e75c cf_stacks: - cflinuxfs4 - source: https://www.python.org/ftp/python/3.10.20/Python-3.10.20.tgz - source_sha256: 4ff5fd4c5bab803b935019f3e31d7219cebd6f870d00389cea53b88bbe935d1a + source: https://www.python.org/ftp/python/3.10.22/Python-3.10.22.tgz + source_sha256: 9448b34d16f8e3db0964ac3ed9fb283197747543c2c021f283ffd2c8b7287357 - name: python - version: 3.10.20 - uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.10.20_linux_x64_cflinuxfs5_8bb35886.tgz - sha256: 8bb358865558b85b8561c8b1cc08575dec51bf847d01be2d425e1295a7234de5 + version: 3.10.22 + uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.10.22_linux_x64_cflinuxfs5_d8a723d9.tgz + sha256: d8a723d94bda5eb0e28bcaeaaa51fcccfd28174d09562bc85133b470b5689057 cf_stacks: - cflinuxfs5 - source: https://www.python.org/ftp/python/3.10.20/Python-3.10.20.tgz - source_sha256: 4ff5fd4c5bab803b935019f3e31d7219cebd6f870d00389cea53b88bbe935d1a + source: https://www.python.org/ftp/python/3.10.22/Python-3.10.22.tgz + source_sha256: 9448b34d16f8e3db0964ac3ed9fb283197747543c2c021f283ffd2c8b7287357 - name: python version: 3.11.14 uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.11.14_linux_x64_cflinuxfs3_294394be.tgz @@ -146,37 +176,37 @@ dependencies: source: https://www.python.org/ftp/python/3.11.14/Python-3.11.14.tgz source_sha256: 563d2a1b2a5ba5d5409b5ecd05a0e1bf9b028cf3e6a6f0c87a5dc8dc3f2d9182 - name: python - version: 3.11.15 - uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.11.15_linux_x64_cflinuxfs4_830cc0e2.tgz - sha256: 830cc0e2fb2b3232e683f415b5011314703ac58b4acd4e000976963788c94865 + version: 3.11.18 + uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.11.18_linux_x64_cflinuxfs4_2dd696f8.tgz + sha256: 2dd696f8321efbddb1db43d05771eeb455c879e8be3c991fc99ce73b404d49e4 cf_stacks: - cflinuxfs4 - source: https://www.python.org/ftp/python/3.11.15/Python-3.11.15.tgz - source_sha256: f4de1b10bd6c70cbb9fa1cd71fc5038b832747a74ee59d599c69ce4846defb50 + source: https://www.python.org/ftp/python/3.11.18/Python-3.11.18.tgz + source_sha256: 5f62711b12470fd435f83f1451c1b1ef4a179aebc715c716874b0967567d814e - name: python - version: 3.11.15 - uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.11.15_linux_x64_cflinuxfs5_ded45956.tgz - sha256: ded45956efaaa20ecdd5914182b96ea47b3e9e82bc68fe1ea08820fa319689c4 + version: 3.11.18 + uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.11.18_linux_x64_cflinuxfs5_1c07253d.tgz + sha256: 1c07253d69cd0206131b5ee2fdee35d8c22a1a0a3772336ef9e8550e0025b4c3 cf_stacks: - cflinuxfs5 - source: https://www.python.org/ftp/python/3.11.15/Python-3.11.15.tgz - source_sha256: f4de1b10bd6c70cbb9fa1cd71fc5038b832747a74ee59d599c69ce4846defb50 + source: https://www.python.org/ftp/python/3.11.18/Python-3.11.18.tgz + source_sha256: 5f62711b12470fd435f83f1451c1b1ef4a179aebc715c716874b0967567d814e - name: python - version: 3.12.13 - uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.12.13_linux_x64_cflinuxfs4_e63cf720.tgz - sha256: e63cf720801bdc46dda0e1eac12465451317340ba39268b435e7b5bb5b398b89 + version: 3.12.16 + uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.12.16_linux_x64_cflinuxfs4_7b7ad03e.tgz + sha256: 7b7ad03e783ee686c9beade0ab66ab24ee78b58b665bfffcd6d7f7e25d2e3321 cf_stacks: - cflinuxfs4 - source: https://www.python.org/ftp/python/3.12.13/Python-3.12.13.tgz - source_sha256: '0816c4761c97ecdb3f50a3924de0a93fd78cb63ee8e6c04201ddfaedca500b0b' + source: https://www.python.org/ftp/python/3.12.16/Python-3.12.16.tgz + source_sha256: 710c3e75dac8b2f258d9cd0f76e5c4c2e9175fac9e249c98901552f7cf33b7dd - name: python - version: 3.12.13 - uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.12.13_linux_x64_cflinuxfs5_3d4387ec.tgz - sha256: 3d4387eceedf5d24d3a2d8b6098049d02ccd0bf413a4e02c73eba845284d86f0 + version: 3.12.16 + uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.12.16_linux_x64_cflinuxfs5_7bf4a9ba.tgz + sha256: 7bf4a9ba01316a36b2f3b0d14a699c0ab998c28b7238b214fc20c77977e89ed0 cf_stacks: - cflinuxfs5 - source: https://www.python.org/ftp/python/3.12.13/Python-3.12.13.tgz - source_sha256: '0816c4761c97ecdb3f50a3924de0a93fd78cb63ee8e6c04201ddfaedca500b0b' + source: https://www.python.org/ftp/python/3.12.16/Python-3.12.16.tgz + source_sha256: 710c3e75dac8b2f258d9cd0f76e5c4c2e9175fac9e249c98901552f7cf33b7dd - name: python version: 3.13.9 uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.13.9_linux_x64_cflinuxfs3_1c04ba8c.tgz @@ -186,21 +216,21 @@ dependencies: source: https://www.python.org/ftp/python/3.13.9/Python-3.13.9.tgz source_sha256: c4c066af19c98fb7835d473bebd7e23be84f6e9874d47db9e39a68ee5d0ce35c - name: python - version: 3.13.13 - uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.13.13_linux_x64_cflinuxfs4_8311abbf.tgz - sha256: 8311abbf60e3c061a70eabca62ccddba613ee0eeac790ec6f7e42b75213a05f1 + version: 3.13.18 + uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.13.18_linux_x64_cflinuxfs4_86d7d323.tgz + sha256: 86d7d32318bde025be37a53f56b9364981f595ce30d4c0d26d5842d0eb5c0fa3 cf_stacks: - cflinuxfs4 - source: https://www.python.org/ftp/python/3.13.13/Python-3.13.13.tgz - source_sha256: f9cde7b0e2ec8165d7326e2a0f59ea2686ce9d0c617dbbb3d66a7e54d31b74b9 + source: https://www.python.org/ftp/python/3.13.18/Python-3.13.18.tgz + source_sha256: 99dbc847fb6a3fb26358370fb4c591215864116ebb584f2b89ab0b74c51dfa2a - name: python - version: 3.13.13 - uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.13.13_linux_x64_cflinuxfs5_953e784f.tgz - sha256: 953e784f168dfcb66192b209181f2bbf4f9b6e554edb1938d367d7b1498aaa5f + version: 3.13.18 + uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.13.18_linux_x64_cflinuxfs5_67aab22c.tgz + sha256: 67aab22c86ed6a520867a6f24b3fc567675531ba5050f83bf207a8db2842ec83 cf_stacks: - cflinuxfs5 - source: https://www.python.org/ftp/python/3.13.13/Python-3.13.13.tgz - source_sha256: f9cde7b0e2ec8165d7326e2a0f59ea2686ce9d0c617dbbb3d66a7e54d31b74b9 + source: https://www.python.org/ftp/python/3.13.18/Python-3.13.18.tgz + source_sha256: 99dbc847fb6a3fb26358370fb4c591215864116ebb584f2b89ab0b74c51dfa2a - name: python version: 3.14.2 uri: https://buildpack-dependencies.tanzu.vmware.com/cf/python/python_3.14.2_linux_x64_cflinuxfs3_82c1798d.tgz @@ -210,30 +240,53 @@ dependencies: source: https://www.python.org/ftp/python/3.14.2/Python-3.14.2.tgz source_sha256: c609e078adab90e2c6bacb6afafacd5eaf60cd94cf670f1e159565725fcd448d - name: python - version: 3.14.4 - uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.14.4_linux_x64_cflinuxfs4_c99dfa05.tgz - sha256: c99dfa053d8b47dab158af2e072d0a4c80c6593443cb97e759e45de1934afc96 + version: 3.14.10 + uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.14.10_linux_x64_cflinuxfs4_fb1e502b.tgz + sha256: fb1e502bf9685cc9c9673ea1e102ab657989f3de90d951e7367c5f690a05afe3 cf_stacks: - cflinuxfs4 - source: https://www.python.org/ftp/python/3.14.4/Python-3.14.4.tgz - source_sha256: b4c059d5895f030e7df9663894ce3732bfa1b32cd3ab2883980266a45ce3cb3b + source: https://www.python.org/ftp/python/3.14.10/Python-3.14.10.tgz + source_sha256: 9e4996c19ae5a3df31f10c37723661f71d3455d73bd005f79df7098e5cc13192 - name: python - version: 3.14.4 - uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.14.4_linux_x64_cflinuxfs5_ae27ea8c.tgz - sha256: ae27ea8c3e4b063be4f1dfbfcb37b65fe55be0c9812f275f56e68df96e7283ec + version: 3.14.10 + uri: https://buildpacks.cloudfoundry.org/dependencies/python/python_3.14.10_linux_x64_cflinuxfs5_b3363a06.tgz + sha256: b3363a06bb2df5ca394935c399bcbc5a834c891cc7558ffcdc8676325ef7765a cf_stacks: - cflinuxfs5 - source: https://www.python.org/ftp/python/3.14.4/Python-3.14.4.tgz - source_sha256: b4c059d5895f030e7df9663894ce3732bfa1b32cd3ab2883980266a45ce3cb3b + source: https://www.python.org/ftp/python/3.14.10/Python-3.14.10.tgz + source_sha256: 9e4996c19ae5a3df31f10c37723661f71d3455d73bd005f79df7098e5cc13192 - name: setuptools - version: 82.0.1 - uri: https://buildpacks.cloudfoundry.org/dependencies/setuptools/setuptools_82.0.1_linux_noarch_any-stack_934b4323.tgz - sha256: 934b4323475131e04577a24eff3774f75a1219948f49c63afcd5e35a507d8ba7 + version: 84.2.1 + uri: https://buildpacks.cloudfoundry.org/dependencies/setuptools/setuptools_84.2.1_linux_noarch_cflinuxfs4_b187c0e5.tgz + sha256: b187c0e57a959fe5917b399029110b4e3452b39be66acb39aa3fd7f0c12a62e5 cf_stacks: - cflinuxfs4 + source: https://files.pythonhosted.org/packages/70/b3/c19426f783614d625699a4b247faf628ea9ab1db228674491767b417f9e1/setuptools-84.2.1.tar.gz + source_sha256: 3ff8b3b5492a0aa66960f4419365a86b84e013070d4313e4d4a6894f5d64d6bc +- name: setuptools + version: 84.2.1 + uri: https://buildpacks.cloudfoundry.org/dependencies/setuptools/setuptools_84.2.1_linux_noarch_cflinuxfs5_cd4edafb.tgz + sha256: cd4edafba5b573915ef489118cb994f87cb61d2cf094448321f12f7e24594e69 + cf_stacks: + - cflinuxfs5 + source: https://files.pythonhosted.org/packages/70/b3/c19426f783614d625699a4b247faf628ea9ab1db228674491767b417f9e1/setuptools-84.2.1.tar.gz + source_sha256: 3ff8b3b5492a0aa66960f4419365a86b84e013070d4313e4d4a6894f5d64d6bc +- name: uv + version: 0.13.5 + uri: https://buildpacks.cloudfoundry.org/dependencies/uv/uv_0.13.5_linux_x64_cflinuxfs4_4a873e08.tgz + sha256: 4a873e08d7a57cc63f6e229eeec0947f8b88f69ff75b80082c23df51b47e3625 + cf_stacks: + - cflinuxfs4 + source: https://files.pythonhosted.org/packages/de/f0/7565e80415f841c3500ed69d86516c7676e3b24470a218ab61b1f43071a2/uv-0.13.5.tar.gz + source_sha256: 979409b8c9a78df140ffb19c53f511b7a73526da8d1d5e36558833055e371c6c +- name: uv + version: 0.13.5 + uri: https://buildpacks.cloudfoundry.org/dependencies/uv/uv_0.13.5_linux_x64_cflinuxfs5_df0489b1.tgz + sha256: df0489b125d2d2e018b6c83ef135a9cc0f689c4239dca662e649c2317fda1a82 + cf_stacks: - cflinuxfs5 - source: https://files.pythonhosted.org/packages/4f/db/cfac1baf10650ab4d1c111714410d2fbb77ac5a616db26775db562c8fab2/setuptools-82.0.1.tar.gz - source_sha256: 7d872682c5d01cfde07da7bccc7b65469d3dca203318515ada1de5eda35efbf9 + source: https://files.pythonhosted.org/packages/de/f0/7565e80415f841c3500ed69d86516c7676e3b24470a218ab61b1f43071a2/uv-0.13.5.tar.gz + source_sha256: 979409b8c9a78df140ffb19c53f511b7a73526da8d1d5e36558833055e371c6c include_files: - CHANGELOG - CONTRIBUTING.md diff --git a/scripts/integration.sh b/scripts/integration.sh index bc6fdc1cd..2a22251df 100755 --- a/scripts/integration.sh +++ b/scripts/integration.sh @@ -115,7 +115,10 @@ function specs::run() { nodes=1 if [[ "${parallel}" == "true" ]]; then - nodes=3 + # Honour GINKGO_NODES from the CI pipeline (defaults to 3) so parallelism can be + # tuned per environment -- e.g. lowered on the single-AZ buildpacks test CF where + # heavy Rails fixtures otherwise saturate the one Diego cell. + nodes="${GINKGO_NODES:-3}" serial_flag="" fi diff --git a/src/python/hooks/dynatrace.go b/src/python/hooks/dynatrace.go index 7585289ad..c69553297 100644 --- a/src/python/hooks/dynatrace.go +++ b/src/python/hooks/dynatrace.go @@ -6,5 +6,5 @@ import ( ) func init() { - libbuildpack.AddHook(dynatrace.NewHook("sdk", "process")) + libbuildpack.AddHook(dynatrace.NewHook("python", "sdk", "process")) } diff --git a/src/python/supply/supply.go b/src/python/supply/supply.go index b36a48fd9..613c055d3 100644 --- a/src/python/supply/supply.go +++ b/src/python/supply/supply.go @@ -341,12 +341,35 @@ func (s *Supplier) InstallPip() error { return err } + // The pip dependency tarball bundles a flit-core wheel (the build backend + // required by pip's pyproject.toml). We must bootstrap flit-core into the + // Python environment before installing pip, because: + // - pip's pyproject.toml declares build-requires: flit-core >=3.11,<4 + // - With build isolation, pip would try to install flit-core into a + // temporary venv, but --no-index prevents network access and the + // bundled flit-core version may not satisfy the <4 constraint + // - With --no-build-isolation, pip skips the isolated env but needs + // flit_core importable in the current environment + // This matches the pattern used by InstallCommonBuildDependencies(). + s.Log.Info("Installing build backend flit-core (bootstrap)") + if err := s.Command.Execute(s.Stager.BuildDir(), indentWriter(os.Stdout), indentWriter(os.Stderr), + "python", + "-m", "pip", + "install", "flit-core", + "--no-index", + "--no-build-isolation", + fmt.Sprintf("--find-links=%s", tempPath), + ); err != nil { + return fmt.Errorf("could not bootstrap flit-core: %v", err) + } + if err := s.Command.Execute(s.Stager.BuildDir(), indentWriter(os.Stdout), indentWriter(os.Stderr), "python", "-m", "pip", "install", "pip", "--exists-action=w", "--no-index", + "--no-build-isolation", "--ignore-installed", fmt.Sprintf("--find-links=%s", tempPath), ); err != nil { @@ -743,19 +766,28 @@ func (s *Supplier) RunPipVendored() error { // dependencies - wheel and setuptools. These are packaged by the dependency // pipeline within the "pip" dependency. func (s *Supplier) InstallCommonBuildDependencies() error { - var commonDeps = []string{"wheel", "setuptools"} tempPath := filepath.Join("/tmp", "common_build_deps") if err := s.Installer.InstallOnlyVersion("pip", tempPath); err != nil { return err } + for _, dep := range []string{"flit-core", "poetry-core"} { + if err := s.Installer.InstallOnlyVersion(dep, tempPath); err != nil { + return fmt.Errorf("could not prepare build-time dependency %s: %v", dep, err) + } + s.Log.Info("Installing build-time dependency %s (bootstrap)", dep) + if err := s.runPipInstall(tempPath, "--no-build-isolation"); err != nil { + return fmt.Errorf("could not bootstrap-install %s: %v", dep, err) + } + } - for _, dep := range commonDeps { + for _, dep := range []string{"wheel", "setuptools"} { s.Log.Info("Installing build-time dependency %s", dep) - args := []string{dep, "--no-index", "--upgrade-strategy=only-if-needed", fmt.Sprintf("--find-links=%s", tempPath)} + args := []string{dep, "--no-index", "--no-build-isolation", "--upgrade-strategy=only-if-needed", fmt.Sprintf("--find-links=%s", tempPath)} if err := s.runPipInstall(args...); err != nil { return fmt.Errorf("could not install build-time dependency %s: %v", dep, err) } } + return nil } diff --git a/src/python/supply/supply_test.go b/src/python/supply/supply_test.go index b7947dc30..b6533dee4 100644 --- a/src/python/supply/supply_test.go +++ b/src/python/supply/supply_test.go @@ -154,7 +154,10 @@ var _ = Describe("Supply", func() { It("installs latest from manifest", func() { mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/pip") - mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "pip", "--exists-action=w", "--no-index", "--ignore-installed", "--find-links=/tmp/pip") + gomock.InOrder( + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "flit-core", "--no-index", "--no-build-isolation", "--find-links=/tmp/pip"), + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "pip", "--exists-action=w", "--no-index", "--no-build-isolation", "--ignore-installed", "--find-links=/tmp/pip"), + ) mockStager.EXPECT().LinkDirectoryInDepDir(filepath.Join(filepath.Join(depDir, "python"), "bin"), "bin") Expect(supplier.InstallPip()).To(Succeed()) @@ -633,22 +636,57 @@ MarkupSafe==2.0.1 Describe("InstallCommonBuildDependencies", func() { Context("successful installation", func() { - It("runs command to install wheel and setuptools", func() { + It("bootstraps flit-core, poetry-core, wheel and setuptools", func() { mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps") - mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "wheel", "--no-index", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps") - mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "setuptools", "--no-index", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps") + mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation") + mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "wheel", "--no-index", "--no-build-isolation", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "setuptools", "--no-index", "--no-build-isolation", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps") Expect(supplier.InstallCommonBuildDependencies()).To(Succeed()) }) }) - Context("installation fails", func() { - BeforeEach(func() { - mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "wheel", "--no-index", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps").Return(fmt.Errorf("some-pip-error")) + Context("flit-core bootstrap fails", func() { + It("returns a useful error message", func() { + mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps") + mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation").Return(fmt.Errorf("bootstrap-error")) + Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not bootstrap-install flit-core: bootstrap-error")) }) + }) + Context("poetry-core preparation fails", func() { It("returns a useful error message", func() { - mockInstaller.EXPECT().InstallOnlyVersion(gomock.Any(), gomock.Any()).Times(1) + mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps") + mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation") + mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps").Return(fmt.Errorf("prepare-error")) + Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not prepare build-time dependency poetry-core: prepare-error")) + }) + }) + + Context("poetry-core bootstrap fails", func() { + It("returns a useful error message", func() { + mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps") + mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation") + mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation").Return(fmt.Errorf("poetry-error")) + Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not bootstrap-install poetry-core: poetry-error")) + }) + }) + + Context("wheel installation fails", func() { + It("returns a useful error message", func() { + mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps") + mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation") + mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation") + mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "wheel", "--no-index", "--no-build-isolation", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps").Return(fmt.Errorf("some-pip-error")) Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not install build-time dependency wheel: some-pip-error")) }) }) diff --git a/vendor/github.com/Dynatrace/libbuildpack-dynatrace/.gitignore b/vendor/github.com/Dynatrace/libbuildpack-dynatrace/.gitignore index 31c5c6ff2..c57d01cee 100644 --- a/vendor/github.com/Dynatrace/libbuildpack-dynatrace/.gitignore +++ b/vendor/github.com/Dynatrace/libbuildpack-dynatrace/.gitignore @@ -11,5 +11,6 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out -# vim session file +# various editor files Session.vim +*.swp diff --git a/vendor/github.com/Dynatrace/libbuildpack-dynatrace/CODEOWNERS b/vendor/github.com/Dynatrace/libbuildpack-dynatrace/CODEOWNERS new file mode 100644 index 000000000..eed8c20a1 --- /dev/null +++ b/vendor/github.com/Dynatrace/libbuildpack-dynatrace/CODEOWNERS @@ -0,0 +1 @@ +* @Dynatrace/team-kite diff --git a/vendor/github.com/Dynatrace/libbuildpack-dynatrace/README.md b/vendor/github.com/Dynatrace/libbuildpack-dynatrace/README.md index c85864380..b510233ea 100644 --- a/vendor/github.com/Dynatrace/libbuildpack-dynatrace/README.md +++ b/vendor/github.com/Dynatrace/libbuildpack-dynatrace/README.md @@ -21,7 +21,12 @@ func init() { ## Configuration -The Hook will look for credentials in the configurations for existing services (which is represented in the runtime as the VCAP_SERVICES environment variable in JSON format.) We look for service names having the 'dynatrace' substring. +The Hook will look for credentials in the configurations for existing services. It searches for service credentials depending on the binding type: + +1. **File-based**: If the `VCAP_SERVICES_FILE_PATH` environment variable is set, the hook reads the VCAP_SERVICES JSON from the file at that path. +2. **Environment variable**: If the env var `VCAP_SERVICES` is set, it reads the JSON from the `VCAP_SERVICES` environment variable directly. + +In both cases, we look for service names having the 'dynatrace' substring. We support the following configuration fields, @@ -33,6 +38,7 @@ We support the following configuration fields, | skiperrors | boolean | If true, the deployment doesn't fail if the Dynatrace agent download fails. | No | false | | networkzone | string | If set, agent is configured to choose communication endpoints located at the field's value. | No | empty | | enablefips | boolean | If true, the [FIPS 140-2 mode](https://www.dynatrace.com/news/blog/dynatrace-achieves-fips-140-2-certification/) is enabled | No | false | +| removetechnologies| string | Removes OneAgent code-modules via a comma-separated list. This is applied **before** addtechnologies. | No | empty | | addtechnologies| string | Adds additional OneAgent code-modules via a comma-separated list. See [supported values](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/deployment/oneagent/download-oneagent-version#parameters) in the "included" row | No | empty | For example, @@ -47,8 +53,9 @@ We also support standard Dynatrace environment variables. ## Requirements -- Go 1.11 -- Linux to run the tests. +- Go 1.19 or higher. +- Deployment targets: Linux and Windows. +- Development and testing: Linux, Mac OS, and Windows. ## Development @@ -57,7 +64,14 @@ You can download or clone the repository. You can run tests through, ``` -go test +go test ./... +``` + +By default, tests simulate the Linux platform. To test against a different target OS, use the `-os` flag: + +``` +go test ./... -os=windows +go test ./... -os=linux ``` If you modify/add interfaces, you may need to regenerate the mocks. For this you need [gomock](https://github.com/golang/mock): diff --git a/vendor/github.com/Dynatrace/libbuildpack-dynatrace/hook.go b/vendor/github.com/Dynatrace/libbuildpack-dynatrace/hook.go index bef46b816..936aec74d 100644 --- a/vendor/github.com/Dynatrace/libbuildpack-dynatrace/hook.go +++ b/vendor/github.com/Dynatrace/libbuildpack-dynatrace/hook.go @@ -13,6 +13,7 @@ import ( "path/filepath" "regexp" "runtime" + "slices" "strings" "time" @@ -36,6 +37,7 @@ type credentials struct { NetworkZone string EnableFIPS bool AddTechnologies string + RemoveTechnologies string } // Hook implements libbuildpack.Hook. It downloads and install the Dynatrace OneAgent. @@ -66,7 +68,12 @@ func NewHook(technologies ...string) libbuildpack.Hook { func (h *Hook) AfterCompile(stager *libbuildpack.Stager) error { // All other methods in this package are called from here, which // makes it the main entry-point. + return h.injectDynatrace(stager, runtime.GOOS) +} + +// injectDynatrace is an indirection to get rid of the tight coupling to the underlying operating system +func (h *Hook) injectDynatrace(stager *libbuildpack.Stager, operatingSystem string) error { var err error h.Log.Debug("Checking for enabled dynatrace service...") @@ -84,30 +91,30 @@ func (h *Hook) AfterCompile(stager *libbuildpack.Stager) error { // download installer var installerFilename string - if runtime.GOOS == "linux" { + if operatingSystem == "linux" { installerFilename = "paasInstaller.sh" - } else if runtime.GOOS == "windows" { + } else if operatingSystem == "windows" { installerFilename = "paasInstaller.zip" } else { // This is the only place where we need to return an error. // All following operating system checks are just to determine installation specifics. - return errors.New("libbuildpack-dynatrace: Unsupported operating system: " + runtime.GOOS) + return errors.New("libbuildpack-dynatrace: Unsupported operating system: " + operatingSystem) } installerFilePath := filepath.Join(os.TempDir(), installerFilename) - url := h.getDownloadURL(creds) + url := h.getDownloadURL(creds, operatingSystem) err = h.download(url, installerFilePath, stager, creds) if err != nil && creds.SkipErrors { h.Log.Warning("Error during installer download, skipping installation") return nil - }else if err != nil { + } else if err != nil { return err } // run installer - if runtime.GOOS == "linux" { + if operatingSystem == "linux" { err = h.runInstallerUnix(installerFilePath, installDir, creds, stager) - } else if runtime.GOOS == "windows" { + } else if operatingSystem == "windows" { err = h.runInstallerWindows(installerFilePath, installDir, creds, stager) } @@ -137,9 +144,45 @@ func (h *Hook) AfterCompile(stager *libbuildpack.Stager) error { return nil } +// loadVCAPServicesData returns the raw VCAP_SERVICES JSON data from the appropriate source. +func (h *Hook) loadVCAPServicesData() []byte { + filePath, filePathSet := os.LookupEnv("VCAP_SERVICES_FILE_PATH") + + if filePathSet { + if filePath == "" { + h.Log.Debug("VCAP_SERVICES_FILE_PATH is set but empty") + return nil + } + + h.Log.Debug("Loading VCAP services from file: %s", filePath) + fileContent, err := os.ReadFile(filePath) + if err != nil { + h.Log.Error("Failed to read VCAP services file %s: %s", filePath, err) + return nil + } + h.Log.Debug("Successfully read VCAP Service data.") + return fileContent + + } + + h.Log.Debug("Loading VCAP services from environment variable VCAP_SERVICES") + envData := os.Getenv("VCAP_SERVICES") + if envData == "" { + h.Log.Debug("Environment variable VCAP_SERVICES is not set or empty") + return nil + } + h.Log.Debug("Successfully read VCAP Service data from environment variable.") + return []byte(envData) +} + // getCredentials returns the configuration from the environment, or nil if not found. The credentials are represented -// as a JSON object in the VCAP_SERVICES environment variable. +// as a JSON object loaded via loadVCAPServicesData. func (h *Hook) getCredentials() *credentials { + data := h.loadVCAPServicesData() + if data == nil { + return nil + } + // Represent the structure of the JSON object in VCAP_SERVICES for parsing. var vcapServices map[string][]struct { @@ -147,7 +190,7 @@ func (h *Hook) getCredentials() *credentials { Credentials map[string]interface{} `json:"credentials"` } - if err := json.Unmarshal([]byte(os.Getenv("VCAP_SERVICES")), &vcapServices); err != nil { + if err := json.Unmarshal(data, &vcapServices); err != nil { h.Log.Debug("Failed to unmarshal VCAP_SERVICES: %s", err) return nil } @@ -176,13 +219,14 @@ func (h *Hook) getCredentials() *credentials { SkipErrors: queryString("skiperrors") == "true", NetworkZone: queryString("networkzone"), EnableFIPS: queryString("enablefips") == "true", - AddTechnologies: queryString("addtechnologies"), + AddTechnologies: queryString("addtechnologies"), + RemoveTechnologies: queryString("removetechnologies"), } if (creds.EnvironmentID != "" && creds.APIToken != "") || creds.CustomOneAgentURL != "" { found = append(found, creds) } else if !(creds.EnvironmentID == "" && creds.APIToken == "") { // One of the fields is empty. - h.Log.Warning("Incomplete credentials for service: %s, environment ID: %s, API token: %s", creds.ServiceName, + h.Log.Error("Incomplete credentials for service: %s, environment ID: %s, API token: %s", creds.ServiceName, creds.EnvironmentID, creds.APIToken) } } @@ -194,7 +238,7 @@ func (h *Hook) getCredentials() *credentials { } if len(found) > 1 { - h.Log.Warning("More than one matching service found!") + h.Log.Error("More than one matching service found!") } return nil @@ -206,10 +250,10 @@ func (h *Hook) download(url, filePath string, stager *libbuildpack.Stager, creds req, _ := http.NewRequest("GET", url, nil) if creds.CustomOneAgentURL == "" { ver, err := stager.BuildpackVersion() - if err != nil { - h.Log.Warning("Failed to get buildpack version: %v", err) - ver = "unknown" - } + if err != nil { + h.Log.Warning("Failed to get buildpack version: %v", err) + ver = "unknown" + } req.Header.Set("User-Agent", fmt.Sprintf("cf-%s-buildpack/%s", stager.BuildpackLanguage(), ver)) req.Header.Set("Authorization", fmt.Sprintf("Api-Token %s", creds.APIToken)) } @@ -219,7 +263,7 @@ func (h *Hook) download(url, filePath string, stager *libbuildpack.Stager, creds return err } defer out.Close() - + const baseWaitTime = 3 * time.Second for i := 0; ; i++ { resp, err := client.Do(req) @@ -268,12 +312,13 @@ func (h *Hook) download(url, filePath string, stager *libbuildpack.Stager, creds } -func (h *Hook) getDownloadURL(c *credentials) string { +func (h *Hook) getDownloadURL(c *credentials, operatingSystem string) string { var osType, installerType string - if runtime.GOOS == "linux" { + switch operatingSystem { + case "linux": osType = "unix" installerType = "paas-sh" - } else if runtime.GOOS == "windows" { + case "windows": osType = "windows" installerType = "paas" } @@ -298,9 +343,25 @@ func (h *Hook) getDownloadURL(c *credentials) string { if c.NetworkZone != "" { qv.Add("networkZone", c.NetworkZone) } + + keepTech := []string{} + if c.RemoveTechnologies != "" { + // remove configured OneAgent code modules, except 'process' + remove := strings.Split(c.RemoveTechnologies, ",") + for _, tech := range h.IncludeTechnologies { + if tech == "process" || !slices.Contains(remove, tech) { + keepTech = append(keepTech, tech) + } else { + h.Log.Debug("Removing code module from download: %s", tech) + } + } + h.IncludeTechnologies = keepTech + } + for _, t := range h.IncludeTechnologies { qv.Add("include", t) } + if c.AddTechnologies != "" { // add optionally configured OneAgent code modules for _, t := range strings.Split(c.AddTechnologies, ",") { @@ -308,6 +369,7 @@ func (h *Hook) getDownloadURL(c *credentials) string { qv.Add("include", t) } } + u.RawQuery = qv.Encode() // Parameters will be sorted by key. return u.String() diff --git a/vendor/github.com/Dynatrace/libbuildpack-dynatrace/windows.go b/vendor/github.com/Dynatrace/libbuildpack-dynatrace/windows.go index 2763fb11f..2301e5913 100644 --- a/vendor/github.com/Dynatrace/libbuildpack-dynatrace/windows.go +++ b/vendor/github.com/Dynatrace/libbuildpack-dynatrace/windows.go @@ -39,16 +39,16 @@ func (h *Hook) runInstallerWindows(installerFilePath, installDir string, creds * } func (h *Hook) setUpDotNetCorProfilerInjection(creds *credentials, installDir string, stager *libbuildpack.Stager) error { - loaderPath, err := h.findAbsoluteLoaderPath(stager, installDir) + agentPath, err := h.findAbsoluteAgentPath(stager, installDir) if err != nil { - return fmt.Errorf("cannot find oneagentloader.dll: %s", err) + return fmt.Errorf("cannot find oneagentdotnet.dll: %s", err) } scriptContent := "set COR_ENABLE_PROFILING=1\n" scriptContent += "set COR_PROFILER={B7038F67-52FC-4DA2-AB02-969B3C1EDA03}\n" scriptContent += "set DT_AGENTACTIVE=true\n" scriptContent += "set DT_BLOCKLIST=powershell*\n" - scriptContent += fmt.Sprintf("set COR_PROFILER_PATH_64=%s\n", loaderPath) + scriptContent += fmt.Sprintf("set COR_PROFILER_PATH_64=%s\n", agentPath) if creds.NetworkZone != "" { h.Log.Debug("Setting DT_NETWORK_ZONE...") @@ -68,32 +68,32 @@ func (h *Hook) setUpDotNetCorProfilerInjection(creds *credentials, installDir st return nil } -func (h *Hook) findAbsoluteLoaderPath(stager *libbuildpack.Stager, installDir string) (string, error) { +func (h *Hook) findAbsoluteAgentPath(stager *libbuildpack.Stager, installDir string) (string, error) { - // look for dotnet loader DLL file relative to the root of the downloaded zip archive - // and get the path from the manifest e.g. agent/bin/windows-x86-64/oneagentloader.dll - loaderDllPath, err := h.findAgentPath(filepath.Join(stager.BuildDir(), installDir), "dotnet", "loader", "oneagentloader.dll", "windows-x86-64") + // look for dotnet agent DLL file relative to the root of the downloaded zip archive + // and get the path from the manifest e.g. agent/bin/windows-x86-64/oneagentdotnet .dll + agentDllPath, err := h.findAgentPath(filepath.Join(stager.BuildDir(), installDir), "dotnet", "primary", "oneagentdotnet.dll", "windows-x86-64") if err != nil { h.Log.Error("Manifest handling failed!") return "", err } // windows path separator is "\" instead of "/" - loaderDllPath = strings.ReplaceAll(loaderDllPath, "/", "\\") + agentDllPath = strings.ReplaceAll(agentDllPath, "/", "\\") - // build the loader DLL path relative to the app directory - // e.g. dynatrace/oneagent/agent/bin/windows-x86-64/oneagentloader.dll - loaderDllPathInAppDir := filepath.Join(installDir, loaderDllPath) + // build the agent DLL path relative to the app directory + // e.g. dynatrace/oneagent/agent/bin/windows-x86-64/oneagentdotnet.dll + agentDllPathInAppDir := filepath.Join(installDir, agentDllPath) - // check that the loader dll is present in the build dir - // e.g. at \tmp\app\dynatrace\oneagent\agent\bin\1.303.0.20240930-081133\windows-x86-32\oneagentloader.dll - loaderDllPathInBuildDir := filepath.Join(stager.BuildDir(), loaderDllPathInAppDir) + // check that the agent dll is present in the build dir + // e.g. at \tmp\app\dynatrace\oneagent\agent\bin\1.303.0.20240930-081133\windows-x86-32\oneagentdotnet.dll + agentDllPathInBuildDir := filepath.Join(stager.BuildDir(), agentDllPathInAppDir) - if _, err = os.Stat(loaderDllPathInBuildDir); os.IsNotExist(err) { - h.Log.Error("Agent library (%s) not found!", loaderDllPathInBuildDir) + if _, err = os.Stat(agentDllPathInBuildDir); os.IsNotExist(err) { + h.Log.Error("Agent library (%s) not found!", agentDllPathInBuildDir) return "", err } - // build the absolute path of the loader DLL as it will be available at runtime - return filepath.Join("C:\\users\\vcap\\app", loaderDllPathInAppDir), nil + // build the absolute path of the agent DLL as it will be available at runtime + return filepath.Join("C:\\users\\vcap\\app", agentDllPathInAppDir), nil } diff --git a/vendor/github.com/cloudfoundry/libbuildpack/installer.go b/vendor/github.com/cloudfoundry/libbuildpack/installer.go index ebcf2d406..dbbf34774 100644 --- a/vendor/github.com/cloudfoundry/libbuildpack/installer.go +++ b/vendor/github.com/cloudfoundry/libbuildpack/installer.go @@ -110,7 +110,7 @@ func (i *Installer) InstallDependencyWithStrip(dep Dependency, outputDir string, func (i *Installer) warnNewerPatch(dep Dependency) error { - v, err := semver.NewVersion(dep.Version) + v, err := semver.NewVersion(normalizeSemver(dep.Version)) if err != nil { return nil } @@ -131,6 +131,11 @@ func (i *Installer) warnNewerPatch(dep Dependency) error { latest, err := FindMatchingVersion(constraint, versions) if err != nil { + if normalizeSemver(dep.Version) != dep.Version { + // Versions with more than three fields were never checked before; + // don't let an unparsable sibling version fail their installation. + return nil + } return err } @@ -142,13 +147,13 @@ func (i *Installer) warnNewerPatch(dep Dependency) error { } func (i *Installer) warnEndOfLife(dep Dependency) error { - matchVersion := func(versionLine, depVersion string) bool { + matchSemver := func(versionLine, depVersion string) bool { return versionLine == depVersion } - v, err := semver.NewVersion(dep.Version) + v, err := semver.NewVersion(normalizeSemver(dep.Version)) if err == nil { - matchVersion = func(versionLine, depVersion string) bool { + matchSemver = func(versionLine, depVersion string) bool { constraint, err := semver.NewConstraint(versionLine) if err != nil { return false @@ -158,6 +163,16 @@ func (i *Installer) warnEndOfLife(dep Dependency) error { } } + matchVersion := func(versionLine, depVersion string) bool { + // Exact version lines such as "21.0.12+10" or "21.0.12.1" are matched + // like exact FindMatchingVersion constraints; semver would ignore the + // build number or fail to parse more than three fields. + if c, ok := isExactJEP322Constraint(versionLine); ok { + return matchesExactJEP322(c, depVersion) + } + return matchSemver(versionLine, depVersion) + } + for _, deprecation := range i.manifest.Deprecations { if deprecation.Name != dep.Name { continue diff --git a/vendor/github.com/cloudfoundry/libbuildpack/packager/README.md b/vendor/github.com/cloudfoundry/libbuildpack/packager/README.md index cb626df5f..d4533c047 100644 --- a/vendor/github.com/cloudfoundry/libbuildpack/packager/README.md +++ b/vendor/github.com/cloudfoundry/libbuildpack/packager/README.md @@ -20,3 +20,142 @@ For more on go-bindata: https://github.com/jteeuwen/go-bindata ``` ginkgo -r ``` + +--- + +## Selective Dependency Packaging + +`buildpack-packager` supports building **cached** buildpacks that contain only a named +subset of dependencies. This is useful for operators who need a smaller artifact or a +pre-defined variant (e.g. a "minimal" build without optional agent libraries). + +> **Note:** `--profile`, `--exclude`, and `--include` are only valid for **cached** +> buildpacks (`--cached` flag). Using them on an uncached build is a hard error. + +### Packaging profiles + +A buildpack author defines named profiles in `manifest.yml` under the +`packaging_profiles` key: + +```yaml +packaging_profiles: + minimal: + description: "Core runtime only — no agents or profilers" + exclude: + - agent-dep + - profiler-dep + + no-profiler: + description: "Full build minus the profiler library" + exclude: + - profiler-dep +``` + +Each profile has: + +| Field | Type | Description | +|---------------|----------------|-------------| +| `description` | string | Human-readable summary shown by `buildpack-packager summary` | +| `exclude` | list of string | Dependency names to omit when this profile is active | + +Profile names must match `^[a-z0-9_-]+$` (lowercase letters, digits, hyphens, +underscores). This keeps names safe for embedding in zip filenames. + +All dependency names listed in a profile's `exclude` list must exist in the +manifest — a typo is a hard error at packaging time. + +### CLI flags + +| Flag | Argument | Description | +|------|----------|-------------| +| `--profile` | profile name | Activate a named profile from `manifest.yml` | +| `--exclude` | `dep1,dep2,...` | Additional dependencies to exclude (comma-separated) | +| `--include` | `dep1,dep2,...` | Restore dependencies that the active profile excluded | + +#### Examples + +```sh +# Build with the "minimal" profile (omits agent-dep and profiler-dep) +buildpack-packager --cached --stack cflinuxfs4 --profile minimal + +# Build with the "minimal" profile but restore profiler-dep +buildpack-packager --cached --stack cflinuxfs4 --profile minimal --include profiler-dep + +# No profile — just exclude a specific dependency +buildpack-packager --cached --stack cflinuxfs4 --exclude agent-dep + +# Combine a profile with an extra exclusion +buildpack-packager --cached --stack cflinuxfs4 --profile no-profiler --exclude agent-dep +``` + +### Resolution order + +1. Profile's `exclude` list is applied first. +2. `--exclude` names are **unioned** with the profile exclusions. +3. `--include` names are **removed** from the exclusion set (overrides the profile). + +Excluded dependencies are neither downloaded nor written into the packaged +`manifest.yml`. + +### Output filename + +The zip filename encodes which variant was built: + +| Options used | Filename pattern | +|---|---| +| No opts | `_buildpack-cached--v.zip` | +| `--profile minimal` | `_buildpack-cached-minimal--v.zip` | +| `--profile minimal --include profiler-dep` | `_buildpack-cached-minimal+custom--v.zip` | +| `--profile minimal --exclude extra-dep` | `_buildpack-cached-minimal+custom--v.zip` | +| `--exclude agent-dep` (no profile) | `_buildpack-cached-custom--v.zip` | + +The `+custom` suffix appears only when the result deviates from a pure profile: +either an extra `--exclude` was added, or `--include` actually overrode one of +the profile's exclusions. + +### Error conditions + +All validation errors are **hard errors** — the packager exits non-zero with a +descriptive message. There are no silent no-ops or warnings. + +| Situation | Error message | +|---|---| +| `--profile` / `--exclude` / `--include` on uncached build | `--profile/--exclude/--include are only valid for cached buildpacks` | +| `--include` without `--profile` | `--include requires --profile` | +| Unknown profile name | `packaging profile "" not found in manifest` | +| Invalid profile name characters | `profile name "" is invalid: must match ^[a-z0-9_-]+$` | +| Unknown dep in `--exclude` | `dependency "" not found in manifest` | +| Unknown dep in `--include` | `dependency "" not found in manifest` | +| `--include` of dep not excluded by profile | `--include "" has no effect: dependency is not excluded by the profile or --exclude` | +| Profile's `exclude` list references unknown dep | `profile "" references unknown dependency ""` | + +### Go API + +`Package()` is unchanged and delegates to `PackageWithOptions` with zero options: + +```go +// Legacy — unchanged behaviour +zipFile, err := packager.Package(bpDir, cacheDir, version, stack, cached) + +// New — selective packaging +zipFile, err := packager.PackageWithOptions(bpDir, cacheDir, version, stack, true, + packager.PackageOptions{ + Profile: "minimal", + Include: []string{"profiler-dep"}, + }) +``` + +`PackageOptions` fields: + +```go +type PackageOptions struct { + // Profile is a packaging_profiles key from manifest.yml. + Profile string + // Exclude lists additional dependency names to skip. + Exclude []string + // Include restores dependency names excluded by Profile. + // Requires Profile to be set. Hard error if a name was not excluded. + Include []string +} +``` + diff --git a/vendor/github.com/cloudfoundry/libbuildpack/packager/models.go b/vendor/github.com/cloudfoundry/libbuildpack/packager/models.go index e9150d919..d4b309f0a 100644 --- a/vendor/github.com/cloudfoundry/libbuildpack/packager/models.go +++ b/vendor/github.com/cloudfoundry/libbuildpack/packager/models.go @@ -15,6 +15,12 @@ type Dependency struct { type SubDependency struct{ Name string } type Dependencies []Dependency +// PackagingProfile defines a named dependency exclusion set for use at packaging time. +type PackagingProfile struct { + Description string `yaml:"description"` + Exclude []string `yaml:"exclude"` +} + type Manifest struct { Language string `yaml:"language"` Stack string `yaml:"stack"` @@ -25,6 +31,7 @@ type Manifest struct { Name string `yaml:"name"` Version string `yaml:"version"` } `yaml:"default_versions"` + PackagingProfiles map[string]PackagingProfile `yaml:"packaging_profiles"` } type File struct { diff --git a/vendor/github.com/cloudfoundry/libbuildpack/packager/packager.go b/vendor/github.com/cloudfoundry/libbuildpack/packager/packager.go index 2f0810686..b0c61b049 100644 --- a/vendor/github.com/cloudfoundry/libbuildpack/packager/packager.go +++ b/vendor/github.com/cloudfoundry/libbuildpack/packager/packager.go @@ -15,12 +15,17 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "strings" "github.com/cloudfoundry/libbuildpack" "gopkg.in/yaml.v2" ) +// profileNameRe restricts profile names to safe characters that can be +// embedded in a zip filename without escaping or path-traversal risk. +var profileNameRe = regexp.MustCompile(`^[a-z0-9_-]+$`) + type sha struct { Sha map[string]string `yaml:"sha"` } @@ -152,7 +157,92 @@ func downloadDependency(dependency Dependency, cacheDir string) (File, error) { return File{file, filepath.Join(cacheDir, file)}, nil } +// PackageOptions configures optional selective-packaging behaviour for PackageWithOptions. +// All fields are optional; zero values produce identical output to the legacy Package function. +type PackageOptions struct { + // Profile is the name of a packaging_profiles entry in manifest.yml. + // Its exclude list is applied before Exclude and Include are processed. + Profile string + // Exclude is an additional list of dependency names to skip, unioned with + // any exclusions implied by Profile. + Exclude []string + // Include restores specific dependency names that would otherwise be excluded + // by Profile. It is a no-op (with a warning) when Profile is empty. + Include []string +} + +// resolveExclusions returns the set of dependency names that should be skipped +// during packaging, and the count of include names that actually overrode a +// profile exclusion (used by the caller to decide the +custom filename suffix). +// Resolution order: +// 1. Profile's exclude list (if a profile is named). +// 2. Explicit Exclude names are unioned in. +// 3. Explicit Include names are removed (overrides profile exclusions). +// +// An error is returned if the profile name is unknown or if any exclude/include +// name does not exist in the manifest (including names in the profile's exclude +// list itself). +func resolveExclusions(manifest Manifest, profile string, exclude []string, include []string) (map[string]struct{}, int, error) { + // Build a set of all known dependency names for validation. + depNames := make(map[string]struct{}, len(manifest.Dependencies)) + for _, d := range manifest.Dependencies { + depNames[d.Name] = struct{}{} + } + + // 1. Start with profile exclusions. + result := make(map[string]struct{}) + if profile != "" { + if !profileNameRe.MatchString(profile) { + return nil, 0, fmt.Errorf("profile name %q is invalid: must match ^[a-z0-9_-]+$", profile) + } + p, ok := manifest.PackagingProfiles[profile] + if !ok { + return nil, 0, fmt.Errorf("packaging profile %q not found in manifest", profile) + } + for _, name := range p.Exclude { + if _, ok := depNames[name]; !ok { + return nil, 0, fmt.Errorf("profile %q references unknown dependency %q", profile, name) + } + result[name] = struct{}{} + } + } + + // 2. Union with explicitly excluded names. + for _, name := range exclude { + if _, ok := depNames[name]; !ok { + return nil, 0, fmt.Errorf("dependency %q not found in manifest", name) + } + result[name] = struct{}{} + } + + // 3. Remove explicitly included names (overrides profile). + // Count how many of these actually removed something from the set. + // It is a hard error to --include a name that was never excluded (likely a typo). + effectiveIncludes := 0 + for _, name := range include { + if _, ok := depNames[name]; !ok { + return nil, 0, fmt.Errorf("dependency %q not found in manifest", name) + } + if _, wasExcluded := result[name]; !wasExcluded { + return nil, 0, fmt.Errorf("--include %q has no effect: dependency is not excluded by the profile or --exclude", name) + } + effectiveIncludes++ + delete(result, name) + } + + return result, effectiveIncludes, nil +} + +// Package is the legacy entry point. It delegates to PackageWithOptions with +// zero-value options so all existing callers remain unaffected. func Package(bpDir, cacheDir, version, stack string, cached bool) (string, error) { + return PackageWithOptions(bpDir, cacheDir, version, stack, cached, PackageOptions{}) +} + +// PackageWithOptions creates a buildpack zip, optionally filtering dependencies +// according to opts (profile, exclude, include). When opts is zero-value the +// behaviour is identical to the legacy Package function. +func PackageWithOptions(bpDir, cacheDir, version, stack string, cached bool, opts PackageOptions) (string, error) { bpDir, err := filepath.Abs(bpDir) if err != nil { return "", err @@ -177,6 +267,28 @@ func Package(bpDir, cacheDir, version, stack string, cached bool) (string, error return "", err } + // --profile/--exclude/--include only apply to cached buildpacks. + if !cached && (opts.Profile != "" || len(opts.Exclude) > 0 || len(opts.Include) > 0) { + return "", fmt.Errorf("--profile/--exclude/--include are only valid for cached buildpacks") + } + + // --include requires --profile (nothing to override otherwise). + if opts.Profile == "" && len(opts.Include) > 0 { + return "", fmt.Errorf("--include requires --profile") + } + + // Resolve which dependency names to skip before the download loop. + // On uncached builds the exclusion set is never used, so skip validation. + excluded := map[string]struct{}{} + effectiveIncludes := 0 + if cached { + var err2 error + excluded, effectiveIncludes, err2 = resolveExclusions(manifest, opts.Profile, opts.Exclude, opts.Include) + if err2 != nil { + return "", err2 + } + } + if manifest.PrePackage != "" { cmd := exec.Command(manifest.PrePackage) cmd.Dir = dir @@ -207,6 +319,12 @@ func Package(bpDir, cacheDir, version, stack string, cached bool) (string, error } dependenciesForStack := []interface{}{} for idx, d := range manifest.Dependencies { + // Skip excluded dependencies — they are not downloaded and are not + // written into the packaged manifest.yml. + if _, skip := excluded[d.Name]; skip { + continue + } + for _, s := range d.Stacks { if stack == "" || s == stack { dependencyMap := deps[idx] @@ -242,7 +360,21 @@ func Package(bpDir, cacheDir, version, stack string, cached bool) (string, error cachedPart = "-cached" } - fileName := fmt.Sprintf("%s_buildpack%s%s-v%s.zip", manifest.Language, cachedPart, stackPart, version) + // Build the profile/exclusion suffix for the filename. + // +custom is only appended when there is genuine customisation on top of + // the profile: either an extra --exclude, or an --include that actually + // overrode one of the profile's exclusions (effectiveIncludes > 0). + profilePart := "" + if opts.Profile != "" { + profilePart = "-" + opts.Profile + if len(opts.Exclude) > 0 || effectiveIncludes > 0 { + profilePart += "+custom" + } + } else if len(opts.Exclude) > 0 { + profilePart = "-custom" + } + + fileName := fmt.Sprintf("%s_buildpack%s%s%s-v%s.zip", manifest.Language, cachedPart, profilePart, stackPart, version) zipFile := filepath.Join(bpDir, fileName) if err := ZipFiles(zipFile, files); err != nil { diff --git a/vendor/github.com/cloudfoundry/libbuildpack/packager/summary.go b/vendor/github.com/cloudfoundry/libbuildpack/packager/summary.go index 7381c30cf..67237f8d3 100644 --- a/vendor/github.com/cloudfoundry/libbuildpack/packager/summary.go +++ b/vendor/github.com/cloudfoundry/libbuildpack/packager/summary.go @@ -62,5 +62,17 @@ func Summary(bpDir string) (string, error) { } } + if len(manifest.PackagingProfiles) > 0 { + out += "\nPackaging profiles:\n\n" + profileNames := make([]string, 0, len(manifest.PackagingProfiles)) + for name := range manifest.PackagingProfiles { + profileNames = append(profileNames, name) + } + sort.Strings(profileNames) + for _, name := range profileNames { + out += fmt.Sprintf(" %-12s %s\n", name, manifest.PackagingProfiles[name].Description) + } + } + return out, nil } diff --git a/vendor/github.com/cloudfoundry/libbuildpack/versions.go b/vendor/github.com/cloudfoundry/libbuildpack/versions.go index f510997e0..0b9f34bc9 100644 --- a/vendor/github.com/cloudfoundry/libbuildpack/versions.go +++ b/vendor/github.com/cloudfoundry/libbuildpack/versions.go @@ -2,7 +2,10 @@ package libbuildpack import ( "fmt" + "regexp" "sort" + "strconv" + "strings" semver2 "github.com/Masterminds/semver" semver1 "github.com/blang/semver" @@ -14,9 +17,163 @@ type versionWithOriginal struct { } type versionsWithOriginal []versionWithOriginal -func (v versionsWithOriginal) Len() int { return len(v) } -func (v versionsWithOriginal) Swap(i, j int) { v[i], v[j] = v[j], v[i] } -func (v versionsWithOriginal) Less(i, j int) bool { return v[i].version.LT(v[j].version) } +func (v versionsWithOriginal) Len() int { return len(v) } +func (v versionsWithOriginal) Swap(i, j int) { v[i], v[j] = v[j], v[i] } +func (v versionsWithOriginal) Less(i, j int) bool { + if v[i].version.EQ(v[j].version) { + return compareJEP322(v[i].original, v[j].original) < 0 + } + return v[i].version.LT(v[j].version) +} + +// jep322Regex matches numeric JEP 322 style versions: any number of numeric +// fields, optionally followed by a numeric build number, e.g. "21", "21.0.12", +// "21.0.12.1", "21.0.10.0.1", "21.0.12+10" or "21.0.12.1+1". +// See https://openjdk.org/jeps/322. +var jep322Regex = regexp.MustCompile(`^(\d+(?:\.\d+)*)(?:\+(\d+))?$`) + +type jep322Version struct { + fields []int + build int // -1 if absent +} + +// parseJEP322 parses a numeric JEP 322 style version. It returns false for +// anything else, e.g. versions with pre-release identifiers or non-numeric +// build metadata, which are left to the semver libraries. +func parseJEP322(ver string) (jep322Version, bool) { + m := jep322Regex.FindStringSubmatch(ver) + if m == nil { + return jep322Version{}, false + } + parts := strings.Split(m[1], ".") + v := jep322Version{fields: make([]int, len(parts)), build: -1} + for i, p := range parts { + n, err := strconv.Atoi(p) + if err != nil { + return jep322Version{}, false + } + v.fields[i] = n + } + if m[2] != "" { + n, err := strconv.Atoi(m[2]) + if err != nil { + return jep322Version{}, false + } + v.build = n + } + return v, true +} + +// compareFields compares numeric fields, treating missing fields as zero, +// so it reports "21.0.12" and "21.0.12.0" as equal. compareJEP322 breaks +// such ties by number of fields; matchesExactJEP322 requires equal counts. +func (a jep322Version) compareFields(b jep322Version) int { + for i := 0; i < len(a.fields) || i < len(b.fields); i++ { + var x, y int + if i < len(a.fields) { + x = a.fields[i] + } + if i < len(b.fields) { + y = b.fields[i] + } + if x != y { + if x < y { + return -1 + } + return 1 + } + } + return 0 +} + +// compareJEP322 is the tie-breaker for versions that are equal according to +// semver. It orders two numeric JEP 322 versions by all numeric fields +// (trailing zeros insignificant), then by numeric build number +// (absent < +1 < +2), and finally by number of fields so that ordering stays +// deterministic ("21.0.12" < "21.0.12.0"). Other versions (e.g. with +// non-numeric build metadata such as "21.0.12+foo") are equal to each other +// and sort before numeric JEP 322 versions, keeping the ordering transitive. +func compareJEP322(a, b string) int { + va, okA := parseJEP322(a) + vb, okB := parseJEP322(b) + if !okA || !okB { + switch { + case okA: + return 1 + case okB: + return -1 + default: + return 0 + } + } + if c := va.compareFields(vb); c != 0 { + return c + } + if va.build != vb.build { + if va.build < vb.build { + return -1 + } + return 1 + } + return len(va.fields) - len(vb.fields) +} + +// normalizeSemver truncates a numeric JEP 322 version with more than three +// fields (e.g. "21.0.12.1", "21.0.12.1+1" or "21.0.10.0.1") to its first three +// fields ("21.0.12") so that the semver libraries can parse it. The original +// string is preserved separately for output and ordering (see compareJEP322). +// All other strings, including 3-part versions with build metadata +// ("21.0.12+10") and pre-release versions ("8.0.100-preview.7.23376.3"), are +// returned unchanged. +func normalizeSemver(ver string) string { + if v, ok := parseJEP322(ver); ok && len(v.fields) > 3 { + return fmt.Sprintf("%d.%d.%d", v.fields[0], v.fields[1], v.fields[2]) + } + return ver +} + +// isExactJEP322Constraint reports whether constraint is an exact numeric +// version that the semver libraries cannot handle correctly as a constraint: +// more than three fields ("21.0.12.1") or an explicit build number +// ("21.0.12+10", "21.0.12.1+1"). +func isExactJEP322Constraint(constraint string) (jep322Version, bool) { + v, ok := parseJEP322(constraint) + if !ok || (len(v.fields) <= 3 && v.build < 0) { + return jep322Version{}, false + } + return v, true +} + +// matchesExactJEP322 reports whether ver equals the exact constraint c. The +// numeric fields must be identical, including their number ("21.0.12.0" does +// not match "21.0.12"). Without a build number in the constraint any build +// matches ("21.0.12.1" matches "21.0.12.1+1" and "21.0.12.1+2"); with one, +// the build must be equal. +func matchesExactJEP322(c jep322Version, ver string) bool { + v, ok := parseJEP322(ver) + if !ok || len(v.fields) != len(c.fields) || v.compareFields(c) != 0 { + return false + } + return c.build < 0 || v.build == c.build +} + +// matchExactJEP322 returns all versions matching the exact constraint, see +// matchesExactJEP322. +func matchExactJEP322(constraint string, c jep322Version, versions []string) ([]string, error) { + var matched []string + for _, ver := range versions { + if matchesExactJEP322(c, ver) { + matched = append(matched, ver) + } + } + if len(matched) == 0 { + return []string{}, fmt.Errorf("no match found for %s in %v", constraint, versions) + } + sort.SliceStable(matched, func(i, j int) bool { + return compareJEP322(matched[i], matched[j]) < 0 + }) + return matched, nil +} func FindMatchingVersion(constraint string, versions []string) (string, error) { vs, err := FindMatchingVersions(constraint, versions) @@ -27,6 +184,13 @@ func FindMatchingVersion(constraint string, versions []string) (string, error) { } func FindMatchingVersions(constraint string, versions []string) ([]string, error) { + // Short-circuit: exact JEP 322 version constraint. Neither blang/semver nor + // Masterminds/semver accept more than three fields, and both ignore build + // metadata when comparing. + if c, ok := isExactJEP322Constraint(constraint); ok { + return matchExactJEP322(constraint, c, versions) + } + matchedVersions, err := matchSemver1(constraint, versions) if err == nil { return matchedVersions, nil @@ -43,17 +207,16 @@ func matchSemver1(constraint string, versions []string) ([]string, error) { } for _, ver := range versions { - depVersion, err := semver1.Parse(ver) + depVersion, err := semver1.Parse(normalizeSemver(ver)) if err != nil { return []string{}, err } - versionWithOriginal := versionWithOriginal{ - original: ver, - version: depVersion, - } if versionConstraint(depVersion) { - depVersions = append(depVersions, versionWithOriginal) + depVersions = append(depVersions, versionWithOriginal{ + original: ver, + version: depVersion, + }) } } @@ -70,28 +233,40 @@ func matchSemver1(constraint string, versions []string) ([]string, error) { } func matchSemver2(constraint string, versions []string) ([]string, error) { - var depVersions []*semver2.Version + type versionEntry struct { + original string + parsed *semver2.Version + } + var depVersions []versionEntry versionConstraint, err := semver2.NewConstraint(constraint) if err != nil { return []string{}, err } for _, ver := range versions { - depVersion, err := semver2.NewVersion(ver) + depVersion, err := semver2.NewVersion(normalizeSemver(ver)) if err != nil { return []string{}, err } if versionConstraint.Check(depVersion) { - depVersions = append(depVersions, depVersion) + depVersions = append(depVersions, versionEntry{ + original: ver, + parsed: depVersion, + }) } } if len(depVersions) != 0 { - sort.Sort(semver2.Collection(depVersions)) + sort.Slice(depVersions, func(i, j int) bool { + if depVersions[i].parsed.Equal(depVersions[j].parsed) { + return compareJEP322(depVersions[i].original, depVersions[j].original) < 0 + } + return depVersions[i].parsed.LessThan(depVersions[j].parsed) + }) var vs []string - for _, depV := range depVersions { - vs = append(vs, depV.Original()) + for _, e := range depVersions { + vs = append(vs, e.original) } return vs, nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 9803a1092..594233305 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,7 @@ # code.cloudfoundry.org/lager v2.0.0+incompatible ## explicit code.cloudfoundry.org/lager -# github.com/Dynatrace/libbuildpack-dynatrace v1.8.0 +# github.com/Dynatrace/libbuildpack-dynatrace v1.10.0 ## explicit; go 1.19 github.com/Dynatrace/libbuildpack-dynatrace # github.com/Masterminds/semver v1.5.0 @@ -23,7 +23,7 @@ github.com/blang/semver # github.com/cenkalti/backoff/v4 v4.3.0 ## explicit; go 1.18 github.com/cenkalti/backoff/v4 -# github.com/cloudfoundry/libbuildpack v0.0.0-20260306125332-dcaf55eb6f33 +# github.com/cloudfoundry/libbuildpack v0.0.0-20261012122722-6cd465089938 ## explicit; go 1.22.5 github.com/cloudfoundry/libbuildpack github.com/cloudfoundry/libbuildpack/ansicleaner