fix(bootstrap): fail fast when pkg cache is cold (Sam & Codex) #104

Merged
clawdie merged 1 commit from fix/jail-bootstrap-cache-preflight into main 2026-06-20 08:49:18 +02:00

View file

@ -10,6 +10,7 @@
set -eu
JAIL_NAME="${1:-}"
PKG_CACHE_DIR="${PKG_CACHE_DIR:-/var/cache/pkg}"
# The jail name becomes a path component, so reject anything that could escape
# /usr/local/bastille/jails/<name>/root (empty, traversal, odd characters).
@ -45,6 +46,12 @@ for p in ${PKGS}; do
echo " (versions are pinned to the host; the cache has nothing to serve otherwise)" >&2
exit 1
fi
if ! ls "${PKG_CACHE_DIR}/${p}-${ver}"*.pkg >/dev/null 2>&1; then
echo "error: host pkg cache is missing ${p}-${ver}" >&2
echo " prime it first: pkg fetch -y ${p}-${ver}" >&2
echo " (offline/exact-version bootstrap depends on ${PKG_CACHE_DIR})" >&2
exit 1
fi
echo " ${p}-${ver}"
pkg -c "${JAIL_ROOT}" install -y "${p}-${ver}"
done