Upgrading Software

This is a very simple task that sometimes leads to big headaches and lengthy troubleshooting. In a perfect world in which all goes well, however, there are really only 3 things you should have to do in order to upgrade an application to its newest available version.

Before we do that, however, please note that this section assumes you have portupgrade installed on your system. To find out whether you have it or not, type

pkg_info | grep portupgrade

Which should spit out "portupgrade" with a version number. If you get nothing in response, you need to install portupgrade:

cd /usr/ports/sysutils/portupgrade
make install clean

Now that we have portupgrade, we can continue with this section.

First, make sure that your Ports tree is up-to-date. As root:

cvsup /root/ports-supfile

This will update your Ports tree. Once this has finished,

pkgdb -F

This will fix any inconsistencies in your package database. For more information on the usage of pkgdb -F, visit our page devoted to the topic here.

portupgrade firefox

This will upgrade Firefox to the newest available version in Ports. If, on the other hand, and want to upgrade all of your applications at once, type:

portupgrade -akO

This will (if successful) upgrade all of your installed applications to the most current versions available in Ports. At the end of the process, any packages that failed to upgrade properly will be listed (it is not uncommon for a few packages to fail to upgrade on any given attempt). We have pages with solutions and advice on a few of the more common errors encountered while upgrading, which you can find listed on our Table of Contents or at the end of this section.

Another useful way to upgrade is to first run the following command:

pkg_version -L =

Which will tell you which of your installed packages are out-of-date. Then, you can run portupgrade on those outdated packages that you want to update. (You might not want to upgrade all of them). The output of this command will look something like this:

fongsaiyuk% pkg_version -L =
expat                                            <
openoffice                                    <
pkgconfig                                     <
png                                               <
xorg-server                                   <
xterm                                            <
reinholz@fongsaiyuk$

Which tells me that expat, openoffice, and the other listed packages have more recent versions available (and listed) in my Ports tree. (In other words, that these packages are out-of-date). However, I know that I DO NOT want to upgrade openoffice. I don't have the patience to wait as this massive app is compiled/installed from source.

So what if you're lazy and want to be able to do a "portupgrade -akO", but you don't want certain packages (like openoffice or linuxpluginwrapper) to be included in the upgrade? No problem. All we have to do is edit this file:

vi /usr/local/etc/pkgtools.conf

And add the following lines if they do not already exist:

  HOLD_PKGS = [
    'bsdpan-*',
    'linuxpluginwrapper*',
    'en-US-openoffice*',
  ]

Which tells portupgrade not to upgrade these packages. Very useful tool.

Common Portupgrade Pitfalls

It is not uncommon for a few packages to fail to upgrade (or build for the first time) successfully. Although we cannot give advice or solutions to every upgrade or install problem that might arise, we have highlighted a few of the more common errors encountered while attempting to upgrade software.

The first thing you should do when a package fails to upgrade or build properly is to check /usr/ports/UPDATING for important information. A good technique is to open this file in vi, then search for the name of the package you're having trouble with. If you are unfamiliar with vi, we have a page here that lists some useful commands for that application. If cups failed to upgrade properly, for example, you would open /usr/ports/UPDATING in vi and then type /cups and hit 'Enter' to search for the word "cups." I cannot stress enough how important it is to check /usr/ports/UPDATING when a package fails to upgrade. Often this is because upgrading the package will break other packages on your system unless you follow the steps outlined in /usr/ports UPDATING.

It is also a good idea to check FreshPorts for any critical information about upgrading.

Before you look any further, however, we have created some pages dealing with some of the most common upgrading pitfalls and techniques. See if these help before expanding your search elsewhere:

Checksum Mismatch
____ conflicts with installed package(s): ____
XML::Parser
pkgdb -F usage
Restoring an earlier version of an application

Since Xorg has been updated from a monolithic to a modular system, sometimes certain components can be updated in a way that breaks compatibility with other components that have not yet been updated. In particular, a newer version of Xorg may include ABI changes, yet all drivers may not yet be updated for the new ABI. In such a situation, try running X by using

startx -- -ignoreABI

and it may solve your problem. If this is the case, you may want to consider aliasing some command (perhaps starty) to start X with the ignoreABI option.

If none of the above-listed pages help with your upgrading problem, and there is no information about the problem package listed in /usr/ports/UPDATING, you may have to do some searching on Google or your favorite forums. NOTE: it is far more successful to paste all or a portion of the error message that appears in your terminal into Firefox and search for those exact terms than to type some generic search term like "bash won't build" or "portupgrade fails". The latter 2 won't return any useful results, but your exact error message very well may.

One final word: sometimes a package just won't build. It happens. It can be incredibly frustrating. Keep in mind that errors without easy fixes are generally rare, and most Port maintainers are pretty good about updating things. If a package just won't build or upgrade, keep checking on FreshPorts to see if a new version has come out. Sometimes it is only a matter of days before a fix arrives. Other times, the wait can be quite lengthy. During that time, you have to ask yourself how bad you really need to update this particular trouble package. If you cannot install it in the first place, there is always the pkg_add route, and don't forget about portdowngrade either. Just because the current version won't build doesn't mean that the previous one won't either. It very well may. If you're running FreeBSD on a platform other than x86 (i386), try opening the Makefile for the application and searching for the line ONLY_FOR_ARCHS= and see if your platform is listed. If there is an ONLY_FOR_ARCHS limitation and your platform is not listed, I'm afraid you're out of luck as far as that particular package is concerned.