Files
deepseek-harness/scripts/prepare-ci-bubblewrap.sh
T
Chinesezjc 68f83cc992 fix(ci): cache the verified bubblewrap archive and bound its download
Backport of #8325 to release/dsh-0.2.2.

(cherry picked from commit 907c47c8f251cae6ce844cf8c7145bbfd5dbe176)
2026-11-12 19:27:57 +08:00

41 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Ubuntu's package transaction scans the hosted image's full dpkg database and
# runs post-install hooks. CI needs only the signed-archive payload, so pin and
# verify that payload before extracting it into the ephemeral runner directory.
# This amd64 build needs glibc 2.38+ and Linux 5.10+; Ubuntu 24.04 satisfies both.
readonly BUBBLEWRAP_VERSION='0.12.0-1'
readonly BUBBLEWRAP_SHA256='db4d572a7927bfd34cc9b8e24b56983efa8e0483d03da6c810f6caae081dcc36'
# The recorded build remains addressable after Ubuntu prunes its live package pool.
readonly BUBBLEWRAP_URL="https://launchpad.net/ubuntu/+source/bubblewrap/${BUBBLEWRAP_VERSION}/+build/33546835/+files/bubblewrap_${BUBBLEWRAP_VERSION}_amd64.deb"
# Workflows that run on ephemeral runners restore and save this directory as
# `~/.cache/dsh-ci/bubblewrap` with actions/cache, so a warm cache needs no
# Launchpad request; the persistent self-hosted pool keeps the directory itself.
readonly BUBBLEWRAP_CACHE_DIR="${HOME}/.cache/dsh-ci/bubblewrap"
# shellcheck source=scripts/ci-verified-download.sh
source "$(dirname -- "${BASH_SOURCE[0]}")/ci-verified-download.sh"
: "${RUNNER_TEMP:?prepare-ci-bubblewrap requires RUNNER_TEMP}"
: "${GITHUB_PATH:?prepare-ci-bubblewrap requires GITHUB_PATH}"
if [[ "$(uname -s)" != 'Linux' || "$(uname -m)" != 'x86_64' ]]; then
echo 'prepare-ci-bubblewrap supports only Linux x86_64 hosted runners' >&2
exit 1
fi
archive="${BUBBLEWRAP_CACHE_DIR}/bubblewrap_${BUBBLEWRAP_VERSION}_amd64.deb"
root="${RUNNER_TEMP}/dsh-bubblewrap"
acquire_verified_archive "$BUBBLEWRAP_URL" "$BUBBLEWRAP_SHA256" "$archive"
mkdir -p "$root"
dpkg-deb --extract "$archive" "$root"
printf '%s\n' "$root/usr/bin" >> "$GITHUB_PATH"
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 \
|| echo 'apparmor userns knob absent — the functional probe decides'
"$root/usr/bin/bwrap" --version
"$root/usr/bin/bwrap" --ro-bind / / --dev /dev --unshare-pid --proc /proc --die-with-parent -- true
echo 'bubblewrap functional probe passed'