Build musl and glibc for amd64 and arm64 through one native package path. Reuse musl outputs for OCI images and OpenWrt installers, and export binaries inside a rootless unshare session. Restore the executable dependency graph into a shared persistent NuGet cache, build managed dependencies once, and run isolated native publishes in parallel. Clean temporary outputs and expired image layers under store locks, retire inactive legacy stores after seven days, and retain two toolchain exports. Add regression coverage for staging, extraction, packaging and cleanup boundaries.
33 lines
1.6 KiB
Bash
33 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
|
# Package the same Agent and enrollment outputs for every Linux target.
|
|
set -euo pipefail
|
|
rid="${1:?usage: package-linux-agent.sh <rid> <binaries> <destination>}"
|
|
binaries="${2:?}"; destination="${3:?}"
|
|
case "$rid" in
|
|
linux-x64) suffix=amd64 ;;
|
|
linux-arm64) suffix=arm64 ;;
|
|
linux-musl-x64) suffix=musl-amd64 ;;
|
|
linux-musl-arm64) suffix=musl-arm64 ;;
|
|
*) echo "unsupported Linux RID: $rid" >&2; exit 2 ;;
|
|
esac
|
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
source "$root/ci/version.sh"
|
|
work="$(mktemp -d)"
|
|
trap 'rm -rf "$work"' EXIT
|
|
mkdir -p "$work/systemd" "$work/openwrt" "$destination"
|
|
install -m 0755 "$binaries/moshiro-agent" "$binaries/fleet-enroll" "$root/packaging/install.sh" "$work/"
|
|
for library in "$binaries"/lib*.so.*; do
|
|
[[ ! -f "$library" ]] || install -m 0644 "$library" "$work/"
|
|
done
|
|
install -m 0644 "$root/LICENSE" "$work/"
|
|
install -m 0644 "$root/backend/agent/README.md" "$work/README.md"
|
|
install -m 0644 "$root/packaging/systemd/moshiro-agent.service" "$work/systemd/"
|
|
install -m 0755 "$root/packaging/openwrt/moshiro-agent.init" "$work/openwrt/"
|
|
install -m 0644 "$root/packaging/openwrt/moshiro.keep" "$work/openwrt/"
|
|
archive="moshiro-agent-v$MOSHIRO_VERSION-linux-$suffix.tar.gz"
|
|
# Name the members explicitly so tar does not add a leading ./ directory.
|
|
mapfile -t members < <(find "$work" -mindepth 1 -maxdepth 1 -printf '%f\n' | LC_ALL=C sort)
|
|
tar --sort=name --mtime='UTC 2000-01-01' --owner=0 --group=0 --numeric-owner -czf "$destination/$archive" -C "$work" "${members[@]}"
|
|
(cd "$destination" && sha256sum "$archive" > "$archive.sha256")
|
|
echo "packaged $archive"
|