After upgrading FreeBSD from v6 to 6.1, i tried to upgrade all software installed on the server with portupgrade.
I start getting the error
[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 … [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!]
Command failed [exit code 1]: /usr/local/sbin/pkgdb -aFQ
Command failed [exit code 1]: /usr/local/sbin/pkgdb -aFQ
The problem is fixed by deleting the pkgdb.db file
server26# rm /var/db/pkg/pkgdb.db