Closed dmikusa closed 4 months ago
To test, I ran this code on a buildpack with no targets. It produced this build, which is correct.
Paketo Buildpack for Apache Tomcat 1.2.3
https://github.com/paketo-buildpacks/apache-tomcat
Creating package in ./out
Pre-package with scripts/build.sh
Adding LICENSE
Adding NOTICE
Adding README.md
Adding bin/build
Adding bin/detect
Adding bin/helper
Adding bin/main
Adding buildpack.toml
Adding resources/context.xml
Adding resources/logging.properties
Adding resources/server.xml
Adding resources/web.xml
I ran it against a buildpack with targets and it produced this output, which is also correct. Notice how it fans out the non-arch specific files into each arch-specific folder.
Paketo Buildpack for Apache Tomcat 1.2.3
https://github.com/paketo-buildpacks/apache-tomcat
Creating package in ./out
Pre-package with scripts/build.sh
Adding buildpack.toml
Adding linux/amd64/LICENSE
Adding linux/amd64/NOTICE
Adding linux/amd64/README.md
Adding linux/amd64/bin/build
Adding linux/amd64/bin/detect
Adding linux/amd64/bin/helper
Adding linux/amd64/bin/main
Adding linux/amd64/resources/context.xml
Adding linux/amd64/resources/logging.properties
Adding linux/amd64/resources/server.xml
Adding linux/amd64/resources/web.xml
Adding linux/arm64/LICENSE
Adding linux/arm64/NOTICE
Adding linux/arm64/README.md
Adding linux/arm64/bin/build
Adding linux/arm64/bin/detect
Adding linux/arm64/bin/helper
Adding linux/arm64/bin/main
Adding linux/arm64/resources/context.xml
Adding linux/arm64/resources/logging.properties
Adding linux/arm64/resources/server.xml
Adding linux/arm64/resources/web.xml
I built an image from the output and it's including all the files now:
All good, here's how I tested:
go install -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/create-package@package-arches
cd ~/paketo-buildpacks/apache-tomcat
create-package --source . --destination ~/buildpack --version 9.9.9
Paketo Buildpack for Apache Tomcat 9.9.9
https://github.com/paketo-buildpacks/apache-tomcat
Creating package in /home/ubuntu/buildpack
Pre-package with scripts/build.sh
go: downloading github.com/paketo-buildpacks/libpak v1.69.0
Adding buildpack.toml
Adding linux/amd64/LICENSE
Adding linux/amd64/NOTICE
Adding linux/amd64/README.md
Adding linux/amd64/bin/build
Adding linux/amd64/bin/detect
Adding linux/amd64/bin/helper
Adding linux/amd64/bin/main
Adding linux/amd64/resources/context.xml
Adding linux/amd64/resources/logging.properties
Adding linux/amd64/resources/server.xml
Adding linux/amd64/resources/web.xml
Adding linux/arm64/LICENSE
Adding linux/arm64/NOTICE
Adding linux/arm64/README.md
Adding linux/arm64/bin/build
Adding linux/arm64/bin/detect
Adding linux/arm64/bin/helper
Adding linux/arm64/bin/main
Adding linux/arm64/resources/context.xml
Adding linux/arm64/resources/logging.properties
Adding linux/arm64/resources/server.xml
Adding linux/arm64/resources/web.xml
cd ~/buildpack
~/my-exp-pack buildpack package anthonydahanne/apache-tomcat:dual --publish
Successfully published package anthonydahanne/apache-tomcat:dual and saved to registry
and then I dive
'd into it
Summary
We recently added targets to the
include-files
list inbuildpack.toml
. The referenced files get packaged up into the buildpack. What we added were some files prefixed withlinux/<arch>/...
. These files get put into that location within the generated buildpack directory. This is to work with a new version of pack that packages multi-arch images. It packages up whatever is under each architecture directory into the image specific to that architecture.What's happened is that we now have non-architecture dependent files like the README and LICENSE which are not being included in the images. These files also need to be prefixed with the path for each architecture. Instead of putting a lot of duplicate entries into the
include-files
list, what this PR does is to take any file not prefixed withlinux/
and duplicate it for all of the detected architectures.The PR determines the list of target architectures by looking at the
include-files
list and pulling out all of the distinctlinux/<arch>
's that it sees. This isn't the best implementation but it's all we can do with the v1.x branch of libpak because the target metadata is not present in that version of libcnb. In libpak 2.x, we'll be able to read the target list directly frombuildpack.toml
and use that instead, which is a better option.Use Cases
Multi-arch support.
Checklist