Thursday, July 21, 2005

Using Portsnap

For as long as I can remember I have been using cvsup to update my ports tree, but until recently I came across a quick excerpt on Richard Bejtlich blog about portsnap. I tried it once then stopped using cvsup for ports. Now I only use cvsup for sources and docs.

$> portsnap fetch
Fetching snapshot tag... done.
Fetching snapshot metadata... done.
Updating from Fri Jul 22 00:57:39 UTC 2005 to Fri Jul 22 02:22:01 UTC 2005.
Fetching 4 metadata patches... done.
Applying metadata patches... done.
Fetching 0 metadata files... done.
Fetching 4 patches... done.
...
Fetching 0 new ports or files... done.

$> portsnap extract
/usr/ports/x11/xtermset/
/usr/ports/x11/xtestpicture/
/usr/ports/x11/xtoolwait/
/usr/ports/x11/xtrlock/
/usr/ports/x11/xtset/
/usr/ports/x11/xvattr/
/usr/ports/x11/xvkbd/
/usr/ports/x11/xwatchwin/
/usr/ports/x11/xwit/
/usr/ports/x11/xxkb/
/usr/ports/x11/xzoom/
/usr/ports/x11/yalias/
/usr/ports/x11/yelp/
/usr/ports/x11/zenity/
Building new INDEX files... done.

$> portsnap update
Removing old files and directories... done.
Extracting new files:
/usr/ports/editors/abiword-devel/
/usr/ports/editors/abiword/
/usr/ports/irc/p5-POE-Component-IRC/
/usr/ports/www/chtml/
Building new INDEX files... done.


The fetch command fetches and stores a compressed snapshot of the ports tree, which is usually around 35MB in size. The compressed snapshot is stored in /usr/local/portsnap for later extraction using the 'extract' command. The extract command does exactly what it says, it extracts the contents of the compressed tree into /usr/ports/. Since this was my first time using portsnap and converting from cvsup, it was required that I extracted the compressed snapshot before I could use the update command to update my ports. Update is pretty fast compared to cvsup.

Now I just needed to see which ports were out dated:

$> pkg_version -L =
...
glib <
gnomekeyring <
iwi-firmware ?
k3b <
libidn <
mozilla <
...

There were about 20 ports which needed to be upgraded. Before I issuded the portupgrade command I needed to check for any stale dependencies and make sure my ports had no broken parts.

$> pkgdb -F

---> Checking the package registry database
Stale origin: 'sysutils/iwi-firmware': perhaps moved or obsoleted.
[Updating the portsdb in /usr/ports ... - 13244 port entries found .........1000.........2000.........3000.........4000.........5000.........6000
.........7000.........8000.........9000.........10000.........11000.........12000
.........13000.. ..... done]
Skip this for now? [yes] yes

The -F option lets you interactively fix the registry database if there appears to be a problem with a particular port. When I ran pkgdb one file was detected to have a stale origin, but I know this is no error as I have manually installed iwi-firmware to enable my ThinkPad wireless BG card to work correctly. iwi-firmware as of FreeBSD 5.4-Release was not included within the ports tree, but I assume that will change soon. I can now safely upgrade my the installed packages which need updating with portupgrade.

When I use portupgrade I like to first fetch all the required packages before compiling. I do a recursive fetch for all the ports which will be needed for the compile:

$> portupgrade -arF
$> portupgrade -ar

The -F option causes portupgrade to just fetch packages and store them in /usr/ports/distfiles for later compilation. -a and -r are for all packages and recursive respectively.