Upgrading software (ports/packages) in FreeBSD

You can use portupgrade to keep ports up to date in FreeBSD.  It is best to do this often to avoid as many problems as possible.

It sometimes causes a problem and you should be prepared to resolve any problems it may cause.  You have been warned!

First, if you have not installed portupgrade, you can install it from packages or ports.  To install it from packages, use:

pkg_add -r portupgrade

Or from ports, use:

cd /usr/ports/ports-mgmt/portupgrade
make install distclean

Assuming you have portupgrade installed, you should first upgrade your ports collection.  I have detailed how to do this in this post.

Once the ports tree is updated (it takes a while), you can check which ports/packages require upgrading with the following command:

pkg_version -v | grep -v up-to-date

This will show you 1 line per package that needs upgrading.  On the left, the installed package and version – and on the right the new version.

To upgrade all ports/packages (this takes time as it will download and compile everything), use the following command:

portupgrade -rv \*

Depending on your shell, you may or may not require the escape character ( \ ) before the *.

Beware that the uninstall of some ports will shutdown daemons but the installer will not restart them.  A common example is the MySQL server port.  A simple solution is to reboot the server once done.

Any problems will be reported at the end of the process.  As I explained above, you may need to resolve some issues manually and this can be complex!

6 thoughts on “Upgrading software (ports/packages) in FreeBSD

  1. Chris

    This isn’t really the forum for this question, but is related and since you seem quite knowledgeable of Things FreeBSD: Is there instead an equivalent of yum or apt-get where pre-packaged updates are installed, rather than having to download/compile individual bits?

    I have tried portupgrade before and have really gotten in trouble when it tried to build KDE… Thanks!

    Reply
    1. dan Post author

      you can use “pkg_add -r” to install a package from a remote location… e.g. “pkg_add -r bash”… installing from source is ideal (from ports) as you can get local machine optimisations and custom settings – but packages if you must.

      Reply
  2. Chris

    PS I just tried portupgrade to upgrade just ONE program – my bash shell – and now it’s downloading KDE (qt-everywhere)! I know about having to install dependencies but this takes the cake!

    Reply
  3. Chris

    Thank you! In the interim I found out about freebsd-update, which may offer the minimum package updates I desire, then can try to use portupdate for applications or tools which are not part of the OS distro…

    Reply
  4. Rico

    This is one of the main disadvantages of BSD – upgrading packages!

    I use Debian/GNU kFreeBSD – I get the cool FreeBSD kernel, but with the cool APT tool from Debian to handle all packages.

    No more stone-age upgrading using native FreeBSD tools.

    Reply
    1. dan Post author

      packages take forever to update.. this is why linuxes are generally far behind on packages.
      The ports tree allows you to keep your machine updated within days or even hours of source repositories being updated… Give me the FreeBSD ports method anyday.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *