1
0
Fork 0
mirror of https://github.com/Luzifer/archrepo.git synced 2024-11-12 19:32:43 +00:00
archrepo/scripts/do_cleanup.sh
Knut Ahlers 7c2a1c3578
Move repo to subdir, remove repoctl dependency
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2021-10-20 21:25:37 +02:00

29 lines
856 B
Bash

#!/bin/bash
set -euo pipefail
function log() {
echo "[$(date +%H:%M:%S)] $@" >&2
}
syncdir="${REPO_DIR:-$(pwd)}"
log "Cleaning up old package versions..."
BASE_PATH="${syncdir}" python scripts/remove_old_versions.py
# Ensure removal of previous repo files
log "Cleaning up old database files..."
find "${syncdir}" -regextype egrep -regex '^.*\.(db|files)(|\.tar|\.tar\.xz|\.tar\.zst)$' -delete
log "Adding remaining packages to database..."
packages=($(find "${syncdir}" -regextype egrep -regex '^.*\.pkg\.tar(\.xz|\.zst)$' | sort))
if [ "${#packages[@]}" -eq 0 ]; then
log "No packages found to add to repo, this looks like an error!"
exit 1
fi
log "Adding packages..."
repo-add --new --prevent-downgrade "${syncdir}/luzifer.db.tar.xz" "${packages[@]}"
log "All packages added, removing *.old copies..."
find "${syncdir}" -name '*.old' -delete