Subject: Re: Cleaning old packages from pkgsrc/packages/All
To: Mark Thomas <thomas.s.mark@gmail.com>
From: Greg Troxel <gdt@ir.bbn.com>
List: netbsd-help
Date: 12/08/2007 09:09:30
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