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.
83 lines
3.0 KiB
Bash
83 lines
3.0 KiB
Bash
#!/usr/bin/env bash
|
|
# Prepare the glibc MsQuic sidecars for Agent packages and in-process tests.
|
|
# Debian packages are extracted locally (no root install); downloads live in
|
|
# the persistent backend test cache so fast and slow workflows reuse them.
|
|
set -euo pipefail
|
|
|
|
cache="${1:?usage: fetch-quic-test-runtime.sh <cache-directory>}"
|
|
runtime="$cache/runtime"
|
|
downloads="$cache/downloads"
|
|
mkdir -p "$runtime" "$downloads"
|
|
|
|
if [[ -z "${2:-}" ]] && command -v apk >/dev/null 2>&1; then
|
|
# The Alpine test image installs runtime libraries into the normal loader path.
|
|
apk add --no-cache libmsquic numactl lttng-ust zlib >/dev/null
|
|
exit 0
|
|
fi
|
|
|
|
case "${2:-$(uname -m)}" in
|
|
x86_64|amd64) deb_arch=amd64 ;;
|
|
aarch64|arm64) deb_arch=arm64 ;;
|
|
*) echo "unsupported architecture for QUIC runtime: ${2:-$(uname -m)}" >&2; exit 2 ;;
|
|
esac
|
|
|
|
download() {
|
|
local url="$1" destination="$2"
|
|
if [[ ! -s "$destination" ]]; then
|
|
curl --fail --silent --show-error --retry 3 "$url" -o "$destination"
|
|
fi
|
|
}
|
|
|
|
extract_library_sonames() {
|
|
local package="$1" unpack="$2" data entry normalized name soname
|
|
mkdir -p "$unpack"
|
|
if [[ ! -f "$unpack/.extracted" ]]; then
|
|
(cd "$unpack" && ar x "$package")
|
|
data="$(find "$unpack" -maxdepth 1 -type f -name 'data.tar.*' -print -quit)"
|
|
[[ -n "$data" ]] || { echo "package has no data archive: $package" >&2; exit 1; }
|
|
while IFS= read -r entry; do
|
|
normalized="${entry#./}"
|
|
case "$normalized" in
|
|
usr/lib/*|lib/*) ;;
|
|
*) continue ;;
|
|
esac
|
|
name="${normalized##*/}"
|
|
[[ "$name" =~ \.so\.[0-9]+(\.[0-9]+)+$ ]] || continue
|
|
[[ "$name" =~ ^libmsquic\.lttng\.so\. ]] && continue
|
|
soname="$(sed -E 's/^(.+\.so\.[0-9]+).*/\1/' <<<"$name")"
|
|
tar -xf "$data" -C "$unpack" "$entry"
|
|
install -m 0644 "$unpack/$normalized" "$runtime/$soname"
|
|
done < <(tar -tf "$data")
|
|
touch "$unpack/.extracted"
|
|
fi
|
|
}
|
|
|
|
package_cache="$downloads/packages"
|
|
unpack_cache="$downloads/unpacked"
|
|
mkdir -p "$package_cache" "$unpack_cache"
|
|
|
|
msquic_index='https://packages.microsoft.com/debian/12/prod/pool/main/libm/libmsquic/'
|
|
msquic_file="$(curl --fail --silent --show-error --retry 3 "$msquic_index" \
|
|
| grep -oE "libmsquic_[0-9]+(\.[0-9]+){1,3}_${deb_arch}\.deb" \
|
|
| sort -Vu | tail -n 1)"
|
|
[[ -n "$msquic_file" ]] || { echo "could not find a stable MsQuic package for $deb_arch" >&2; exit 1; }
|
|
|
|
packages=(
|
|
"$msquic_index$msquic_file"
|
|
"https://deb.debian.org/debian/pool/main/n/numactl/libnuma1_2.0.16-1_${deb_arch}.deb"
|
|
"https://deb.debian.org/debian/pool/main/libz/libzstd/libzstd1_1.5.4+dfsg2-5_${deb_arch}.deb"
|
|
"https://deb.debian.org/debian/pool/main/z/zlib/zlib1g_1.2.13.dfsg-1_${deb_arch}.deb"
|
|
)
|
|
|
|
for url in "${packages[@]}"; do
|
|
file="${url##*/}"
|
|
package="$package_cache/$file"
|
|
download "$url" "$package"
|
|
extract_library_sonames "$package" "$unpack_cache/${file%.deb}"
|
|
done
|
|
|
|
for library in libmsquic.so.2 libnuma.so.1 libz.so.1 libzstd.so.1; do
|
|
[[ -f "$runtime/$library" ]] || { echo "missing QUIC test library: $library" >&2; exit 1; }
|
|
done
|
|
echo "prepared MsQuic test runtime ($deb_arch) in $runtime"
|