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
Pavel
thx. good advice!