Downgrade a port in FreeBSD

Use ports tree to install an older version of a port


Subject

We're going to use ports to install older than latest version of a single port.

Prerequisites

  • Recent FreeBSD with ports tree installed.
  • Access to the web and a web browser.

Reasons to do this

My personal reason was to install the same version of hplip-plugin as hplip (for a HP scanner). The plugin port is not a prebuilt package installable by pkg, while hplip takes a long time to install and has multiple dependencies. Pkg version of hplip was 3.22.4, while hplip-plugin port installed version 3.22.10, which meant I couldn't use the scanner.

You might also want to do this if the newer version contains a bug.

Note that FreeBSD has a program named portdowngrade, but it currently seems out of date, as it only handles svn, while FreeBSD now uses git. This may change in the future.

Step 1: Locate the port

Go to the port directory on your machine as a root, like /usr/ports/print/hplip-plugin. Make sure to make clean this directory.

In the browser, navigate to https://github.com/freebsd/freebsd-ports and find the same directory.

Step 2: Find the wanted version

The most important files of the port are Makefile which builds it and distinfo which contains the control sum.

Open one of those files in the browser and click on History button, to see commits which changed the file. Find a commit which updated this single port to a higher version.

Step 3: Adjust the files

By inspecting the commit changes you can reproduce the older state of the port locally. Best to backup the entire directory before doing this!

It will always require changing Makefile and distinfo, and depending on the port it may also involve more files.

That's it!

You can now try compiling the port using make.

This will surely work for simple ports, but I haven't tried it on more complex ports. I don't have the comprehensive understanding of the ports system, so be prepared to dig deeper if these steps are not sufficient.


Comments? Suggestions? Send to feedback@bbrtj.eu
Published on 2023-01-02