Portupgrade on FreeBSD

Ran into a “pkgdb.db: unexpected file type or format” during a portupgrade on FreeBSD. Here’s the fix.

I’m using FreeBSD, and keeping it up to date with the ports collection is normally a fairly simple thing to do.

  1. Make sure DNS is working (check you /etc/resolve.conf file)
  2. # portsnap fetch
  3. # portsnap update
  4. # portupgrade -a

Only, today I got a strange error message doing the portupgrade:
/var/db/pkg/pkgdb.db: unexpected file type or format — Invalid argument

Whether something broke, got disconnected, terminated in the middle of processing, or the database format or version changed, I dunno.

However, the fix is easy. Get rid of the problem files, and let portupgrade rebuild them.

# rm /var/db/pkg/pkgdb.db
# rm /usr/ports/INDEX*.db
# portupgrade -a

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.