Subject: Re: Editing and rebuiding the pkgdb.byfile.db by hand
To: Todd Gruhn <tgruhn2@mail.com>
From: Frederick Bruckman <fredb@immanent.net>
List: tech-pkg
Date: 07/10/2003 14:24:50
On Fri, 11 Jul 2003, Todd Gruhn wrote:

> I keep getting this nasty error:
>
> gandalf# pkg_info mit-pthreads
> Information for mit-pthreads-1.60b6:
>
> Comment:
> ERROR: show_file: Can't open '+COMMENT' for reading!
>
> Description:
> ERROR: show_file: Can't open '+DESC' for reading!
>
> I believe it is because of this lack of data that I cannot
> use 'pkg_admin rebuild' to rebuild the database -- it chokes
> whe it hits the mit-pthreads entries. And I cannot delete and
> do a make; reinstall GRRR!

It should be fine to delete the corrupted package, delete the
package's directory in "/var/db/pkg" if necessary, do a "pkg_admin
rebuild", then re-install. If "pkg_admin check" ever finds errors, by
the way, it's a good idea to delete the suspect package before running
"pkg_admin rebuild", otherwise you're just papering over the errors,
defaeating the whole purpose of the checks.

> Is it possible to edit the dumped database (have that)
> and reconvert said dumped-database-file back into a *.db
> file? Probably most important Q to ask here is: Is it
> a Berkeley DB file, and how would I create that using the
> BerkeleyDB Perl module? Has anyone tried this before?

I did write a utility (pkgdb), as part of a larger project, that can
add or delete individual keys:

    ftp://ftp.netbsd.org/pub/NetBSD/misc/fredb/pkg_hack.tar.gz

It uses pkg_add's libinstall to do the dirty work, so it can't do
anything too weird or incompatible with the pkg_tools.

Frederick