#!/bin/bash # Koji cleanup script # This script cleans up old build roots and work directories on the Koji hub. set -euo pipefail # --- Configuration --- KOJI_TOP_DIR="{{ koji_top_dir }}" KOJI_ADMIN_USER="{{ koji_admin_user }}" ADMIN_USER_KOJI_DIR="{{ koji_hub_admin_user_koji_dir }}" # --- Main Script --- echo "$(date): Starting Koji cleanup..." # Clean up old build roots # koji-gc --cleanup-buildroots --debug # Clean up old work directories # find "$KOJI_TOP_DIR/work" -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \; # Example: Remove old scratch builds (older than 30 days) # koji --config="$ADMIN_USER_KOJI_DIR/config" list-builds --state=FAILED --state=CANCELED --state=DELETED --mine --after-completion="$(date -d '30 days ago' +%Y-%m-%d)" | awk '{print $1}' | xargs -r -L 1 koji --config="$ADMIN_USER_KOJI_DIR/config" remove-build --nowait echo "$(date): Koji cleanup finished."