Debian 13 runtime with restic 0.18.1 pinned outside the OS; restic assumptions re-proven; felhom-samba 1.2.0 (R-1105, R-972)
gates / gates (push) Successful in 49s

This commit is contained in:
2026-10-16 20:33:57 +02:00
parent 29a3ce8cf2
commit fbcc3cf042
47 changed files with 706 additions and 48 deletions
+35
View File
@@ -18,6 +18,41 @@ ACTION="${2:-}"
REGISTRY="gitea.dooplex.hu/admin"
IMAGE="${REGISTRY}/felhom-samba"
CTX="$(cd "$(dirname "$0")/../infra-images/samba" && pwd)"
REPO_DIR="${FELHOM_REPO_DIR:-$(cd "$(dirname "$0")/../.." && pwd)}"
# A VERSION NUMBER IS PUSHED ONCE (R-972, felhom-samba 1.2.0) — the same two checks build.sh makes for the
# controller (v0.316.0/v0.316.4), because the box pulls an infra image by its tag and never again once it has it:
# a second image under one number is a box that runs either and never learns which. Before any build:
# 1. the tag must be ABSENT from the registry; a registry that cannot be asked is a refusal, not a pass;
# 2. the tree must be clean and at origin/main — an image from an unpushed tree cannot be rebuilt.
# Local builds (no --push) are untouched. Tested by scripts/test_samba_build_push_once.sh (a fake `docker`).
if [[ "${ACTION}" == "--push" ]]; then
probe_rc=0
probe_out=$(docker manifest inspect "${IMAGE}:${VERSION}" 2>&1) || probe_rc=$?
if [[ ${probe_rc} -eq 0 ]]; then
echo "[ERROR] ${IMAGE}:${VERSION} already exists in the registry — bump the version." >&2
exit 1
fi
if ! grep -qiE 'no such manifest|manifest unknown|not found|does not exist|NAME_UNKNOWN|MANIFEST_UNKNOWN' <<<"${probe_out}"; then
echo "[ERROR] Could not establish whether ${IMAGE}:${VERSION} exists — refusing to build. The registry answered: ${probe_out}" >&2
exit 1
fi
echo "[INFO] ${VERSION} is not present in the registry — proceeding."
if ! git -C "${REPO_DIR}" rev-parse --git-dir >/dev/null 2>&1; then
echo "[ERROR] ${REPO_DIR} is not a git checkout — refusing to push a build whose source cannot be identified." >&2
exit 1
fi
if [[ -n "$(git -C "${REPO_DIR}" status --porcelain 2>/dev/null)" ]]; then
echo "[ERROR] ${REPO_DIR} has uncommitted changes — refusing to push a build from it." >&2
exit 1
fi
if [[ "$(git -C "${REPO_DIR}" rev-parse HEAD)" != "$(git -C "${REPO_DIR}" rev-parse origin/main 2>/dev/null)" ]]; then
echo "[ERROR] ${REPO_DIR} is not at origin/main — refusing to push." >&2
exit 1
fi
echo "[INFO] Source tree is clean and at origin/main."
CTX="${REPO_DIR}/controller/infra-images/samba"
fi
echo "[INFO] building ${IMAGE}:${VERSION}"
echo "[INFO] context: ${CTX}"
+59
View File
@@ -0,0 +1,59 @@
#!/bin/bash
# A felhom-samba VERSION NUMBER IS PUSHED ONCE — the test for build-samba-image.sh's registry and tree checks
# (R-972, 1.2.0). Same method as test_build_push_once.sh: a fake `docker` first on PATH drives the REAL script;
# the fake answers `build`/`push` with a marker, so a run that got past a refusal is caught, and nothing is pushed.
# Run from controller/: bash scripts/test_samba_build_push_once.sh
set -u
HERE="$(cd "$(dirname "$0")" && pwd)"
SH="$HERE/build-samba-image.sh"
fails=0; ran=0
make_fake_docker() {
mkdir -p "$1"
cat > "$1/docker" <<'FAKE'
#!/bin/bash
case "$1 $2" in
"manifest inspect")
case "${FAKE_MODE}" in
present) echo '{"schemaVersion":2}'; exit 0 ;;
absent) echo "manifest unknown: manifest unknown" >&2; exit 1 ;;
down) echo "dial tcp: connection refused" >&2; exit 1 ;;
esac ;;
"build "*|"push "*) echo "FAKE-DOCKER-REACHED: $*"; exit 0 ;;
esac
exit 0
FAKE
chmod +x "$1/docker"
}
run() { # $1 mode, $2 repo dir ("" = default), rest = args
local mode="$1" repo="$2"; shift 2
local tmp; tmp="$(mktemp -d)"; make_fake_docker "$tmp/bin"
if [[ -n "$repo" ]]; then FAKE_MODE="$mode" FELHOM_REPO_DIR="$repo" PATH="$tmp/bin:$PATH" bash "$SH" "$@" >"$tmp/out" 2>&1
else FAKE_MODE="$mode" PATH="$tmp/bin:$PATH" bash "$SH" "$@" >"$tmp/out" 2>&1; fi
rc=$?; out="$(cat "$tmp/out")"; rm -rf "$tmp"
}
check() { # name, want_rc, want_text, forbid_text
ran=$((ran+1))
if [[ "$rc" != "$2" ]] || { [[ -n "$3" ]] && ! grep -qi -- "$3" <<<"$out"; } || { [[ -n "${4:-}" ]] && grep -qi -- "$4" <<<"$out"; }; then
fails=$((fails+1)); echo " FAIL $1 (exit $rc)"; echo "$out" | tail -4 | sed 's/^/ /'; return
fi
echo " ok $1"
}
scratch_repo() {
local d; d="$(mktemp -d)"; git -C "$d" init -q; git -C "$d" config user.email t@t; git -C "$d" config user.name t
mkdir -p "$d/controller/infra-images/samba"; echo x > "$d/controller/infra-images/samba/Dockerfile"
git -C "$d" add -A >/dev/null; git -C "$d" commit -qm one >/dev/null; git -C "$d" update-ref refs/remotes/origin/main HEAD; echo "$d"
}
echo "build-samba-image.sh — a version number is pushed once, from a clean tree"
R="$(scratch_repo)"
run present "$R" 9.9.9 --push; check "tag present -> refuses" 1 "already exists in the registry" "FAKE-DOCKER-REACHED"
run down "$R" 9.9.9 --push; check "registry unreachable -> refuses" 1 "Could not establish whether" "FAKE-DOCKER-REACHED"
run absent "$R" 9.9.9 --push; check "tag absent, clean tree -> builds and pushes" 0 "FAKE-DOCKER-REACHED: push" "refusing"
echo dirt > "$R/controller/infra-images/samba/extra"
run absent "$R" 9.9.9 --push; check "dirty tree -> refuses" 1 "uncommitted changes" "FAKE-DOCKER-REACHED"
rm -f "$R/controller/infra-images/samba/extra"; echo y > "$R/controller/f2"; git -C "$R" add -A >/dev/null; git -C "$R" commit -qm two >/dev/null
run absent "$R" 9.9.9 --push; check "ahead of origin/main -> refuses" 1 "not at origin/main" "FAKE-DOCKER-REACHED"
rm -rf "$R"
run present "" 9.9.9; check "local build, tag present -> not refused" 0 "FAKE-DOCKER-REACHED: build" "already exists"
echo
[[ $fails -eq 0 ]] && { echo "all $ran cases behaved"; exit 0; }
echo "$fails of $ran cases FAILED"; exit 1