Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Apr 2010 18:00:26 +0000
From:      "b. f." <bf1783@googlemail.com>
To:        freebsd-hackers@FreeBSD.org
Cc:        mandree@FreeBSD.org
Subject:   Re: regenerating /var/db/pkg
Message-ID:  <l2rd873d5be1004221100x404c3ed7vdab3ce64c7e67c3e@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
>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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?l2rd873d5be1004221100x404c3ed7vdab3ce64c7e67c3e>