Open ckoehler opened 3 weeks ago
Same thing with Docker:
❯ docker run --rm --privileged -v "$(pwd)":/work cgr.dev/chainguard/melange build --arch aarch64 test.yaml
❯ docker run --rm --privileged -v "$(pwd)":/work cgr.dev/chainguard/melange version
__ __ _____ _ _ _ _ ____ _____
| \/ | | ____| | | / \ | \ | | / ___| | ____|
| |\/| | | _| | | / _ \ | \| | | | _ | _|
| | | | | |___ | |___ / ___ \ | |\ | | |_| | | |___
|_| |_| |_____| |_____| /_/ \_\ |_| \_| \____| |_____|
melange
GitVersion: v0.14.7
GitCommit: 71c88c32251b71894867172d355a13ee703f86ec
GitTreeState: clean
BuildDate: '2024-10-23T15:39:27Z'
GoVersion: go1.23.2
Compiler: gc
Platform: linux/arm64
A few more debug logs:
[...]
2024/10/23 18:08:11 DEBU finished building filesystem
2024/10/23 18:08:13 INFO built image layer tarball as /tmp/apko-temp-916801685/apko-aarch64.tar.gz
2024/10/23 18:08:13 INFO using /tmp/apko-temp-916801685/apko-aarch64.tar.gz for image layer
2024/10/23 18:08:18 DEBU pushed /tmp/apko-temp-916801685/apko-aarch64.tar.gz as /tmp/melange-guest-3950364476
2024/10/23 18:08:18 DEBU successfully built workspace with apko
2024/10/23 18:08:18 INFO ImgRef = /tmp/melange-guest-3950364476
2024/10/23 18:08:18 DEBU executing: bwrap --bind /tmp/melange-guest-3950364476 / --bind /tmp/melange-workspace-3540092415 /home/build --bind /etc/resolv.conf /etc/resolv.conf --unshare-pid --die-with-parent --dev /dev --proc /proc --ro-bind /sys /sys --chdir /home/build --clearenv --new-session --setenv SOURCE_DATE_EPOCH 0 --setenv GOMODCACHE /var/cache/melange/gomodcache --setenv HOME /home/build --setenv GOPATH /home/build/.cache/go /bin/sh -c [ -x /sbin/ldconfig ] && /sbin/ldconfig /lib || true
2024/10/23 18:08:19 DEBU running the main pipeline
2024/10/23 18:08:19 INFO running step "cargo/build"
2024/10/23 18:08:19 DEBU executing: bwrap --bind /tmp/melange-guest-3950364476 / --bind /tmp/melange-workspace-3540092415 /home/build --bind /etc/resolv.conf /etc/resolv.conf --unshare-pid --die-with-parent --dev /dev --proc /proc --ro-bind /sys /sys --chdir /home/build --clearenv --new-session --setenv GOPATH /home/build/.cache/go --setenv SOURCE_DATE_EPOCH 0 --setenv GOMODCACHE /var/cache/melange/gomodcache --setenv HOME /home/build --setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /bin/sh -c set -e
[ -d '/home/build' ] || mkdir -p '/home/build'
cd '/home/build'
exit 0 uses=cargo/build
2024/10/23 18:08:19 DEBU executing: bwrap --bind /tmp/melange-guest-3950364476 / --bind /tmp/melange-workspace-3540092415 /home/build --bind /etc/resolv.conf /etc/resolv.conf --unshare-pid --die-with-parent --dev /dev --proc /proc --ro-bind /sys /sys --chdir /home/build --clearenv --new-session --setenv SOURCE_DATE_EPOCH 0 --setenv GOMODCACHE /var/cache/melange/gomodcache --setenv HOME /home/build --setenv GOPATH /home/build/.cache/go --setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /bin/sh -c set -e
[ -d '/home/build' ] || mkdir -p '/home/build'
cd '/home/build'
# Installation directory should always be bin as we are producing a binary
INSTALL_PATH="/home/build/melange-out/cargo-test/usr/bin"
OUTPUT_PATH="target/release"
# Enter target package directory
cd "."
# Build and install package(s)
cargo auditable build "--release"
if [[ ! -z "" ]]; then
install -Dm755 "${OUTPUT_PATH}/" "${INSTALL_PATH}/"
else
install -Dm755 "${OUTPUT_PATH}"/* -t "${INSTALL_PATH}"
fi
exit 0 uses=cargo/build
2024/10/23 18:08:19 WARN Compiling melange-test v0.1.0 (/home/build) uses=cargo/build
2024/10/23 18:08:19 WARN Finished `release` profile [optimized] target(s) in 0.21s uses=cargo/build
2024/10/23 18:08:19 WARN install: omitting directory 'target/release/build' uses=cargo/build
2024/10/23 18:08:19 WARN install: omitting directory 'target/release/deps' uses=cargo/build
2024/10/23 18:08:19 WARN install: omitting directory 'target/release/examples' uses=cargo/build
2024/10/23 18:08:19 WARN install: omitting directory 'target/release/incremental' uses=cargo/build
2024/10/23 18:08:19 INFO deleting guest dir /tmp/melange-guest-3571777626
2024/10/23 18:08:19 INFO deleting workspace dir /tmp/melange-workspace-3540092415
2024/10/23 18:08:19 INFO removing image path /tmp/melange-guest-3950364476
2024/10/23 18:08:19 ERRO failed to build package: unable to run package cargo-test pipeline: unable to run pipeline: unable to run pipeline: exit status 1
@ckoehler where is the source that you're trying to build, generally we checkout a project using git-checkout that we want to build. I don't see a git-checkout in your config, you can use maybe fetch too if you want to pull a tarball. You'll be able to find examples for fetch in wolfi repository. Let me know if you are able to make some more progress after this.
There's also a useful make debug/geckodriver
make target that'll put your in shell if the build fails and then you can inspect more. Something like you can ensure if you're in right directory or invoke cargo auditable build
directly.
It's the current directory, mapped into work
. The steps to reproduce this are in the issue above. The cargo build step succeeds, but the package generation fails.
Maybe there's also a workflow problem? I am usually packaging local apps in CI, so the source is available from a git checkout already, no need to fetch anything remotely. What's the best way to do that?
@ckoehler the honest answer for now is that I lack this context as of now. I've never tried building local packages, I can look into this tomorrow if it's possible but generally whole packages fetch the source code from internet and build it from source.
I'll look into this tomorrow if this is still an issue that's not solved.
Here's a self-contained yaml file that pulls and builds a project from git. The cargo build is successful, but the package generation isn't.
package:
name: probe
version: 0.1.0
description: probe
copyright:
- license: MIT
dependencies:
runtime:
environment:
contents:
keyring:
- https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
repositories:
- https://packages.wolfi.dev/os
packages:
pipeline:
- uses: git-checkout
with:
expected-commit: 5092046571b4791f68a47c29527a14d6d57aee3a
repository: https://github.com/ckoehler/probe.git
tag: v0.2.2
- uses: cargo/build
I built it with Docker and the dev-container method, including make debug/probe
, which puts me in a shell; there, cargo auditable build
succeeds as well (the warning can be ignored). It's something after the build step, in the package generation or something.
@ckoehler this should keep you moving.
package:
name: probe
version: 0.1.0
description: probe
copyright:
- license: MIT
environment:
contents:
packages:
- build-base
pipeline:
- uses: git-checkout
with:
expected-commit: 5092046571b4791f68a47c29527a14d6d57aee3a
repository: https://github.com/ckoehler/probe.git
tag: v0.2.2
- uses: cargo/build
with:
output: probe
Notes about why it was failing can be read in this PR notes: https://github.com/chainguard-dev/melange/pull/1596
I saw you've two binaries pub
and probe
but we will not be able to move with two binaries installation for now. Maybe there's a workaround.
But this is something where we plan to improve in the future as we plan to adopt cargo/build
more and more.
Thanks for being patient.
Ah interesting! The actual repo I have trouble with actually has no binaries, but a couple of libraries (rlib). Does the same thing apply to that case?
I guess it does, I didn't know the install
command would exit with 1 if it encounters directories. So that wildcard install never would've worked.
melange is giving an error even tho the build is successful.
Log
Reproduce
Create a new Rust project, the default works.
cargo new melange-test; cd melange-test
Create a melange file with this content:
Build:
melange build --arch amd64 test.yaml
Arch doesn't matter, just keeping the output shorter.aarch64
also fails.Version