[arch-dev-public] [PATCH 7/7] Change ftpdir-cleanup scripts for package pooling

Ghost1227 ghost1227 at archlinux.us
Thu Mar 11 23:08:43 CET 2010


---
 cron-jobs/ftpdir-cleanup    |   33 +++++++++++++++++++++++++++++++++
 misc-scripts/ftpdir-cleanup |   12 ++++--------
 2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup
index 8fa8cbc..c21c9d3 100755
--- a/cron-jobs/ftpdir-cleanup
+++ b/cron-jobs/ftpdir-cleanup
@@ -34,6 +34,39 @@ for repo in $repos; do
 	$(dirname $0)/../misc-scripts/ftpdir-cleanup $repo $CLEANUP_DESTDIR
 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
 
 # vim: set ts=4 sw=4 noet ft=sh:
diff --git a/misc-scripts/ftpdir-cleanup b/misc-scripts/ftpdir-cleanup
index d35b511..109b4c8 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>"
+	echo "usage: $(basename $0) <reponame>"
 	exit 1
 fi
 
 reponame=$1
-dest=$2
 
 ############################################################
 
@@ -113,7 +112,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
@@ -139,14 +137,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
 
@@ -156,7 +153,7 @@ for arch in ${ARCHES[@]}; do
 	fi
 
 	if [ -n "${EXTRAFILES}" ]; then
-		${CLEANUP_DRYRUN} || mv ${EXTRAFILES} "$dest"
+		${CLEANUP_DRYRUN} || rm -f ${EXTRAFILES}
 		echo ''
 	fi
 
@@ -186,7 +183,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
@@ -194,7 +190,7 @@ 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
 
-- 
1.7.0.2





More information about the arch-dev-public mailing list