2021-10-20 19:25:37 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
function log() {
|
2024-04-28 14:19:17 +00:00
|
|
|
echo "[$(date +%H:%M:%S)] $@" >&2
|
2021-10-20 19:25:37 +00:00
|
|
|
}
|
|
|
|
|
2024-04-28 14:19:17 +00:00
|
|
|
add_opts=()
|
|
|
|
[[ -z ${REPOKEY:-} ]] || add_opts+=(-s --key ${REPOKEY})
|
|
|
|
|
2021-10-20 19:25:37 +00:00
|
|
|
syncdir="${REPO_DIR:-$(pwd)}"
|
|
|
|
|
|
|
|
log "Cleaning up old package versions..."
|
|
|
|
BASE_PATH="${syncdir}" python scripts/remove_old_versions.py
|
|
|
|
|
|
|
|
log "Adding remaining packages to database..."
|
|
|
|
packages=($(find "${syncdir}" -regextype egrep -regex '^.*\.pkg\.tar(\.xz|\.zst)$' | sort))
|
|
|
|
|
|
|
|
if [ "${#packages[@]}" -eq 0 ]; then
|
2024-04-28 14:19:17 +00:00
|
|
|
log "No packages found to add to repo, this looks like an error!"
|
|
|
|
exit 1
|
2021-10-20 19:25:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
log "Adding packages..."
|
2024-04-28 14:19:17 +00:00
|
|
|
repo-add ${add_opts[@]} --new --prevent-downgrade "${DATABASE}" "${packages[@]}"
|
2021-10-20 19:25:37 +00:00
|
|
|
|
|
|
|
log "All packages added, removing *.old copies..."
|
|
|
|
find "${syncdir}" -name '*.old' -delete
|