Restoring an earlier version of an application (portdowngrade)

Why would you want to downgrade an installed application to an older version? The most common reason is that after upgrading an application, you find that the new version is not all it's cracked up to be, or more likely that the new version has a few bugs in it that make it less than enjoyable to use. Never fear, there is a tool that will allow you to revert to the previous (or several versions earlier if you like) version of your application.

First things first. Check here for a list of anonymous CVS servers.

Find a server in your region. We're going to set portdowngrade to always use this server when we install it so we don't have to type in a server every time we run portdowngrade. In this example, we'll use the server freebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs, which is in the USA.

To install portdowngrade:

cd /usr/ports/sysutils/portdowngrade
make DEFAULT_CVS_SERVER=\freebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs install clean

portdowngrade's usage is fairly straightforward, but because you will be prompted several times in the course of downgrading an application, I'll walk through downgrading qemu (as an example) with you:

portdowngrade qemu

Where qemu is the name of the application you want to downgrade. After executing this command, you should see something like this:

fongsaiyuk# portdowngrade qemu
 
portdowngrade 0.6 by Heiner Eichmann
Please note, that nothing is changed in the ports tree
unless it is explicitly permitted in step 6!
 
Seeking port qemu ... found: emulators/qemu
 
Step 1: Checking out port from CVS repository
CVS root directory: freebsdanoncvs@anoncvs.freebsd.org:/home/ncvs
The authenticity of host 'anoncvs.freebsd.org (128.46.156.46)' can't be established.
DSA key fingerprint is 52:02:38:1a:2f:a8:71:d3:f5:83:93:8d:aa:00:6f:65.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'anoncvs.freebsd.org' (DSA) to the list of known hosts.

Because this was our first time connecting to this server with portdowngrade, note the ssh warning we received about the authenticity of our host. When asked "Are you sure you want to continue connecting (yes/no)?", type "yes" and hit 'Enter' to continue. This host is then added to our list of known hosts and we will not receive this warning in the future.

Step 2: Reading the port history from the CVS repository
 
Step 3: Analyzing the port history from the CVS repository
 
Step 4: Load port version numbers and present results
Keys: : next page                      d : details
            p : previous page
       : leave presentation and downdgrade if wanted
===============================================================================
number         date         portversion  comment
    1  2006/05/19 08:17:54  0.8.1_1      Fix plist
    2  2006/05/06 16:15:41  0.8.1        Update to 0.8.1.
    3  2006/04/29 09:15:49  0.8.0s.20060426  - Update to 2006-04-26 snapshot
    4  2006/04/23 17:33:29  0.8.0s.20060414_0  Fix build on 4.x
    5  2006/04/16 02:38:01  0.8.0s.20060414_0  Update to 2006-04-14 snapshot.
    6  2006/04/09 17:09:42  0.8.0s.20060408_0 Update to 2006-04-08 snapshot.
    7  2006/03/26 15:11:36  0.8.0_5      - Lonnie sent me updates to 2 of his u
    8  2006/03/18 21:23:42  0.8.0_4      - Add Lonnie's usb host support patche
    9  2006/01/21 23:41:48  0.8.0_3      (WITH_HACKS) Patching process should b
   10  2006/01/21 23:10:06  0.8.0_3      Add another hack:
   11  2006/01/05 22:21:13  0.8.0_3      two additional slirp patches for emula
   12  2005/12/31 00:12:20  0.8.0_2      Add a knob WITH_HACKS. we now have IDE
   13  2005/12/21 23:46:30  0.8.0_2      - Fix patch from previous revision
   14  2005/12/21 22:12:45  0.8.0_1      - add slirp speedup patch by Paul Broo
   15  2005/12/20 23:27:46  0.8.0        - Update to 0.8.0
   16  2005/12/03 03:18:40  0.7.2s.20051130  Update to 2005-11-30 snapshot.
   17  2005/11/16 01:32:56  0.7.2s.20051112_0  Fix build on amd64
Total lines: 56. Command:

portdowngrade displays a list of previous versions (along with the current version, listed as # 1) of qemu, along with the beginning of the Port maintainer's comments for each. (You can read the full comments at FreshPorts under "Commit History", searching for the application you're running portdowngrade on).

Lastly, we are confronted with a prompt stating "Command:". At this prompt, type 'Enter', and you will be confronted with this additional prompt:

Enter version number to change port to (0: exit): 15

On the list of previous versions for qemu, we were given 17 choices. Note that I chose # 15, which is version 0.8.0, qemu as it was on 20 December 2005. I chose this for purely demonstrative purposes--you would rarely if ever want to downgrade that many versions!

portdowngrade then displays the following messages, after which time it gives us a last chance to cancel:

Step 5: Checking out choosen date of the port from the CVS repository
 
Step 6: Modifying the port
Port: emulators/qemu
at : 2005/12/20 23:27:46
Type 'yes' to bring the port to the state of the date above
or 'no' to exit without changing anything. Note, that this only changes
the port, not the installed software! yes or no:yes

At this last prompt, asking me if I'm sure I want to downgrade, I typed "yes" and hit 'Enter'. You will then receive this final confirmation:

The port has been set to the selected version. Install it if you wish. If you have portupgrade installed, you should run
 
portsdb -Uu
 
now, to see the changes in the ports database. In any case
 
portupgrade -f qemu
 
will install the changed port. Note: if you run cvsup, the port
is changed back to the choosen label!

We have now set the Port information for qemu back to version 0.8.0, but nothing has actually been installed. If we decided that we did not want to downgrade qemu after all, we could simply perform a cvsup to update our Ports tree and qemu's information would be restored to the current version. If you want to go through with the downgrade, type:

portupgrade -f qemu

Note the -f flag. This is crucial. If you just type portupgrade qemu, you will receive an error message about the current version installed on the system being more up-to-date than the Port version, and the downgrade will be canceled. By specifying the -f flag, we are forcing portupgrade to "upgrade" qemu to the version specified even though this version is older than the version currently installed (i.e. we're downgrading qemu to an older version).

Hopefully this page has proved useful.