Monday, September 17, 2007

FreeBSD Ports Collection, getting and keeping them up to date

To get the port tree for the first time:

portsnap fetch
portsnap extract

you will now have the ports tree at /usr/ports

To update the ports tree:

portsnap fetch
portsnap update


Typical install of a port

cd /usr/local/security/openssl
make install clean


Uninstall a port

cd /usr/local/security/openssl
make deinstall


The portmanager utility allows you to keep your installed ports up to date:

cd /usr/ports/ports-mgmt/portmanager
make install


To see if any installed ports are out of date:

portmanager -s

To upgrade all installed ports convient for those of us who would rather just have the system brought up to date without much ado:

portmanager -u

Interesting tidbit from the portmanager manual, portmanager comes with a pretty impressive safety net:

With the normal "make install clean" method of adding ports there is a critical step, after a port is made, the old port must be deinstalled then the new port installed in its place. If for some reason the new port fails to install you are left with neither your old port, nor the new one. It is for this reason portmanager makes a package from your old port before removing it, and if the new port fails to install correctly portmanager will reinstall your old port from that package.

Even if you out of portmanager at the crucial moment between removal of the old port and installation of the new port portmanager may still install the original from the backup package, this is not guaranteed though, so only at this step it is recommended not to terminate portmanager. Every other point in time it is perfectly safe to abort, , kill, etc., during program operation. Your ports collection will not be harmed!

Of course there are other ways to keep your ports tree in up to date. Here are couple articles on ports I just found from a google search that might prove useful, portupgrade and Ports Tricks.

Searching the ports tree for keywords

cd /usr/ports
make search key=rails more


Leave me a comment if you have any suggestions or know of any better ways to keep your ports collection up to date.