Cleaning /var/db/ports
RW
fbsd06 at mlists.homeunix.com
Tue Mar 25 19:45:18 PDT 2008
On Tue, 25 Mar 2008 17:30:18 -0700
Doug Barton <dougb at FreeBSD.org> wrote:
> Lars Stokholm wrote:
> > Apart from doing 'rm -r /var/db/ports/*' is there a way of cleaning
> > the folder of stale folders and files?
>
> Not an automated one, no. It would also be somewhat difficult
> (although not impossible) to write an automated tool to do it because
> of the loose relationship between the names in /var/db/ports and the
> names in /var/db/pkg.
I think you can just compile a list of the UNIQUENAME values for all
installed origins and then delete any directories that are not on the
list - something like the script below. It's a bit slow though, and I'd
recommend running it without the -delete first time.
--------------------------------------------------------------
#!/bin/sh
: ${PORTSDIR:=/usr/ports}
: ${PORT_DBDIR:=/var/db/ports}
ure="nosuch-port"
for p in `pkg_info -qoa ` ; do
cd ${PORTSDIR}/$p
ure="${ure}|`make -V UNIQUENAME`"
done
cd ${PORT_DBDIR}
find -E . -mindepth 1 \! -regex "^\./(${ure})(/.*)?" -delete
--------------------------------------------------------------
More information about the freebsd-ports
mailing list