Date: Fri, 12 Oct 2007 21:19:09 +0200 From: Mel <fbsd.questions@rachie.is-a-geek.net> To: freebsd-questions@freebsd.org Subject: Re: I performed an rm -r on /var/lib/pkg Message-ID: <200710122119.09370.fbsd.questions@rachie.is-a-geek.net> In-Reply-To: <1192142367.33933.32.camel@secretariat.lanl.gov> References: <1192134379.33933.9.camel@secretariat.lanl.gov> <18190.41045.40653.528498@jerusalem.litteratus.org> <1192142367.33933.32.camel@secretariat.lanl.gov>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710122119.09370.fbsd.questions>