From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 22 18:00:28 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 90757106564A for ; Thu, 22 Apr 2010 18:00:28 +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 00FD08FC19 for ; Thu, 22 Apr 2010 18:00:27 +0000 (UTC) Received: by wwa36 with SMTP id 36so5661887wwa.13 for ; Thu, 22 Apr 2010 11:00:26 -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:cc:content-type; bh=WaWBfYbGwIe7GYLwPn/mwUU2Rfl5nPwMGu/pnvzzpgs=; b=iZSw8GcBBoaV/TXPYgqBue/SK2S/jpqfk4pBVUn+mQtgwD/00OVTT/fnrbKXruSmSA WoYRIEfhgjXblpNV4PDTetXz/vdNBoiG2CRqNt1eG1IvlQ+KNf5ZNB0jU1d8kcOa97n0 V1ca4TMsVOiqtW4vpAgQmuVkCooPAV6aGsS6I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:reply-to:date:message-id:subject:from:to:cc :content-type; b=ZY9PN/Oi0Rv5JmjqyzmSfBSFmh4XB6atXBMdhid5oTMhfZMLPbjVMsX+TZoarptJlA +PK4/ltdAYUTcY6QAUJv5pXMYlPTo9L6ik6Dau1C/vFGktDAkzTowSZ9kxTOAhcXZfmB Gk4rcEmCHPv+PO4qiEQ8DVg29BILqRLDuIXys= MIME-Version: 1.0 Received: by 10.216.229.165 with HTTP; Thu, 22 Apr 2010 11:00:26 -0700 (PDT) Date: Thu, 22 Apr 2010 18:00:26 +0000 Received: by 10.216.87.16 with SMTP id x16mr2683381wee.27.1271959226517; Thu, 22 Apr 2010 11:00:26 -0700 (PDT) Message-ID: From: "b. f." To: freebsd-hackers@FreeBSD.org Content-Type: text/plain; charset=ISO-8859-1 Cc: mandree@FreeBSD.org 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:00:28 -0000 >Am 22.04.2010 14:49, schrieb Diane Bruce: >> On Tue, Apr 20, 2010 at 10:11:24PM -0400, 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) >> >> >> You would have to write a script which went through each file in >> /usr/local/bin and /usr/local/lib (mostly sufficient) and examined >> every single pkg-plist looking for the corresponding file. Then you >> know what port the file was generated by. Needless to say, this would >> be somewhat horrible. > >Diane, > >it's not *that* bad. Consider this algorithm: > >1. scan for files under /usr/local/{bin,include,lib,libexec,sbin} and sort or >hash the list - perhaps guess just a port name from an executable in /usr/local/bin > >2. Repeat: > > 2.1 use the next file from the list and search for it > 2.2 once you have a port name for this file, obtain the packing list and >remove it from the file list in 1. This cuts down the list from 1 quite a bit. > >3. Now print the list of ports found, > and print the list of files not found in ports > > >Surely and index of plist files in port default configurations could help big >time, but even a blunt ( cd /usr/ports && find . -mindepth 3 -maxdepth 3 -name >pkg-plist -exec egrep FILENAME '{}' + ) might be reasonable given sufficient RAM >so that it runs from cache for the 2nd file you inquire. > >If that is too slow, a step between 1 and 2 could procure all pkg-plists as some >sort of FILEINDEX file to accelerate searches. > >HTH >Matthias By the time you account for CONFLICTS, dynamic plists, substitutions in plists, etc., I'd have to agree with Diane that this is a pain. It could be done, and would help to reconstruct most if not all of an average user's /var/db/pkg, but it's laborious. b.