What happens with FreeBSD pkg and ports ends up with a corrupted database?

This happens from time to time, here’s how it was solved:

# pkgdb -F
—> Checking the package registry database
[Updating the pkgdb in /var/db/pkg ... /var/db/pkg/pkgdb.db: unexpected file type or format -- Invalid argument; rebuild needed] [Rebuilding the pkgdb in /var/db/pkg ... /var/db/pkg/pkgdb.db: unexpected file type or format -- Invalid argument: Cannot update the pkgdb!]: Cannot update the pkgdb!]

To fix this, remove /var/db/pkgdb.db and then run:

pkgdb -aF

# pkgdb -aF
—> Checking the package registry database
[Rebuilding the pkgdb in /var/db/pkg ... - 40 packages found (-0 +40) ........................................ done]
Stale dependency: portaudit-0.5.11 -> pkg_install-devel-20040811 (ports-mgmt/pkg_install-devel):
[/usr/ports/INDEX-5.db: unexpected file type or format -- Invalid argument] [Updating the portsdb in /usr/ports ... - 16801 port entries found /usr/ports/INDEX-5.db: unexpected file type or format -- Invalid argument: Cannot update the portsdb! (/usr/ports/INDEX-5.db)]
database file error

Now we’ve got a ports db error, remove the /usr/ports/INDEX-5.db file, and run:

portsdb -F -u

# portsdb -F -u
Receiving /usr/ports/INDEX-5.bz2 (921511 bytes): 100%
921511 bytes transferred in 3.0 seconds (296.37 kBps)
done
[Updating the portsdb in /usr/ports ... - 16817 port entries found .........1000.........2000.........3000.........4000.........5000.........6000.........7000.........8000.........9000.........10000.........11000.........12000.........13000.........14000.........15000.........16000........ ..... done]

Now all should work. Optionally:

Check for lost dependencies within installed ports:

pkgdb -L

And can fix up dependencies with:

pkgdb -F

VN:F [1.9.17_1161]
Rating: +1 (from 1 vote)
Tagged with:
 

One Response to FreeBSD pkgdb.db error

  1. Pavel says:

    thx. good advice!

    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Set your Twitter account name in your settings to use the TwitterBar Section.