Read the repository URL before the profile branches

Purpose builds skip the Core-tree block, so a mirror assignment placed there
left `mirror` unset when the live ISO profile was written. Read and validate it
once at the top of the container script.
This commit is contained in:
Archipelago 2026-11-13 18:18:57 +03:00
parent ee0232615b
commit 6fb235f6a0

View file

@ -120,6 +120,17 @@ cat > "$work/build-in-container.sh" <<'BUILD'
set -euxo pipefail
export LC_ALL=C
export ARCHIPELAGO_BUILD_PROFILE=$(cat /job/build-profile)
# The image keeps the repository it was composed from: either the public rolling
# mirror or the immutable snapshot bound to this build. An internal build
# transport must never leak in, and a snapshot build must not silently fall back
# to the rolling mirror - that is what broke updates on deployed hosts when the
# mirror pruned a pinned package. Purpose builds skip the Core-tree block below,
# so the value is read once here for every profile.
mirror=$(cat /job/mirror.txt)
case $mirror in
'https://mirror.nw-sys.ru/archlinux'*|'https://mirror.nw-sys.ru/archipelago/arch-repo-snapshot/'*) ;;
*) echo "Installed-system repository must be mirror.nw-sys.ru, got: $mirror" >&2; exit 1 ;;
esac
if [[ ! -f /etc/pacman.d/gnupg/trustdb.gpg ]]; then
pacman-key --init
pacman-key --populate archlinux
@ -251,16 +262,6 @@ for database in passwd shadow group gshadow; do
done
rm -rf /job/core/etc/pacman.d/gnupg
rm -f /job/core/etc/ssh/ssh_host_* /job/core/etc/.pwd.lock
# The installed system keeps the repository it was composed from: either the
# public rolling mirror or the immutable snapshot bound to this build. An
# internal build transport must never leak into the image, and a snapshot build
# must not silently fall back to the rolling mirror - that is what broke updates
# on already deployed hosts when the mirror pruned a pinned package.
mirror=$(cat /job/mirror.txt)
case $mirror in
'https://mirror.nw-sys.ru/archlinux'*|'https://mirror.nw-sys.ru/archipelago/arch-repo-snapshot/'*) ;;
*) echo "Installed-system repository must be mirror.nw-sys.ru, got: $mirror" >&2; exit 1 ;;
esac
printf 'Server = %s\n' "$mirror" > /job/core/etc/pacman.d/mirrorlist
mv /job/core/etc /job/core/usr/etc
rm -rf /job/core/var /job/core/home /job/core/root /job/core/srv /job/core/opt /job/core/mnt /job/core/usr/local /job/core/boot/*