From owner-freebsd-questions@FreeBSD.ORG  Thu Oct 11 22:38:54 2007
Return-Path: <owner-freebsd-questions@FreeBSD.ORG>
Delivered-To: freebsd-questions@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 99AD616A419
	for <freebsd-questions@freebsd.org>;
	Thu, 11 Oct 2007 22:38:54 +0000 (UTC) (envelope-from jamesh@lanl.gov)
Received: from mailwasher.lanl.gov (mailwasher.lanl.gov [204.121.3.2])
	by mx1.freebsd.org (Postfix) with ESMTP id 41CD613C448
	for <freebsd-questions@freebsd.org>;
	Thu, 11 Oct 2007 22:38:54 +0000 (UTC) (envelope-from jamesh@lanl.gov)
Received: from mailrelay2.lanl.gov (mailrelay2.lanl.gov [128.165.4.103])
	by mailwasher.lanl.gov (8.13.8/8.13.8/(ccn-5)) with ESMTP id
	l9BMcrVE025166; Thu, 11 Oct 2007 16:38:53 -0600
Received: from oppie-mail.lanl.gov (oppie-mail.lanl.gov [128.165.4.123])
	by mailrelay2.lanl.gov (8.13.8/8.13.8/(ccn-5)) with ESMTP id
	l9BMcpE7007229; Thu, 11 Oct 2007 16:38:51 -0600
Received: from [128.165.86.10] (secretariat.lanl.gov [128.165.86.10])
	by oppie-mail.lanl.gov (Postfix) with ESMTP id 169431F8002;
	Thu, 11 Oct 2007 16:38:49 -0600 (MDT)
From: James <jamesh@lanl.gov>
To: Robert Huff <roberthuff@rcn.com>
In-Reply-To: <18190.41045.40653.528498@jerusalem.litteratus.org>
References: <1192134379.33933.9.camel@secretariat.lanl.gov>
	<470E8D3A.8010508@daleco.biz>
	<1192136857.33933.18.camel@secretariat.lanl.gov>
	<20071011211317.GA24658@owl.midgard.homeip.net>
	<1192138145.33933.21.camel@secretariat.lanl.gov>
	<18190.41045.40653.528498@jerusalem.litteratus.org>
Organization: Los Alamos National Laboratories
Date: Thu, 11 Oct 2007 16:39:27 -0600
Message-Id: <1192142367.33933.32.camel@secretariat.lanl.gov>
Mime-Version: 1.0
X-Mailer: Evolution 2.10.3 FreeBSD GNOME Team Port 
X-CTN-5-MailScanner-Information: Please see
	http://network.lanl.gov/email/virus-scan.php
X-CTN-5-MailScanner: Found to be clean
X-CTN-5-MailScanner-From: jamesh@lanl.gov
X-Spam-Status: No
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
X-Content-Filtered-By: Mailman/MimeDel 2.1.5
Cc: freebsd-questions <freebsd-questions@freebsd.org>
Subject: Re: I performed an rm -r on /var/lib/pkg
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: jamesh@lanl.gov
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
	<mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions>
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
	<mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 11 Oct 2007 22:38:54 -0000

On Thu, 2007-10-11 at 18:14 -0400, Robert Huff wrote:

> James writes:
> 
> >  What has happened, though, is I've never ran rm in
> >  /usr/ports/distfiles.  I'm going to think for a little bit about
> >  a script that can move through /usr/ports/distfiles and reinstall
> >  everything that exists there.
> 
> 	Having been in almost the identical situation for different
> rasons, I sympathize.
> 	Yes, this will involve a sweep through /usr/ports distfiles.
> If you haven't ever deleted anything, I suggest a prelimiary manual
> run deleting everything but the most recent version.  This has a
> down-side, but it will prevent cluttering the rebuilt system with
> unused ports.


/usr/ports/distfiles is definitely looking promising. awk is too damn
painful to work with, so I'm going to dust off my perl skills.

Hell, this could actually turn out to be fun. And if I write the script
properly, it might make a nice disaster recovery tool
for /usr/ports/ports-mgmt - it can be called
"WhenYou'reAnIdiotLikeJamesWasOnFreeBSDQuestions"



Well, if you figure out what ports you have installed, you can
regenerate the 

> pkgdb using:
> 
> make -DNO_BUILD -DNO_INSTALL generate-plist fake-pkg
> 
> for each port.
> I just tested that using a temporary PKG_DBDIR. In case you wanna see what 
> happens, here's what I did:
> 
> mkdir -p /tmp/var/db/pkg
> cd /usr/ports/shells/bash
> env PKG_DBDIR=/tmp/var/db/pkg make -DNO_BUILD -DNO_INSTALL \
> 	generate-plist fake-pkg
> 
> 

Wow, that's great! I understand that it has the caveats that you mentioned, but it's
*at least* a fantastic start. 

James