strawberry/packaging/ci/build-release.sh
trvon 1470894c7f
ci: local compiler matrix (trixie/noble/forky x gcc/clang)
make docker-compiler-matrix builds and tests the working tree in throwaway
containers per distro and compiler, ninja -k 0 so every compile error shows.
Minutes per leg locally vs ~3 h for a ci/** run. The apt list moves to
packaging/ci/build-deps.txt, read by build-release.sh and Dockerfile.matrix.
noble's clang leg uses clang-19 + llvm-19: clang 18 cannot use libstdc++ 13's
std::expected.
2026-11-20 10:32:11 -07:00

87 lines
3.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# Build, test and pack a Linux install tree for one distro. CI containers only:
# it installs build packages with apt.
#
# packaging/ci/build-release.sh <trixie|noble|forky> [outdir]
#
# Output: <outdir>/strawberry-<version>-<os>-<arch>.tgz and a .sha256 next to it.
# The tarball holds what scripts/install.sh reads from a source tree:
# builddir/src/strawberry, builddir/src/process_monitor.bpf.o, scripts/, config/, packaging/.
# packaging/ includes rules-snapshot/ (pinned default YARA feed, installed by install.sh).
set -euo pipefail
os=${1:?usage: build-release.sh <trixie|noble|forky> [outdir]}
out=${2:-dist}
jobs=${JOBS:-2}
case "$os" in
trixie) want_id=debian want_codename=trixie ;;
noble) want_id=ubuntu want_codename=noble ;;
forky) want_id=debian want_codename=forky ;;
*) echo "unsupported os: $os" >&2; exit 2 ;;
esac
if [ "${CI:-}" != "true" ]; then
echo "refusing to run outside CI (it installs packages); set CI=true in a throwaway container" >&2
exit 2
fi
. /etc/os-release
if [ "$ID" != "$want_id" ] || [ "${VERSION_CODENAME:-}" != "$want_codename" ]; then
echo "container is $ID ${VERSION_CODENAME:-?}, expected $want_id $want_codename" >&2
exit 2
fi
export DEBIAN_FRONTEND=noninteractive
apt-get update -q
# packaging/ci/build-deps.txt: the Dockerfile base stage set minus Qt (the tray app is not shipped to servers);
# scripts/compiler_matrix.sh builds from the same list.
grep -vE '^[[:space:]]*(#|$)' packaging/ci/build-deps.txt | xargs apt-get install -y -q --no-install-recommends
# Version contract: a tag build publishes only when meson.build, the tag and the built binary agree.
# scripts/release.sh bumps meson.build in the release commit; CI never rewrites the version.
src_version=$(sed -n "s/^ version: '\(.*\)',$/\1/p" meson.build | head -1)
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
tag_version=${GITHUB_REF_NAME#v}
if [ "$src_version" != "$tag_version" ]; then
echo "meson.build version $src_version does not match tag $GITHUB_REF_NAME; cut releases with scripts/release.sh" >&2
exit 1
fi
fi
export CC=gcc CXX=g++
rm -rf builddir
meson setup builddir -Denable_app=disabled -Denable_tests=true
nice -n 19 ninja -C builddir -j"$jobs"
nice -n 19 meson test -C builddir --print-errorlogs --num-processes "$jobs"
for f in builddir/src/strawberry builddir/src/process_monitor.bpf.o; do
test -s "$f" || { echo "missing build output: $f" >&2; exit 1; }
done
built_version=$(builddir/src/strawberry version | awk '{print $2}')
if [ "$built_version" != "$src_version" ]; then
echo "built binary reports $built_version, meson.build says $src_version" >&2
exit 1
fi
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
version=$tag_version
else
version="${src_version}+g$(git rev-parse --short=12 HEAD)"
fi
arch=$(dpkg --print-architecture)
name="strawberry-${version}-${os}-${arch}.tgz"
# The pinned rule snapshot packed below must match its reviewed manifest.
if [ -f packaging/rules-snapshot/SNAPSHOT ]; then
(cd packaging/rules-snapshot && sha256sum -c MANIFEST.sha256 --quiet)
fi
mkdir -p "$out"
epoch=$(git log -1 --format=%ct)
# Reproducible-ish archive: fixed order, owner and mtime; gzip without a timestamp.
tar --sort=name --owner=0 --group=0 --numeric-owner --mtime="@${epoch}" -cf - \
scripts config packaging builddir/src/strawberry builddir/src/process_monitor.bpf.o \
| gzip -n -9 > "$out/$name"
(cd "$out" && sha256sum "$name" > "$name.sha256")
echo "built $out/$name"
cat "$out/$name.sha256"