Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 68 additions & 4 deletions docs/BUILD-FILE.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/BUILD-PROCESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This document describes the Melange build process.
The melange yaml file consists of the following components that are key to the build process. Note that this is not
the official or a comprehensive `melange.yaml` reference.

* `package.target-architectures`: describes which architectures to build for (if empty, build for all available archs).
* `package.target-architectures`: describes which architectures to build for (if empty, build for all available archs); `noarch` builds an architecture-independent package once using the host architecture.
* `package.dependences.runtime`: list of apk packages that need to be available in the final apk package, hence `runtime`.
* `environment.contents`: list of apk packages and their source repositories that need to be available during the build, but not in the final apk package.
* `pipeline`: list of steps to execute during the build.
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Melange options are based on yaml file name.
* `*-build.yaml`: run 'melange build'
* `*-test.yaml`: run 'melange test'
* `*-build-test`: run 'melange build && melange test'
* `*-multiarch-build`: run 'melange build' for `x86_64,aarch64` and assert the package and index are written to both arch directories

If the yaml file name matches '*-nopkg', then the flag `--test-package-append`
will be appended for `busybox` and `python-3`. The intent of these tests
Expand Down
53 changes: 53 additions & 0 deletions e2e-tests/noarch-build-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Verify noarch packages build once on host architecture, execute real melange
# tests, and contain only architecture-independent shell/text content.
package:
name: noarch-test
version: 1.0
epoch: 0
target-architecture:
- noarch
dependencies:
runtime:
- busybox

environment:
contents:
packages:
- busybox

pipeline:
- name: install noarch script
runs: |
bdir=${{targets.destdir}}/usr/bin
mkdir -p "$bdir"
cat > "$bdir/noarch-test" <<"EOF"
#!/bin/sh
echo "noarch works"
EOF
chmod 755 "$bdir/noarch-test"

test:
pipeline:
- name: test noarch script
runs: |
${{vars.tester-blob}}
testrun noarch-test "noarch works"

vars:
tester-blob: |
set +x
testfail() { echo "FAIL:" "$tname${1:+ - $*}" 1>&2; exit 1; }
testpass() { echo "PASS:" "$tname"; }
error() { echo "FATAL:" "$@" 1>&2; exit 1; }
testrun() {
local cmd="$1" expected="$2" tname="" out=""
[ -n "$cmd" ] || error "cmd must set cmd"

tname="'$cmd' is in PATH"
out=$(command -v "$cmd") && testpass || testfail

tname="'$cmd' outputs '$expected'"
out=$($cmd) || testfail "'$cmd' exited $?"
[ "$out" = "$expected" ] &&
testpass || testfail "found '$out'"
}
26 changes: 26 additions & 0 deletions e2e-tests/noarch-multiarch-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Verify one noarch build is copied and indexed for multiple requested arches.
package:
name: noarch-multiarch-test
version: 1.0
epoch: 0
target-architecture:
- noarch
dependencies:
runtime:
- busybox

environment:
contents:
packages:
- busybox

pipeline:
- name: install noarch script
runs: |
bdir=${{targets.destdir}}/usr/bin
mkdir -p "$bdir"
cat > "$bdir/noarch-multiarch-test" <<"EOF"
#!/bin/sh
echo "noarch multiarch works"
EOF
chmod 755 "$bdir/noarch-multiarch-test"
31 changes: 27 additions & 4 deletions e2e-tests/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ fails=""
for yaml in "$@"; do
args="${ARGS}"
ops=""
arch_flag="${ARCH}"
multiarch=""
base=${yaml%.yaml}
case "$base" in
*-build-test)
Expand All @@ -58,6 +60,11 @@ for yaml in "$@"; do
args="${base%-test}"
args="$args --debug"
;;
*-multiarch-build)
ops="build"
arch_flag="x86_64,aarch64"
multiarch="true"
;;
*-build)
ops="build"
;;
Expand All @@ -77,17 +84,33 @@ for yaml in "$@"; do
"test") opargs="--pipeline-dirs $PWD/pipelines";;
esac

vrc "Testing $base from $yaml for $op" \
if vrc "Testing $base from $yaml for $op" \
${MELANGE} "$op" \
--arch=${ARCH} --source-dir=./test-fixtures \
--arch=${arch_flag} --source-dir=./test-fixtures \
--runner=qemu \
"$yaml" \
${args} $opargs \
"--keyring-append=$PWD/$key.pub" \
"--repository-append=$PWD/packages" \
"--repository-append=https://packages.wolfi.dev/os" \
"--keyring-append=https://packages.wolfi.dev/os/wolfi-signing.rsa.pub" ||
fails="${fails} $yaml/$op"
"--keyring-append=https://packages.wolfi.dev/os/wolfi-signing.rsa.pub"; then
if [ -n "$multiarch" ]; then
for arch in x86_64 aarch64; do
apk="packages/$arch/noarch-multiarch-test-1.0-r0.apk"
index="packages/$arch/APKINDEX.tar.gz"
if [ ! -f "$apk" ]; then
echo "ERROR: missing noarch package $apk"
fails="${fails} $yaml/$op"
fi
if [ ! -f "$index" ]; then
echo "ERROR: missing package index $index"
fails="${fails} $yaml/$op"
fi
done
fi
else
fails="${fails} $yaml/$op"
fi
done
done

Expand Down
Loading