From 1e13a032ac0bef748150c60f3b670e57dad2aee5 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sun, 2 May 2010 08:52:59 -0700 Subject: ftpdir-cleanup: Add clean_pkgs function This should remove files if they are symlinks (pooled packages) and move them to the cleanup dir if not --- misc-scripts/ftpdir-cleanup | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/misc-scripts/ftpdir-cleanup b/misc-scripts/ftpdir-cleanup index 97f46b2..c9a232d 100755 --- a/misc-scripts/ftpdir-cleanup +++ b/misc-scripts/ftpdir-cleanup @@ -20,6 +20,16 @@ cleanup() { exit 1 } +clean_pkgs () { + for pkg in "$@"; do + if [ -h "$pkg" ]; then + rm -f "$pkg" + else + mv "$pkg" "$CLEANUP_DESTDIR" + fi + done +} + trap cleanup 2 trap cleanup 15 @@ -155,17 +165,17 @@ for arch in ${ARCHES[@]}; do fi if [ -n "${DELETEFILES}" ]; then - ${CLEANUP_DRYRUN} || rm -f ${DELETEFILES} + ${CLEANUP_DRYRUN} || clean_pkgs ${DELETEFILES} echo "" fi if [ -n "${DELETESYMLINKS}" ]; then - ${CLEANUP_DRYRUN} || rm -f ${DELETESYMLINKS} + ${CLEANUP_DRYRUN} || clean_pkgs ${DELETESYMLINKS} echo "" fi if [ -n "${EXTRAFILES}" ]; then - ${CLEANUP_DRYRUN} || rm -f ${EXTRAFILES} + ${CLEANUP_DRYRUN} || clean_pkgs ${EXTRAFILES} echo "" fi @@ -202,6 +212,6 @@ fi if [ -d "$ftppath_base/any" -a -n "${ARCHINDEPFILES}" ]; then cd "$ftppath_base/any" - ${CLEANUP_DRYRUN} || rm -f ${ARCHINDEPFILES} + ${CLEANUP_DRYRUN} || clean_pkgs ${ARCHINDEPFILES} echo "" fi -- cgit v1.2.3-24-g4f1b