This page looks best with JavaScript enabled

Downgrade a port in FreeBSD

 ·  🎃 kr0m

There are times when a specific version of a port has a bug or we are not interested in having it installed for some reason. In order to install a specific commit of the port, we must use the portdowngrade tool, with which we will be able to see the commit history and revert to one of them.

In this example, we are going to downgrade Nginx. First, we start the configuration to check which version would be installed:

portsnap fetch update
cd /usr/ports/www/nginx
make config
nginx-1.18.0_12,2

We press Ctrl+c since we are not going to install this version.

We install portdowngrade:

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

We can search by the generic name to later specify the exact name of the port:

portdowngrade nginx
modsecurity3-nginx-1.0.1_1 -> security/modsecurity3-nginx
py37-certbot-nginx-1.4.0 -> security/py-certbot-nginx
py27-certbot-nginx-1.4.0 -> security/py-certbot-nginx
nginx-1.18.0_12,2 -> www/nginx
nginx-devel-1.19.0_4 -> www/nginx-devel
nginx-full-1.18.0_4,2 -> www/nginx-full
nginx-lite-1.18.0_12,2 -> www/nginx-lite
nginx-naxsi-1.18.0_12,2 -> www/nginx-naxsi
nginx-prometheus-exporter-0.6.0 -> www/nginx-prometheus-exporter
nginx-ultimate-bad-bot-blocker-4.2020.03.2005_1 -> www/nginx-ultimate-bad-bot-blocker
nginx-vts-exporter-0.10.3 -> www/nginx-vts-exporter
rubygem-passenger-nginx-6.0.5 -> www/rubygem-passenger

Choose a port origin (directory) from the list
above, and then run portdowngrade category/portcd /usr/ports/www/nginx

We consult the commits of the port using its exact name:

portdowngrade www/nginx

NOTE: We can check the same commit information at https://www.freshports.org/www/nginx

We choose the commit we want to revert and execute:

cd
portdowngrade www/nginx COMMITID

If we choose this one from 2019:

r517054 | tobik | 2019-11-08 13:53:37 +0100 (Fri, 08 Nov 2019) | 2 lines
portdowngrade www/nginx r517054

It will create a directory with the sources of that commit, then we configure Nginx again:

cd nginx
make config

And it will effectively configure version 1.16.1_4,2:

nginx-1.16.1_4,2

This may seem like a panacea, but it should only be used temporarily because if we go back too far, there may be incompatibilities with the rest of the system, and we will also be running a version of the software that has not received any patches since that date.

If you liked the article, you can treat me to a RedBull here