Verified Commit a8f8ee96 authored by Morten Linderud's avatar Morten Linderud 🏄
Browse files

cronjobs/ftpdir-cleanup: Support DEBUGPKGPOOL



This implementation is probably the easiest one and/or cheap. After
building a list of all packages in the repositories we filter the lists
into two separate working lists. One for normal packages and one for
debug packages.

The only issue is that we can encounter globs with no matching cleanup
lists, like when running ftpdir-cleanup after the debug package changes
has been introduced, but before deploying new repositories. We guard
against this by ensuring we have found debug packages, and normal
packages, before checking the working lists.

This introduces some duplicated code but should be fine. Rest of the
logic is mirrored between the two package pools.
Signed-off-by: Morten Linderud's avatarMorten Linderud <morten@linderud.pw>
parent b57a25ac
......@@ -32,7 +32,7 @@ done
[[ $CLEANUP_DRYRUN = true ]] && warning 'dry run mode is active'
for repo in "${PKGREPOS[@]}"; do
for repo in "${PKGREPOS[@]}" "${DEBUGREPOS[@]}"; do
for arch in "${ARCHES[@]}"; do
if [[ ! -f ${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT} ]]; then
continue
......@@ -66,11 +66,26 @@ for repo in "${PKGREPOS[@]}"; do
done
# get a list of all available packages in the package pool
HAS_POOL=0
for f in "$FTP_BASE/${PKGPOOL}"/*${PKGEXTS}; do
printf '%s\n' "${f##*/}"
done | sort > "${WORKDIR}/pool"
# create a list of packages in our db
cat "${WORKDIR}"/db-* 2>/dev/null | sort -u > "${WORKDIR}/db"
if [[ -s ${WORKDIR}/pool ]]; then
cat "${WORKDIR}"/db-!(*-debug-*) 2>/dev/null | sort -u > "${WORKDIR}/db"
fi
# seperate list for debug packages
HAS_DEBUGPOOL=0
for f in "$FTP_BASE/${DEBUGPKGPOOL}"/*${PKGEXTS}; do
printf '%s\n' "${f##*/}"
done | sort > "${WORKDIR}/debugpool"
# seperate list for packages in our debug db
if [[ -s ${WORKDIR}/debugpool ]]; then
cat "${WORKDIR}"/db-*-debug-* 2>/dev/null | sort -u > "${WORKDIR}/debug-db"
fi
old_pkgs=($(comm -23 "${WORKDIR}/pool" "${WORKDIR}/db"))
if (( ${#old_pkgs[@]} >= 1 )); then
......@@ -81,7 +96,17 @@ if (( ${#old_pkgs[@]} >= 1 )); then
done
fi
old_debug_pkgs=($(comm -23 "${WORKDIR}/debugpool" "${WORKDIR}/debug-db"))
if (( ${#old_debug_pkgs[@]} >= 1 )); then
msg "Removing old packages from debug package pool..."
for old_debug_pkg in "${old_debug_pkgs[@]}"; do
msg2 '%s' "${old_debug_pkg}"
clean_pkg "$FTP_BASE/${DEBUGPKGPOOL}/${old_debug_pkg}"
done
fi
unset old_pkgs
unset old_debug_pkgs
touch -d "${CLEANUP_KEEP} days ago" "${WORKDIR}/cleanup_timestamp"
for f in "${CLEANUP_DESTDIR}"/**/*${PKGEXTS}; do
if [[ ${WORKDIR}/cleanup_timestamp -nt $f ]]; then
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment