Hello,

Related to my recent question on gentoo-user regarding freeing up disk space, I've just written a short bash script that helps tidying up the binary packages that portage builds (see below).

All it does it take each file in the distfiles and packages directories and use qpkg to see if the package that built/came from it is currently installed. If it isn't then it's removed.

There are obviously shortcomings with this, but as a rough tool it works. One problem is that if you have a package like rsync-1.2.3 and rsync-1.2.3-r1 then rsync-1.2.3 won't get removed until the system gets upgraded to rsync-1.2.4, as (AFAIK) there's no way to specify end-of-string in a query to qpkg (am I wrong about this?)

At the moment it moves packages into a subdirectory ready to be removed but doesn't actually remove them.

Any comments on this?

Cheers,

Andy

#!/bin/bash
# Clean out of date packages and distfiles out

PPATH="/usr/portage/packages/All"
DPATH="/usr/portage/distfiles"
FILELIST=`find $PPATH| sed -e \
's/.*\/\(.*\)\.\(tar.bz2$\|zip\|tar.gz$\|tbz2\|bz2\|gz\)$/\1/g' -e '1d'`

if [[ -z "$PPATH/../old" ]];
    then mkdir "$PPATH/../old"
fi

for file in $FILELIST; do
    echo -n "Testing $file    "
    if [[ ! `qpkg -I $file` ]];
        then mv $PPATH/$file* $PPATH/../old/
        echo "... removing";
    else echo
    fi
done

# Now we do the distfiles
FILELIST=`find $DPATH| sed -e \
's/.*\/\(.*\)\.\(tar.bz2$\|zip\|tar.gz$\|tbz2\|bz2\|gz\|exe\|wsz\|tgz\|patch\|bin\|tar.Z\)$/\1/g' -e '1d'`


if [[ -z "$DPATH/../old" ]];
    then mkdir "$DPATH/../old"
fi

for file in $FILELIST; do
    echo -n "Testing $file    "
    if [[ ! `qpkg -I $file` ]];
        then mv $DPATH/$file* $DPATH/../old/
        echo "... removing";
    else echo
    fi
done


-- [EMAIL PROTECTED] mailing list



Reply via email to