#!/bin/bash . "$(dirname $0)/../db-functions" . "$(dirname $0)/../config" repos="$(get_repos_for_host)" script_lock #adjust the nice level to run at a lower priority /usr/bin/renice +10 -p $$ > /dev/null repopaths='' for repo in $repos; do $(dirname $0)/../misc-scripts/ftpdir-cleanup-repo $repo repopaths="${repopaths} ${FTP_BASE}/${repo}/os/" done to_cleanup="" for _arch in any ${ARCHES[@]}; do poolpath="$FTP_BASE/$(get_pkgpool_for_host)/$_arch/" pushd $poolpath >/dev/null for pkg in *$PKGEXT; do [ -f "$pkg" ] || continue # in case we get a file named "*.pkg.tar.gz" LINKS="$(/usr/bin/find $repopaths -type l -name "$pkg" 2>/dev/null)" if [ -z "$LINKS" ]; then to_cleanup="$to_cleanup $poolpath/$pkg" fi done popd >/dev/null 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 $to_cleanup "$CLEANUP_DESTDIR" fi script_unlock