The FreeBSD Ports Collection is a wonderful system that makes it easy to install third-party-software on a FreeBSD system. The canonical way to install a piece of software from ports is usually:

# cd /usr/ports/<port_to_install>
# make
# make install

So the souce package will be downloaded from the internet, compiled and installed. If the program depends on other programs (for example certain libraries), then these dependencies will be installed automagically.

The (in my opinion) weakest point of the Ports Collection, though, is the upgrade mechanism (when you're installing a new version of an already installed port), because you should delete the old package first und then install the new one, to prevent old files lying around in the system und to remove the old entries in the package database under /var/db/pkg.

But when deinstalling an old package, all dependencies are broken, if other packages rely on this package. Allthough these packages should still run with the newer version of the port you want to install, the dependency information is lost after the upgrade, and that could be a problem in future upgrades.


To prevent this, I've written a small script called that keeps the dependency information during an upgrade. You should use it like this:

# cd /usr/ports/<port_to_upgrade> 
# make [additional make-arguments]
# <options>

Options are:
   -p <path>        REQUIRED: Path to the old installed package
                    (e.g. /var/db/pkg/<port_to_upgrade>)
   -f               Don't ask about removal of old package, just do it.
   -c               Remove sources after installation (same as "make clean")
   -d               Remove sources and distfiles after installation 
                    (same as "make distclean")
   -m <make-args>   Additional make-arguments if the port supports it
                    (e.g. "-DWITHOUT_GNOME" or "WITH_GTK=yes")

So the old version will be deleted and the new version will be installed.

Of course, FreeBSD wouldn't be FreeBSD if such a tool wouldn't already exist. This tool called portupgrade (yes, this is very similar to the name of my script) is already part of FreeBSD's Ports Collection and was written by Akinori MUSHA <>. I do not doubt that this is a very well done piece of software, but it is written in Ruby and I didn't want to install the whole Ruby package just for this tool, so I wrote my own solution in Perl (talk about re-inventing wheels).


Please see the copyright inside the script for licensing issues. Don't forget that this is work in progress, so it might not do what you (and I) expect it to do.

Version 0.7 (2002-03-11) (Fix a bug that corrupts REQUIRED_BY files.)


Currently, looks like and, in fact, is quite a quick hack. So critics and patches are very welcome :-)