summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2011-11-23 13:19:35 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2011-11-23 13:19:35 -0300
commit51e733fdb525e1c1e9392aa4c3a0b882a6433ad4 (patch)
treeb7cf9c75bbfc86b6fde2e7eddcacc3d1117f7ba1
parent9ef417865ef8b102875d42d4cb8ebe277de4ec01 (diff)
Cleanup script + New config vars
-rw-r--r--config6
-rwxr-xr-xdb-cleanup63
-rwxr-xr-xdb-sync4
3 files changed, 71 insertions, 2 deletions
diff --git a/config b/config
index e0d474c..47c9c66 100644
--- a/config
+++ b/config
@@ -15,6 +15,12 @@ PKGREPOS=(${ARCHREPOS[@]} ${OURREPOS[@]} ${USERREPOS[@]} ${PROJREPOS[@]})
PKGPOOL='pool/packages'
SRCPOOL='sources/packages'
+# Directories where packages are shared between repos
+# *relative to FTP_BASE*
+PKGPOOLS=('pool/packages' 'pool/community' 'extra/os/any' 'community/os/any')
+# Directories where sources are stored
+SRCPOOLS=('sources/packages' 'sources/community')
+
CLEANUP_DESTDIR="$FTP_BASE/old/packages"
CLEANUP_DRYRUN=true
# Time in days to keep moved packages
diff --git a/db-cleanup b/db-cleanup
new file mode 100755
index 0000000..0c093c2
--- /dev/null
+++ b/db-cleanup
@@ -0,0 +1,63 @@
+#!/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 $0)/config
+source $(dirname $0)/local_config
+source $(dirname $0)/libremessages
+
+# 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
+
+(( CLEANUP_DRYRUN )) && EXTRAFLAGS+=" --dry-run"
+
+for _repo in ${ARCHREPOS[@]}; do
+ for _arch in ${ARCHARCHES[@]}; do
+ msg "Getting ${_repo}-${_arch} database"
+
+ 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|$|*|" >> /tmp/$0.$PID.filter
+
+ done
+done
+
+msg "Removing old files:"
+
+for POOL in ${PKGPOOLS[@]} ${SRCPOOLS[@]}; do
+ msg2 "${POOL}"
+
+ rsync ${EXTRAFLAGS} -va --delete-excluded \
+ --include-from="${dbfile}" \
+ --exclude="*" \
+ ${FTP_BASE}/${POOL}/ \
+ ${FTP_BASE}/${POOL}/
+done
+
+exit $?
diff --git a/db-sync b/db-sync
index 320a71d..bcdf41a 100755
--- a/db-sync
+++ b/db-sync
@@ -122,7 +122,7 @@ init() {
# Sync
# *Don't delete-after*, this is the job of cleanup scripts. It will remove our
# packages too
- for PKGPOOL in pool/packages pool/community extra/os/any community/os/any; do
+ for PKGPOOL in ${PKGPOOLS[@]}; do
rsync -vrtlH \
--delay-updates \
--safe-links \
@@ -140,7 +140,7 @@ init() {
# Sync
# *Don't delete-after*, this is the job of cleanup scripts. It will remove our
# packages too
- for SRCPOOL in sources/packages sources/community ; do
+ for SRCPOOL in ${SRCPOOLS[@]}; do
rsync -vrtlH \
--delay-updates \
--safe-links \