summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Griffin <aaronmgriffin@gmail.com>2010-02-16 00:44:46 +0100
committerAaron Griffin <aaronmgriffin@gmail.com>2010-04-28 18:51:34 +0200
commite284d06d6cf63665cbadcb65e3a09bbd18027bd1 (patch)
tree19b18ccb8963b450d99d30d136a8f92937b98969
parentc7e3c501f01b6429519e2b8466d6bd8e2f7e22b9 (diff)
downloaddbscripts-e284d06d6cf63665cbadcb65e3a09bbd18027bd1.tar.gz
dbscripts-e284d06d6cf63665cbadcb65e3a09bbd18027bd1.tar.xz
Change ftpdir-cleanup scripts for package pooling
* The per repo script now simply removes files as they should all be symlinks at this time * The cron job script will do the extra job of checking the global pool. If there are no more symlinks, move the pooled package Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
-rwxr-xr-xcron-jobs/ftpdir-cleanup35
-rwxr-xr-xmisc-scripts/ftpdir-cleanup15
2 files changed, 40 insertions, 10 deletions
diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup
index d66138c..1ccc654 100755
--- a/cron-jobs/ftpdir-cleanup
+++ b/cron-jobs/ftpdir-cleanup
@@ -31,7 +31,40 @@ trap ctrl_c 2
/usr/bin/renice +10 -p $$ > /dev/null
for repo in $repos; do
- $(dirname $0)/../misc-scripts/ftpdir-cleanup $repo $CLEANUP_DESTDIR
+ $(dirname $0)/../misc-scripts/ftpdir-cleanup $repo
done
+to_cleanup=""
+for _arch in ${ARCHES[@]}; do
+ poolpath="$FTP_BASE/packages/os/$_arch/"
+ cd $poolpath
+ for pkg in *$PKGEXT; do
+ [ -f "$pkg" ] || continue # in case we get a file named "*.pkg.tar.gz"
+ LINKS="$(/bin/ls $FTP_BASE/*/os/$_arch/$pkg 2>/dev/null)"
+ if [ -n "$LINKS" ]; then
+ found=0
+ for lnk in $LINKS; do
+ if [ -h "$lnk" ]; then
+ found=1
+ break
+ fi
+ done
+ # No links found, clean it up
+ if [ $found -eq 0 ]; then
+ to_cleanup="$to_cleanup $poolpath/$pkg"
+ fi
+ fi
+ done
+done
+
+if [ -n "$to_cleanup" ]; then
+ echo " The following packages are no longer in any repo"
+ echo " They will be moved to $CLEANUP_DESTDIR"
+ for f in $to_cleanup; do
+ echo " $(basename "$f")"
+ done
+ echo ""
+ mv "$f" "$CLEANUP_DESTDIR"
+fi
+
cleanup
diff --git a/misc-scripts/ftpdir-cleanup b/misc-scripts/ftpdir-cleanup
index 351c0f4..97f46b2 100755
--- a/misc-scripts/ftpdir-cleanup
+++ b/misc-scripts/ftpdir-cleanup
@@ -1,12 +1,11 @@
#!/bin/bash
-if [ $# -ne 2 ]; then
- echo "usage: $(basename $0) <reponame> <dest-dir>"
+if [ $# -ne 1 ]; then
+ echo "usage: $(basename $0) <reponame>"
exit 1
fi
reponame=$1
-dest=$2
############################################################
@@ -65,6 +64,7 @@ for arch in ${ARCHES[@]}; do
cd "$ftppath"
for pkg in $CLEANUP_TMPDIR/*; do
+ [ -f "${pkg}" ] || continue
filename=$(grep -A1 '^%FILENAME%$' "${pkg}/desc" | tail -n1)
if [ ! -e "${filename}" ]; then
@@ -124,7 +124,6 @@ for arch in ${ARCHES[@]}; do
if [ -n "$DELETEFILES" ]; then
echo " The following files are out of date"
- echo " They will be moved to '$dest'"
for f in $DELETEFILES; do
echo " $f"
done
@@ -150,14 +149,13 @@ for arch in ${ARCHES[@]}; do
if [ -n "$EXTRAFILES" ]; then
echo " The following files are in the repo but not the db"
- echo " They will be moved to '$dest'"
for f in $EXTRAFILES; do
echo " $f"
done
fi
if [ -n "${DELETEFILES}" ]; then
- ${CLEANUP_DRYRUN} || mv ${DELETEFILES} "$dest"
+ ${CLEANUP_DRYRUN} || rm -f ${DELETEFILES}
echo ""
fi
@@ -167,7 +165,7 @@ for arch in ${ARCHES[@]}; do
fi
if [ -n "${EXTRAFILES}" ]; then
- ${CLEANUP_DRYRUN} || mv ${EXTRAFILES} "$dest"
+ ${CLEANUP_DRYRUN} || rm -f ${EXTRAFILES}
echo ""
fi
@@ -197,7 +195,6 @@ fi
if [ -n "$ARCHINDEPFILES" ]; then
echo " The following architecture independent packages"
echo " are not symlinked in the architecture repositories."
- echo " They will be moved to '$dest'"
for f in $ARCHINDEPFILES; do
echo " $f"
done
@@ -205,6 +202,6 @@ fi
if [ -d "$ftppath_base/any" -a -n "${ARCHINDEPFILES}" ]; then
cd "$ftppath_base/any"
- ${CLEANUP_DRYRUN} || mv ${ARCHINDEPFILES} "$dest"
+ ${CLEANUP_DRYRUN} || rm -f ${ARCHINDEPFILES}
echo ""
fi