diff options
Diffstat (limited to 'cron-jobs')
-rwxr-xr-x | cron-jobs/check_archlinux/check_packages.py | 2 | ||||
-rwxr-xr-x | cron-jobs/db-cleanup | 70 | ||||
-rw-r--r-- | cron-jobs/db-cleanup.conf | 11 |
3 files changed, 82 insertions, 1 deletions
diff --git a/cron-jobs/check_archlinux/check_packages.py b/cron-jobs/check_archlinux/check_packages.py index ac0194f..d233bf6 100755 --- a/cron-jobs/check_archlinux/check_packages.py +++ b/cron-jobs/check_archlinux/check_packages.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python2 # # check_archlinux.py # diff --git a/cron-jobs/db-cleanup b/cron-jobs/db-cleanup new file mode 100755 index 0000000..12d3615 --- /dev/null +++ b/cron-jobs/db-cleanup @@ -0,0 +1,70 @@ +#!/bin/bash +# Syncs pools against themselves using database contents as filter to cleanup +# them up +# License: GPLv3 + +# Principles +# * Get repos dbs contents +# * Make them a include list +# * Rsync pools against themselves removing excluded files +# * Instant cleanup! + +trap_exit() { + echo + error "$@" + exit 1 +} + +source "$(dirname $(dirname "$(readlink -e "$0")"))/config" +source "$(dirname "$(readlink -e "$0")")/db-cleanup.conf" +source "$(librelib messages)" + +# From makepkg +set -E + +trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT +trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT +trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR + +EXTRAFLAGS=() +"${CLEANUP_DRYRUN}" && EXTRAFLAGS+=(--dry-run) + +filter=$(mktemp -t "${0##*/}.XXXXXXXXXX") +trap "rm -f -- $(printf %q "$filter")" EXIT + +for _repo in "${PKGREPOS[@]}"; do + for _arch in "${ARCHES[@]}"; do + msg "Getting %s-%s database" "${_repo}" "${_arch}" + + dbfile="${FTP_BASE}/${_repo}/os/${_arch}/${_repo}${DBEXT}" + + if [ ! -r "${dbfile}" ]; then + warning "Not found" + continue + fi + + # Echo the contents into a filter file + bsdtar tf "${dbfile}" | \ + cut -d'/' -f1 | \ + sort -u | \ + sed "s|$|*|" >> "$filter" + + done +done + +msg "Removing old files:" + +for POOL in "${PKGPOOLS[@]}" "${SRCPOOLS[@]}"; do + msg2 '%s' "${POOL}" + + rsync "${EXTRAFLAGS[@]}" -va --delete-excluded \ + --include-from="$filter" \ + --exclude="*" \ + "${FTP_BASE}/${POOL}/" \ + "${FTP_BASE}/${POOL}/" +done + +msg "Removing dead symlinks:" +actions=(-print) +"${CLEANUP_DRYRUN}" || actions+=(-delete) +find -L "${FTP_BASE}/" -type l "${actions[@]}" diff --git a/cron-jobs/db-cleanup.conf b/cron-jobs/db-cleanup.conf new file mode 100644 index 0000000..7c2344c --- /dev/null +++ b/cron-jobs/db-cleanup.conf @@ -0,0 +1,11 @@ +# Directories where packages are shared between repos +# *relative to FTP_BASE* +PKGPOOLS=(pool/parabola_gnu+linux # Parabola GNU/Linux-libre + pool/arch_gnu+linux_arm # Arch Linux ARM + pool/{packages,community} # Arch Linux + ) +# Directories where sources are stored +SRCPOOLS=(src/parabola_gnu+linux # Parabola GNU/Linux-libre + src/arch_gnu+linux_arm # Arch Linux ARM + sources/{packages,community} # Arch Linux + ) |