/var/db/pkg deleted

How to recreate the db? My packages exist on my system but db have none record of them. Also can not rebuilt my packages (logical because db find 0 packages). Any idea?
 
Tricky, did that once too when I first started with FreeBSD. As far as I know there's no way to recreate the database except to install everything again from the start.
 
Are you joking right? Ok. I think I have veeery hard work to do!!!!! And how I know all my system packages?
Code:
pkg_info | grep *
return 0 results. And installing a package is not installing all his dependencies too because already they exist on system. Now I am really stack! Well. That is something that is missing from FreeBSD. A tool to recreate the db!
 
sk8harddiefast said:
Are you joking right? Ok.
Nope, you are basically SOL x(

And how I know all my system packages?
Code:
pkg_info | grep *
return 0 results.
Memory?

And installing a package is not installing all his dependencies too because already they exist on system. Now I am really stuck! Well. That is something that is missing from FreeBSD. A tool to recreate the db!
I ended up reinstalling the box from scratch. For the umpteenth time, I remember doing that a lot when I started out with FreeBSD :e
 
sk8harddiefast said:
How to recreate the db? My packages exist on my system but db have none record of them. Also can not rebuilt my packages (logical because db find 0 packages). Any idea?

You cant ... write all app names that You use/need in some file, then remove all installed stuff and add them again:
Code:
# vi apps
# rm -rf /usr/local /var/db/pkg
# while read I
> do
>   pkg_add -r ${I}
> done < apps
#
 
sk8harddiefast said:
Are you joking right? Ok. I think I have veeery hard work to do!!!!! And how I know all my system packages?
Code:
pkg_info | grep *
return 0 results. And installing a package is not installing all his dependencies too because already they exist on system. Now I am really stack! Well. That is something that is missing from FreeBSD. A tool to recreate the db!

In theory, you could write a program that would go through $PREFIX and look up files in the pkg-plist files in ports.

In practice, many ports generate dynamic plists, and it would still require looping through every single port in /usr/ports. Maybe there's a better way, like a master plist that shows the origin of every file. The port-building clusters might have that, at least in their /var/db/pkg, but it's probably not available for download. (If you use ports-mgmt/portupgrade, you might be able to get the installed-ports list from its separate /var/db/pkg/pkgdb.db. No real idea how.)

Practical options are:

1. Back up /usr/local/etc, delete /usr/local, and start reinstalling.

2. Keep using the system, installing a port when you find it isn't listed in pkg_info output but you know the files are present. Eventually/hopefully/maybe you'll get everything replaced.

3. Post the question on the -ports mailing list, because more than a few people have experienced it, and maybe there is a way.
 
Well, same old story - you should keep a backup.

But to say something useful too: I did put a cron script on my systems which does a daily system check. Nothing special - it prints kernel version, installed packages, fstab contents, network info, etc.

I do keep them stored in /var/log/bsd/checkconfig/ directory so I can check the system status from days before.
I must say this information came in handy many times.
 
At the very least (if you don't have backups, that is) you should run a command like [cmd=]portmaster --list-origins > ~root/ports.today[/cmd] or [cmd=]pkg_info -aoq > ~root/ports.today[/cmd] once a day from root's crontab.
 
Back
Top