Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Mar 2008 02:17:37 +0000
From:      RW <fbsd06@mlists.homeunix.com>
To:        freebsd-ports@freebsd.org
Subject:   Re: Cleaning /var/db/ports
Message-ID:  <20080326021737.4a650588@gumby.homeunix.com.>
In-Reply-To: <47E9991A.2020507@FreeBSD.org>
References:  <47E949A3.5030103@gmail.com> <47E9991A.2020507@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 25 Mar 2008 17:30:18 -0700
Doug Barton <dougb@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
--------------------------------------------------------------



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080326021737.4a650588>