Re: Cleaning old packages from pkgsrc/packages/All

Greg Troxel <[email protected]> Sat, 08 Dec 2007 09:09:30 -0500
Newsgroups gmane.os.netbsd.help
Message-ID <[email protected]>
Besides lintpkgsrc -r, you may want to remove old packages, but not old
packages that are installed.  'Old package' means older than the one
that would be built by the current value of pkgsrc.  Also, lintpkgsrc -r
will remove old distfiles, and that's perhaps what you want, but
slightly different from removing only old binary packages.

I use this:

# prune distfiles
lintpkgsrc -mor

# make list of packages to prune
rm -f OLD OLD.installed OLD.delete
lintpkgsrc -p | egrep -v 'Cannot extract' > OLD
cat OLD | while read p; do
    pbase=`basename $p .tgz`
    if [ -d /var/db/pkg/$pbase ]; then
	echo "$p" >> OLD.installed
    else
	echo $p >>  OLD.delete
    fi
done

cat OLD.delete | sudo xargs rm -f