chainguard-dev / melange

build APKs from source code
Apache License 2.0
416 stars 97 forks source link

nginx melange build fails on mac #370

Closed amouat closed 1 year ago

amouat commented 1 year ago

Building Chainguard Image nginx on my mac fails with:

 strip: unable to copy file './usr/lib/perl5/vendor_perl/aarch64-linux-thread-multi/auto/nginx/nginx.so'; reason: Operation not permitted

Build command:

make packages/nginx BUILDWORLD=no

Mac version:

❯ uname -a
Darwin Adrians-MBP.home 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64

Melange version

./melange version
  __  __   _____   _          _      _   _    ____   _____
 |  \/  | | ____| | |        / \    | \ | |  / ___| | ____|
 | |\/| | |  _|   | |       / _ \   |  \| | | |  _  |  _|
 | |  | | | |___  | |___   / ___ \  | |\  | | |_| | | |___
 |_|  |_| |_____| |_____| /_/   \_\ |_| \_|  \____| |_____|
melange

GitVersion:    v0.3.0-24-g2e81bb9
GitCommit:     2e81bb97c2159ccb64485821d005892856e7c91c
GitTreeState:  clean
BuildDate:     '2023-04-02T17:00:59Z'
GoVersion:     go1.20.2
Compiler:      gc
Platform:      darwin/arm64

Abridged output, including setup (I suspect the issue might be here):

mkdir -p ./nginx/
SOURCE_DATE_EPOCH=0 ../melange/melange build nginx.yaml --repository-append /Users/amouat/proj/wolfi-os/packages --keyring-append local-melange.rsa.pub --signing-key local-melange.rsa --pipeline-dir ../melange/pipelines --arch aarch64 --env-file build-aarch64.env --namespace wolfi --generate-index false  --cache-source gs://wolfi-sources/ -k https://packages.wolfi.dev/os/wolfi-signing.rsa.pub -r https://packages.wolfi.dev/os --source-dir ./nginx/
2023/04/03 15:19:51 building for [arm64]
2023/04/03 15:19:51 melange: detected git commit for build configuration: b61c8047ee7e528025a2ece6326a3fb7e1929224
2023/04/03 15:19:51 cannot use bubblewrap for containers: bwrap not found on $PATH
2023/04/03 15:19:51 melange (nginx/aarch64): melange is building:
2023/04/03 15:19:51 melange (nginx/aarch64):   configuration file: nginx.yaml
2023/04/03 15:19:51 melange (nginx/aarch64):   workspace dir: /var/folders/g9/k525vdmx1ks2hy9qktq1x4qh0000gn/T/melange-workspace-3812097337
2023/04/03 15:19:51 melange (nginx/aarch64): evaluating pipelines for package requirements
2023/04/03 15:19:51 melange (nginx/aarch64):   adding package "wget" for pipeline "Fetch and extract external object into workspace"
2023/04/03 15:19:51 melange (nginx/aarch64):   adding package "binutils" for pipeline "Strip binaries"
2023/04/03 15:19:51 melange (nginx/aarch64):   adding package "scanelf" for pipeline "Strip binaries"
2023/04/03 15:19:51 melange (nginx/aarch64): building workspace in '/var/folders/g9/k525vdmx1ks2hy9qktq1x4qh0000gn/T/melange-guest-165799782' with apko

...

2023/04/03 15:49:48 melange (nginx/aarch64): make[1]: Leaving directory '/home/build'
2023/04/03 15:49:48 melange (nginx/aarch64): running step strip
2023/04/03 15:49:48 melange (nginx/aarch64):   using strip
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{package.name}}: nginx
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{package.epoch}}: 1
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{cross.triplet.gnu.glibc}}: aarch64-unknown-linux-gnu
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{cross.triplet.gnu.musl}}: aarch64-unknown-linux-musl
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{build.arch}}: aarch64
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{package.version}}: 1.23.3
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{targets.destdir}}: /home/build/melange-out/nginx
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{host.triplet.gnu}}: aarch64-unknown-linux-gnu
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{host.triplet.rust}}: aarch64-unknown-linux-gnu
2023/04/03 15:49:48 melange (nginx/aarch64): running step Strip binaries
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{package.epoch}}: 1
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{targets.destdir}}: /home/build/melange-out/nginx
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{cross.triplet.gnu.glibc}}: aarch64-unknown-linux-gnu
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{cross.triplet.gnu.musl}}: aarch64-unknown-linux-musl
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{build.arch}}: aarch64
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{package.version}}: 1.23.3
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{host.triplet.gnu}}: aarch64-unknown-linux-gnu
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{host.triplet.rust}}: aarch64-unknown-linux-gnu
2023/04/03 15:49:48 melange (nginx/aarch64):     ${{package.name}}: nginx
2023/04/03 15:49:49 melange (nginx/aarch64): strip: unable to copy file './usr/lib/perl5/vendor_perl/aarch64-linux-thread-multi/auto/nginx/nginx.so'; reason: Operation not permitted
2023/04/03 15:49:49 ERROR: failed to build package. the build environment has been preserved:
2023/04/03 15:49:49 melange (nginx/aarch64):   workspace dir: /var/folders/g9/k525vdmx1ks2hy9qktq1x4qh0000gn/T/melange-workspace-2203078242
2023/04/03 15:49:49 melange (nginx/aarch64):   guest dir: /var/folders/g9/k525vdmx1ks2hy9qktq1x4qh0000gn/T/melange-guest-3130225697
Error: failed to build package: unable to run pipeline: task exited with code 1
2023/04/03 15:49:49 error during command execution: failed to build package: unable to run pipeline: task exited with code 1
make: *** [packages/aarch64/nginx-1.23.3-r1.apk] Error 1
amouat commented 1 year ago

It's also much slower than the Docker build, so I'm sure I've set something up wrong.

amouat commented 1 year ago

This is fixed.