On 18 Feb 2008 02:14, Roman Kyrylych wrote:
... Then we can forget about this corner case, it can be worked around by cache cleanup scripts based on filename parsing (available on BBS and ML).
Along these lines this could be useful for someone searching through the list archives. It just removes old duplicates. I need it to clean up my local custom repo when I move $PKGDEST contents into it before rebuilding the repo database. This construct has so far caught every package name I've thrown at it... pkgname=$(echo $FILENAME|sed 's/^\(.*[^-][^0-9]\)-[0-9].*/\1/') mpkg_cleanrepo() { [ -n "$1" ] && WORK=$1 || WORK=/var/cache/pacman/pkg [ -d $WORK ] && cd $WORK || { echo "ERROR: $WORK does not exist" && return } local TMP=($(echo *.pkg*)) # to prevent set -e failing [ ${#TMP[@]} -gt 1 ] && FILES=$(/bin/ls -v *.pkg*) || return BEFORE_DU=$(du -sb|cut -f1) for FILE in $FILES; do NAME=$(echo $FILE|sed 's/^\(.*[^-][^0-9]\)-[0-9].*/\1/') if [ "$PREV_NAME" = "$NAME" ]; then # msg "$PREV_FILE\n" 0 "REMOVED" 31 sudo rm $PREV_FILE CNT_RM=$(($CNT_RM+1)) else CNT_NOTRM=$(($CNT_NOTRM+1)) fi PREV_FILE=$FILE PREV_NAME=$NAME done AFTER_DU=$(du -sb|cut -f1) DIFF_DU=$(($BEFORE_DU-$AFTER_DU)) CURRENT_DU=$(echo $((AFTER_DU/1000000))|sed ':a;s/\B[0-9]\{3\}\>/,&/;ta') REMOVED_DU=$(echo $((DIFF_DU/1000000))|sed ':a;s/\B[0-9]\{3\}\>/,&/;ta') if [ $CNT_RM -gt 0 ]; then # msg "$(pwd)\n" 33 "Package Path:" 31 printf "%-24s %4d %8sM\n" "Packages removed" $CNT_RM $REMOVED_DU printf "%-24s %4d %8sM\n" "Remaining packages" $CNT_NOTRM $CURRENT_DU fi } --markc