Corrige la bascule du catalogue, detecte un changement de depot, compte les packs a l'import
build / Images Harbor (catalog-sync, Dockerfile.catalog-sync) (push) Successful in 9m45s
build / Garde-fou (push) Successful in 10m18s
build / Images Harbor (web, Dockerfile) (push) Successful in 13m10s

This commit is contained in:
hcornet committed 2026-09-11 12:16:57 +02:00
1 parent 469305b4a7
commit c411f2933d
5 files changed
+116 -5

No files matched your search

+20 -4
View File
@@ -19,7 +19,8 @@ if [ -z "${CATALOG_REPO:-}" ]; then
while true; do sleep 3600; done
fi
TRAVAIL=/tmp/depot
# Emplacement du clone de travail, surchargeable pour les tests.
TRAVAIL=${CATALOG_TRAVAIL:-/tmp/depot}
TEMOIN=/tmp/derniere-revision-confirmee
# Previent l'application, et retient si elle a repondu. Tant que la reponse
@@ -39,6 +40,13 @@ prevenir_application() {
}
sync_une_fois() {
# Un clone existant dont l'origine a change tirerait indefiniment depuis
# l'ancien depot : on le refait plutot que de le mettre a jour.
if [ -d "$TRAVAIL/.git" ]; then
ORIGINE=$(git -C "$TRAVAIL" remote get-url origin 2>/dev/null || echo "")
[ "$ORIGINE" = "$CATALOG_REPO" ] || rm -rf "$TRAVAIL"
fi
if [ -d "$TRAVAIL/.git" ]; then
git -C "$TRAVAIL" fetch --quiet --depth 1 origin "$CATALOG_BRANCH" || return 1
git -C "$TRAVAIL" reset --quiet --hard "origin/$CATALOG_BRANCH" || return 1
@@ -66,9 +74,17 @@ sync_une_fois() {
cp -a "$SOURCE"/. "$CIBLE.partiel"/ || return 1
mv "$CIBLE.partiel" "$CIBLE" || return 1
# Bascule atomique du lien, puis menage des anciennes revisions.
ln -sfn "$CIBLE" "$CATALOG_DEST/actuel.neuf"
mv -f "$CATALOG_DEST/actuel.neuf" "$CATALOG_DEST/actuel" || return 1
# Bascule du lien. Surtout pas "mv vers actuel" : quand actuel est un lien
# vers un repertoire, mv le suit et depose le fichier a l'interieur au lieu
# de remplacer le lien. ln -sfn remplace le lien lui-meme, sans le suivre.
ln -sfn "$CIBLE" "$CATALOG_DEST/actuel" || return 1
rm -rf "$CATALOG_DEST"/rev-*/actuel.neuf "$CATALOG_DEST/actuel.neuf"
# Verification : sans elle, une bascule ratee passerait pour un succes.
if [ "$(readlink "$CATALOG_DEST/actuel")" != "$CIBLE" ]; then
echo "catalog-sync : la bascule du lien a echoue" >&2
return 1
fi
ls -1dt "$CATALOG_DEST"/rev-* 2>/dev/null | tail -n +$((REVISIONS_CONSERVEES + 1)) | while read -r vieux; do
rm -rf "$vieux"