From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 22 18:48:46 2010 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F0141065670 for ; Thu, 22 Apr 2010 18:48:46 +0000 (UTC) (envelope-from bf1783@googlemail.com) Received: from mail-ww0-f54.google.com (mail-ww0-f54.google.com [74.125.82.54]) by mx1.freebsd.org (Postfix) with ESMTP id DC0088FC1F for ; Thu, 22 Apr 2010 18:48:44 +0000 (UTC) Received: by wwa36 with SMTP id 36so5698398wwa.13 for ; Thu, 22 Apr 2010 11:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:date:received :message-id:subject:from:to:content-type; bh=93MxQBQAc4fUxnAX9DjghpwEQsGc/0wVU0KXXh6s9IU=; b=wdC3g/MVdVSGN43rsZoqWqDIUBAViIYrnKi3iDBnS0Dkx0p/1NCRU/r7xlskVDTNeQ w+LV5Iv4EOFIeAew2ryQ50tz1uycr6PA+G13PUXYBS7noDE/JBx1nKeN+TqqO1lnY73Q hX60eFK1mJciNuOHcuClWc1XMV6cPdlZLziDs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:reply-to:date:message-id:subject:from:to:content-type; b=gMaPnq7B6FapXvo6REzW+HxN3ZrFI/OEx6QjQ6KL2mN1Cc8c7acjDVx8eqCw08JiRH TePVbHcELafqCqW4G+rVGHsdmH3K821DhGS6RiXuRZapbIZ7K5d+/3Wn3vNnqszP/t93 P1ivjWLzFvCCVMRV2MUNLPqw6oLKy30gwCj2E= MIME-Version: 1.0 Received: by 10.216.229.165 with HTTP; Thu, 22 Apr 2010 11:48:43 -0700 (PDT) Date: Thu, 22 Apr 2010 18:48:43 +0000 Received: by 10.216.85.140 with SMTP id u12mr758054wee.78.1271962123911; Thu, 22 Apr 2010 11:48:43 -0700 (PDT) Message-ID: From: "b. f." To: freebsd-hackers@FreeBSD.org Content-Type: text/plain; charset=ISO-8859-1 Cc: Subject: Re: regenerating /var/db/pkg X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: bf1783@gmail.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Apr 2010 18:48:46 -0000 Doug Barton wrote: >On 4/20/2010 7:11 PM, Aryeh M. Friedman wrote: >> I acciddentally rm'ed my /var/db/pkg and want to know is it possible to >> rgenerate it (I have portmaster and portupgrade installed) > >Portmaster certainly can't do this, it uses the information from >/var/db/pkg. I'm not sure if portupgrade can do it or not. > >Your most likely course of success is to generate a list of ports that >you know you're using ("root" and "leaf" ports in portmaster >terminology), back up any config or other key files from /usr/local, >then delete everything and reinstall. With regard to portupgrade, if your pkgdb file is intact, you should be able to reconstruct /var/db/pkg, although it may not be very convenient to do so. Unfortunately, by default the pkgdb file is /var/db/pkg/pkgdb.db, so it is often wiped out along with the rest of /var/db/pkg. However, if it is intact, make sure you first back it up before attempting to use it's contents, because most of the pkgtools attempt to edit it to correspond with the current state of /var/db/pkg (performing the equivalent of pkgdb -u/-aF) when invoked. You may be able to disable this editing via the "-O" flag, but I haven't checked this lately. If you have a list of installed packages, and a corresponding ports tree, you could reconstruct most but probably not all of /var/db/pkg by running "make generate-plist fake-pkg" in the ports tree origin of each package (if you built the packages with non-default options, you should have an intact /var/db/ports for this to fully work). The directories for packages with dynamic plists might not be fully restored without rebuilding the ports, but this may be enough for a first pass. You could then prune or account for files in PREFIX/LOCALBASE that aren't listed as belonging to a registered package, via something like: find /usr/local -type f -print0 | xargs -0 pkg_which -v | fgrep '?' or with something similar using "pkg_info -W..." instead of "pkg_which -v". Alternatively, if you have backups of all the installed packages, or can obtain them from a server, you could use their packing lists to restore /var/db/pkg. But as Doug suggests, a full cleanup of PREFIX/LOCALBASE and reinstallation of all leaf packages may be easier than a reconstruction of /var/db/pkg. b.