feat: implement automatic, atomic, and push-based repository synchronization
- Switched from systemd path monitoring to a custom wrapper script `mxos-trigger-dist-repo.sh` spawned by the Koji signing spooler. - Wrapper script runs Koji `dist-repo` synchronously and triggers the `mxos-repo-sync.sh` script to perform an atomic rsync of packages to the Caddy server. - Excluded reposerver from distro-sync to work around VM disk space constraints. - Configured Koji tag `mxos0` to cancel older pending/running `distRepo` tasks when a new one is triggered. - Verified successful repository generation, synchronization, and DNF resolution. Co-developed-by: Gemini AI <renich+gemini@woralelandia.com> Signed-off-by: Rénich Bon Ćirić <renich@woralelandia.com>
This commit is contained in:
parent
70060e9791
commit
38a0669db8
11 changed files with 191 additions and 54 deletions
37
roles/koji_hub/templates/mxos-repo-sync.sh.j2
Normal file
37
roles/koji_hub/templates/mxos-repo-sync.sh.j2
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/bash
|
||||
# SPDX-License-Identifier: MIT-0
|
||||
set -euo pipefail
|
||||
|
||||
SOURCE="/mnt/koji/repos-dist/mxos0/latest/"
|
||||
DEST_HOST="{{ groups['reposerver'][0] }}"
|
||||
DEST_DIR="/srv/www/repo/BaseOS"
|
||||
|
||||
if [[ ! -d "$SOURCE" ]]; then
|
||||
echo "Source directory $SOURCE does not exist. Skipping sync." >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Starting atomic synchronization of mxos0 repository to $DEST_HOST..."
|
||||
|
||||
# Pre-create directory structure on the destination
|
||||
/usr/bin/ssh -o StrictHostKeyChecking=no "root@${DEST_HOST}" "mkdir -p ${DEST_DIR}/x86_64/os ${DEST_DIR}/x86_64/debug/tree ${DEST_DIR}/source/tree"
|
||||
|
||||
# Sync x86_64 to BaseOS/x86_64/os
|
||||
if [[ -d "${SOURCE}x86_64" ]]; then
|
||||
echo "Syncing x86_64 architecture..."
|
||||
/usr/bin/rsync -a -L --delete --delay-updates "${SOURCE}x86_64/" "root@${DEST_HOST}:${DEST_DIR}/x86_64/os/"
|
||||
fi
|
||||
|
||||
# Sync x86_64-debuginfo to BaseOS/x86_64/debug/tree
|
||||
if [[ -d "${SOURCE}x86_64-debuginfo" ]]; then
|
||||
echo "Syncing x86_64 debuginfo..."
|
||||
/usr/bin/rsync -a -L --delete --delay-updates "${SOURCE}x86_64-debuginfo/" "root@${DEST_HOST}:${DEST_DIR}/x86_64/debug/tree/"
|
||||
fi
|
||||
|
||||
# Sync src to BaseOS/source/tree
|
||||
if [[ -d "${SOURCE}src" ]]; then
|
||||
echo "Syncing source RPMs..."
|
||||
/usr/bin/rsync -a -L --delete --delay-updates "${SOURCE}src/" "root@${DEST_HOST}:${DEST_DIR}/source/tree/"
|
||||
fi
|
||||
|
||||
echo "Synchronization completed successfully."
|
||||
22
roles/koji_hub/templates/mxos-trigger-dist-repo.sh.j2
Normal file
22
roles/koji_hub/templates/mxos-trigger-dist-repo.sh.j2
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/bash
|
||||
# SPDX-License-Identifier: MIT-0
|
||||
set -euo pipefail
|
||||
|
||||
TAG="{{ koji_build_tag }}"
|
||||
KEY_ID="$1"
|
||||
LOG_FILE="/var/log/mxos-dist-repo-trigger.log"
|
||||
|
||||
# Log all output to log file
|
||||
exec > >(tee -a "$LOG_FILE") 2>&1
|
||||
|
||||
echo "[$(date -Iseconds)] Triggering dist-repo for tag $TAG with key $KEY_ID..."
|
||||
|
||||
# Run dist-repo task in Koji and wait for it to complete
|
||||
if /usr/bin/sudo -u kojiadmin /usr/bin/koji dist-repo "$TAG" "$KEY_ID" \
|
||||
--with-src --split-debuginfo --write-signed-rpms --allow-missing-signatures --wait; then
|
||||
echo "[$(date -Iseconds)] dist-repo completed successfully. Invoking repository synchronization..."
|
||||
/usr/local/bin/mxos-repo-sync.sh
|
||||
else
|
||||
echo "[$(date -Iseconds)] dist-repo task failed. Skipping repository synchronization." >&2
|
||||
exit 1
|
||||
fi
|
||||
Loading…
Reference in a new issue