portupgrade is a tool that allows you to upgrade ports on your FreeBSD system. It has its faults, and it doesn't always work (see below), but its about as close as you can get on FreeBSD to a 'one-click' upgrade.
There are other tools for doing upgrades, and several (including
portupgrade are outlined in the FreeBSD handbook.
Think about updating the base system. See the FreeBSD - Stable Upgrade page, or do a binary update.
First, make sure the ports tree and index file are up-to-date. You can do this either via
portsnap, or via
cvsup ports-supfile(if you're doing this for the first time, you'll need to copy the
/usr/ports/ports-supfile, and change the settings in the file as appropriate).
portsdb -Uuto sync up the ports index file with the ports tree you just updated
portsnap extract(only needed the first time you run portsnap)
Once the ports are up to do, you should backup the package database:
tar cvfz ~/pkg_db_backup.tar.gz /var/db/pkg
Run an audit:
Then, update the package database:
If the database is corrupted, fix it:
Look at the packages that need to be updated (note that
portversion uses the ports index file, so you need to make sure you ran
portsdb -Fu earlier to get the latest file):
portversion -v | grep -v up-to-date
To see the full list, do:
If you would prefer to check your ports against an actual can of the ports tree, you can use
pkg_version instead of
Doing it this way is a lot slower than using
First, figure out if any packages need to be upgraded manually. There isn't really any good way of doing this that I've figured out, but I've made a list of packages I've had problems with below. Feel free to add to it.
Next, do the actual update. You can do this one of two ways: either do a fully automatic upgrade, or do the upgrade bit-by-bit. The latter is STRONGLY recommended, as it allows you to go slowly and test things. The fully automatic upgrade will break things, and may take a lot of time to fix.
portupgrade -aRvIf you do decide to do this, you will want to use the -x option to exclude packages that shouldn't be upgraded automatically (see below), or upgrade those packages manually first.
portupgrade -Rv <pkgname>The
-Ris optional; it will upgrade all the packages that
portsclean -PCDL to clean up old ports, libraries, distfiles and packages.
Then, reboot and then check /var/log/messages for any errors. Also check that all expected services are working on the box.
On the first server you do the upgrade on, do:
/usr/ports/packagesdirectory if it doesn't exist already
portupgrade -p -aRvThis will build packages for each port in
cd /usr/ports/packages; tar cvfz ~/packages_030309.tar.gz *
portupgrade -P -aRvto install the ports using the packages you've made.
Some software doesn't behave well with the
portupgrade process. Sometimes it's because you need to run a certain command after the upgrade and
portupgrade doesn't know about it, or because you've installed the software with custom configuration options (although there are ways to mitigate that).
perl-after-upgrade -fto tell the system about the new version and update all packages necessary. See
man perl-after-upgradefor full details.
/var/db/dspamto that the
dspamuser can write to its database.
* WARNING: If you have a lot of ports installed (who doesn't?), start this process EARLY in the day, because the whole thing takes several hours to run, and there are usually a few things that have to be fixed manually at the end.
make -DDISABLE_VULNERABILITIES Of course, make sure you actually know what you're getting yourself into when you're installing a port with known vulnerabilities.