Recovering loss of /var/db/pkg ?

b. f. bf1783 at googlemail.com
Sat Aug 8 11:02:07 UTC 2009


>There are a lot of common places the files would be installed such as
>bin, sbin, lib, libexec under %%PREFIX%%. You can use `find dir -type f
>| xargs -n1 -Ifoo sh -c "echo -n foo:; pkg_which foo"` to obtain the
>list of known files (pkg_which is part of ports-mgmt/portsupgrade).
>After that you can reinstall all packages that provide files with
>missing origin. I bet you should use the same /usr/ports you have last
>time when /var/db/pkg was full, just to be very close to pkg-plist.

Er, except that pkg_which uses the portupgrade package database which
is installed by default in -- you guessed it -- /var/db/pkg.  So if
you don't have it backed up somewhere, or don't have PKG_DBDIR defined
to a non-default location, you're out of luck.  And if it is still
intact, __back it up__ before calling any of the pkgtools  -- or you
may wipe it out as pkg_which does an automatic update of the pkgdb
after seeing that /var/db/pkg has been modified more recently than the
database.  Just use pkg_glob -qOa -- no need to use pkg_which.  If you
don't have it, you can:

1) use data recovery tools to try to read the names of the
subdirectories of /var/db/pkg from the disk; or
2) write a script to get the names of all files that belonged to ports
and swing through a ports tree, associating the files with ports via
the pkg-plist and PLIST_FILES variables; or
3) rip out all the old junk, and try to start afresh.

b.


More information about the freebsd-questions mailing list