How To Upgrade Packages In FreeBSD?


FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution. It is used to power modern servers, desktops, and embedded platforms.

In FreeBSD, there are two ways to install a package: Using pkg and from the ports collection. Over time, newer versions of the software package become available for installation.

This article describes how to upgrade packages to a newer version in FreeBSD.

How to determine the packages available for upgrade

Before you check and start upgrading packages, ensure that the latest version of the ports tree is installed. To upgrade ports tree execute the following command –

portsnap fetch update

To list the outdated packages in FreeBSD 10 and later use –

pkg version -l "<"

In FreeBSD 9.x and prior versions use –

pkg_version -l "<"

How to upgrade packages

There are various ways to upgrade ports or packages, we will discuss here a few of them.

Upgrading ports using portmaster

Portmaster is a utility categorized under ports-mgmt in the ports tree. To use it for upgrading packages first you need to install it in your system. Use the following command to install it –

cd /usr/ports/ports-mgmt/portmaster
make install clean

Portmaster defines four categories of ports –

  • Root port – has no dependencies and is not a dependency of any other port
  • Trunk port –  has no dependencies but other ports depend upon it
  • Branch port – has dependencies and other ports depend upon it
  • Leaf port – has dependencies but no other ports depend upon it

To list all installed ports by category and search for updates use the following command in your terminal –

portmaster -L

Now use the following command to upgrade all the packages –

portmaster -a

Once this command gets executed, it will start upgrading the outdated applications into newer versions meanwhile it can prompt you to select or deselect programs as you can see in the image below. Select or deselect a program using the space button and then press enter for ok.

Use the following command if errors are encountered during the upgrade process, add -f to upgrade and rebuild all the ports.

portmaster -af

Upgrading ports using portupgrade

Portupgrade is another utility that can be used to upgrade ports. It also categorized under ports-mgmt in the ports tree. It depends upon ruby, to start using it first you need to install it in your system. Use the following command to install it –

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

Now once this utility gets installed, use the following command to upgrade all the outdated ports –

portupgrade -a

To upgrade a specified application use the following command in your terminal –

portupgrade -R nano

If you use option -P with the above command, portupgrade will first search for available packages locally, if not found locally it will start fetching packages from the remote location.

portupgrade -PP xfce

Conclusion

There are other tools such as synth that can also be used for upgrading outdated packages in FreeBSD.

Ok, that’s all for now. If you have a query on this topic then write it to us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.