From owner-freebsd-questions@FreeBSD.ORG Fri Oct 12 19:19:12 2007 Return-Path: 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 0A37316A417 for ; Fri, 12 Oct 2007 19:19:12 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from snoogles.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id D2EC113C474 for ; Fri, 12 Oct 2007 19:19:11 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from localhost (localhost [127.0.0.1]) by snoogles.rachie.is-a-geek.net (Postfix) with ESMTP id A94921CDFC for ; Fri, 12 Oct 2007 11:19:10 -0800 (AKDT) From: Mel To: freebsd-questions@freebsd.org Date: Fri, 12 Oct 2007 21:19:09 +0200 User-Agent: KMail/1.9.7 References: <1192134379.33933.9.camel@secretariat.lanl.gov> <18190.41045.40653.528498@jerusalem.litteratus.org> <1192142367.33933.32.camel@secretariat.lanl.gov> In-Reply-To: <1192142367.33933.32.camel@secretariat.lanl.gov> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-6" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200710122119.09370.fbsd.questions@rachie.is-a-geek.net> 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 List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Oct 2007 19:19:12 -0000 On Friday 12 October 2007 00:39:27 James wrote: > 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. OK, found the culprit after some digging. Quite enlightening. The pkg_create command gets fed the output of make actual-depends-list, which generates a package dependency list based on what's really installed, by looking into /var/db/pkg. Of course this doesn't work for you. The solution lies in PKG_ARGS. I created a Makefile.local in x11/kdebase3 (cuz I was there), with the following one-liner: PKG_ARGS= -v -c -${COMMENT:Q} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`cd ${.CURDIR} && ${MAKE} package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | ${SORT} -u -t : -k 2`" ${EXTRA_PKG_ARGS} $${_LATE_PKG_ARGS} This is a copy of PKG_ARGS as defined in /usr/ports/Mk/bsd.port.mk with the difference that it uses package-depends rather then actual-package-depends to generate the dependency list. I'm 90% sure this ignores any WITH_ knobs/options you've set to generate the dependency list, so you'll have to fix any stale dependencies with pkgdb -F or similar tools later. Adding the above line to /etc/make.conf should work for you - make sure it's one line or escape properly ;) -- Mel