From owner-freebsd-ports@FreeBSD.ORG Wed Mar 26 02:45:18 2008 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D872106566B for ; Wed, 26 Mar 2008 02:45:18 +0000 (UTC) (envelope-from fbsd06+UM=dccf5f20@mlists.homeunix.com) Received: from turtle-out.mxes.net (turtle-out.mxes.net [216.86.168.191]) by mx1.freebsd.org (Postfix) with ESMTP id DE7998FC19 for ; Wed, 26 Mar 2008 02:45:17 +0000 (UTC) (envelope-from fbsd06+UM=dccf5f20@mlists.homeunix.com) Received: from mxout-04.mxes.net (mxout-04.mxes.net [216.86.168.179]) by turtle-in.mxes.net (Postfix) with ESMTP id 3FA7E16415E for ; Tue, 25 Mar 2008 22:17:43 -0400 (EDT) Received: from gumby.homeunix.com. (unknown [87.81.140.128]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTP id A9C5BD05BA for ; Tue, 25 Mar 2008 22:17:40 -0400 (EDT) Date: Wed, 26 Mar 2008 02:17:37 +0000 From: RW To: freebsd-ports@freebsd.org Message-ID: <20080326021737.4a650588@gumby.homeunix.com.> In-Reply-To: <47E9991A.2020507@FreeBSD.org> References: <47E949A3.5030103@gmail.com> <47E9991A.2020507@FreeBSD.org> X-Mailer: Claws Mail 3.3.1 (GTK+ 2.12.9; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: Cleaning /var/db/ports X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Mar 2008 02:45:18 -0000 On Tue, 25 Mar 2008 17:30:18 -0700 Doug Barton 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 --------------------------------------------------------------