Tuesday, October 23, 2012

FreeBSD Ports and Packages Tips & Tricks

Listing installed ports

pkg_info
pkg_info | grep -i foo

What files are installed by a given port

pkg_info -L foo.1.1 | less

Show me duplicate ports or packages

pkg_info | sort | sed -e 's/-[0-9].*$//' | uniq -c | grep -v '^[[:space:]]*1 

Corrupted ports DB

Sometimes, the ports DB can be corrupted. It may happen following an upgrade to RELEASE-pxx and a kernel recompilation (make buildinstall and so on).
Everything is looking fine but after the last mergmaster and reboot to multi-user mode it's now time to recompile all installed ports. To do so, it usually mean that you have first to upgrade portupgrade ( portversion | grep 'needs updating' ).

portupgrade -R -r -O portupgrade

And suddenly comes troubles; even portversion is fucked up!

portversion -l '<'
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ... /var/db/pkg/pkgdb.db: unexpected file type or format -- Invalid argument; rebuild needed] [Rebuilding the pkgdb <format:bdb_btree> in /var/db/pkg ... [Updating the pkgdb <format:bdb_btree> in /var/db/pkg ... /var/db/pkg/pkgdb.db: unexpected file type or format -- Invalid argument; rebuild needed] [Rebuilding the pkgdb <format:bdb_btree> 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 

Trying to repair with portsdb will not make it

portsdb -uU 
 Updating the ports index ... Generating INDEX.tmp - please wait..Warning: Duplicate INDEX entry: mod_rpaf-0.5 Done. done [Updating the portsdb <format:bdb_btree> in /usr/ports ... - 16318 port entries found portsdb:

/usr/ports/INDEX-6.db: unexpected file type or format -- Invalid argument: Cannot update the portsdb! (/usr/ports/INDEX-6.db)]
The solution is to rebuild the DB

mv /var/db/pkg/pkgdb.db /var/db/pkg/pkgdb.db_Corrupted
portsdb -ufU 
Updating the ports index ... Generating INDEX.tmp - please wait..Warning: Duplicate INDEX entry: mod_rpaf-0.5 Done. done [Updating the portsdb <format:bdb_btree> in /usr/ports ... - 16318 port entries found

.........1000.........2000.........3000.........4000.........5000.........6000.........7000.........8000...... ...9000.........10000.........11000.........12000.........13000.........14000.........15000.........16000... ..... done]

pkgdb -u && pkgdb -F

It should now be fixed.

Disregard (accept the default [no] by pressing ENTER) for linux-base, if any such message is displayed during the process.

No comments:

Post a Comment