Unix & Linux

How to update ports on FreeBSD with portmaster or portupgrade

First, you should get a fresh copy of ports tree. I can recommend portsnap. If you are running portsnap for the first time, extract the snapshot into /usr/ports:

$ portsnap fetch
$ portsnap extract

If you already have a populated /usr/ports and you are just updating, run the following command instead:

$ portsnap fetch update

Now you can check which ports are outdated:

$ pkg version -v | grep need

You will see the following output:

mariadb100-client-10.0.15          <   needs updating (index has 10.0.22)
mariadb100-server-10.0.15          <   needs updating (index has 10.0.22)
memcached-1.4.22                   <   needs updating (index has 1.4.24_2)

Next, install portupgrade utility to easily upgrade installed ports:

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

Scan the list of installed ports and fix all the inconsistencies it reports:

$ pkgdb -F

It is a good idea to do this regularly, before every upgrade. If you want to upgrade all outdated ports, run:

$ portupgrade -a

Use the -i flag if you want to be asked for confirmation of every individual upgrade:

$ portupgrade -ai

If you want to upgrade only a certain application, not all available ports, use portupgrade pkgname. Include the -R flag if portupgrade should first upgrade all the ports required by the given application.

$ portupgrade -R wget

After building and installing software from the ports, you should always remember to clean up the temporary work directories using the make clean command. You can sweep the whole Ports Collection with the following command:

$ portsclean -C

Leave a Reply

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