pkg and portmaster don't show any installed ports or packages

I can't say what I did but, a few days ago, I was tinkering with my workstation. I noticed that I was no longer getting any listings for upgrading of ports using pkg or portmaster, which I get every day. So I did a pkg info which didn't show anything. Neither does portmaster -l.

I then look at /var/db/pkg/local.sqlite and see the last date is July 10th. In /var/backups the last date is July 9th. So, for some reason, it looks to me as if pkg and portmaster have lost their way and I don't know how to fix it. I did try pkg backup -r pkg.sql.xz but it only gave me a very small local.sqlite which didn't solve the p;roblem. The current sqlite file size is 360K.
 
I had done most of that for checking the db. The difference is, I have tables listed under .tables so it appears the database contains stuff but pkg and portmaster doesn't use make the connection.
 
You said your /var/db/pkg/local.sqlite is still of significant size. If this is the case, then you could extract a list of the origins of all installed ports and feed this list into ports-mgmt/portmaster for re-installation.

sqlite3 -list /var/db/pkg/local.sqlite 'SELECT origin FROM packages;' > reinstall_list.txt

In case the generated list by the above command contains garbage, you could repeat this with the backup files. You said already, that the latest doesn't seem to work so you need to go down the backup history until one of it gives a good list of installed ports.

You could recover the names (origins) of most if not of all of the installed ports using the following command sequence:
xz -cdk /var/backups/pkg.sql.xz.N > pkg-backup.N.sql
cat pkg-backup.N.sql | sqlite3 pkg-backup.N.sqlite
sqlite3 -list pkg-backup.N.sqlite 'SELECT origin FROM packages;' > reinstall_list.N.txt

N is meant to be the index of the history files, i.e. 1 to 7, and you want to iterate through it until you get a usable list of installed ports.
 
Last edited:
Back
Top