Updating the version of a port on MacPorts

2 minute read

Published:

If you come across a piece of software on MacPorts with an out of date version, here are instructions for how to update it. First open up a terminal window and identify the port’s maintainer:

port info --maintainers <portname>

If the port has a maintainer, easiest is to send them a polite email requesting the port is brought up to date.

If the port has no maintainer (nomaintainer@macports.org), or allows open maintenance (openmaintainer@macports.org), you can upgrade the port manually yourself via the following steps. If successful, you can then submit a new ticket to http://trac.macports.org/ in order for the update to be propagated onto the MacPorts server for the benefit of other users.

First change directory into the port folder:

cd $(port dir <portname>)

Backup the port build file:

sudo cp Portfile Portfile.orig

Use a text editor to edit the software version in the Portfile to the latest version number (e.g. version 1.4.1 to 1.5):

sudo nano Portfile

If the Portfile revision entry is not set to 0, set it to 0 as this is the first revision for the updated version. Now download the source code of the latest version of the port and find its checksums with the following command:

sudo port -d checksum <portname>

Copy the checksums (rmd160 and sha256) that are printed out for the for the latest version and paste them into place over the old checksums in the Portfile. Similarly, if the Portfile contains a livecheck.md5 entry, fetch this for the latest version and propagate it into the Portfile:

sudo port -d livecheck <portname>

You can now compile and install the latest version on your local machine by:

sudo port -d install <portname>

If the compile is successful and the updated software functions correctly, you can then file an update. First create a diff file for the changes to the Portfile:

diff -u Portfile.orig Portfile | sudo tee <portname>.diff

Now make a new ticket at http://trac.macports.org/. Give the ticket a title like:

<portname> @<current_version>: update to <latest_version>

CC in the email address coupled to the port which you identified at the beginning of this process. Attach the .diff file. All being well one of the MacPorts team will use your patch and update the port to the latest version on the MacPorts server within a few days.

Notes

This post was based on the instructions in the MacPorts howto/Upgrade guide: https://trac.macports.org/wiki/howto/Upgrade