Fix symnlinking of releases

This commit is contained in:
Audiobuzz
2026-06-28 01:50:33 +00:00
parent 02ffd7d885
commit 5e4ee87e88
2 changed files with 31 additions and 13 deletions
+12 -10
View File
@@ -65,23 +65,25 @@ rpc nvmf_create_transport -t TCP -u 16384 -m 8 -c 8192 \
|| echo "WARNING: nvmf_create_transport failed (already present?)" >&2
echo "==> registering discovery listener ${TADDR}:${TPORT}"
rpc nvmf_subsystem_add_listener "$DISCOVERY_NQN" -t tcp -a "$TADDR" -s "$TPORT" 2>/dev/null || true
rpc nvmf_subsystem_add_listener "$DISCOVERY_NQN" -t tcp -a "$TADDR" -s "$TPORT" >/dev/null 2>&1 || true
# Bootstrap convenience: if a single OCI artifact image is mounted at /artifacts
# (the simple one-version `docker compose up` flow) and that version isn't yet
# staged under $RELEASES_DIR, stage it so the long-lived target serves it too.
# Symlinks resolve inside the container (both are container paths); fall back to
# a copy if linking fails.
#
# COPY, never symlink: /artifacts is a version-pinned image volume that CHANGES
# when IMAGE_VERSION changes, so a symlink into it would silently re-point an
# already-staged release dir at the new version's data on the next bump. Each
# release dir must hold its own immutable copy. Self-heal: re-copy if the staged
# verity.json differs from the mounted artifact (repairs a dir left stale/symlinked
# by an older build).
if [ -s /artifacts/verity.json ] && [ -n "${IMAGE_VERSION:-}" ]; then
seed="$RELEASES_DIR/$IMAGE_VERSION"
if [ ! -e "$seed/verity.json" ]; then
echo "==> seeding bootstrap release $IMAGE_VERSION from /artifacts"
if [ ! -s "$seed/verity.json" ] || ! cmp -s /artifacts/verity.json "$seed/verity.json"; then
echo "==> seeding bootstrap release $IMAGE_VERSION from /artifacts (copy)"
mkdir -p "$seed"
for f in rootfs.erofs rootfs.hash verity.json; do
ln -sf "/artifacts/$f" "$seed/$f" 2>/dev/null \
|| cp "/artifacts/$f" "$seed/$f" 2>/dev/null \
|| echo "WARNING: could not seed /artifacts/$f" >&2
done
cp -f /artifacts/rootfs.erofs /artifacts/rootfs.hash /artifacts/verity.json "$seed/" \
|| echo "WARNING: failed to seed $IMAGE_VERSION from /artifacts" >&2
fi
fi