downgrade ppa packages to versions available at a previous point in time

The backstory is that the normal Intel GPU drivers don't do the various OpenGL extensions that my hobby coding and some games want. So I have to install xorg-edgers and then its happy. However, last Wednesday or so there was an update to xorg-edgers - lots of packages - and it broke badly; the drivers lock up and take the whole computer with them; hard reset required.

So how can you downgrade - select package versions in a PPA that represent a point in the past, ignoring versions newer than that?


Solution 1:

Using xorg-edgers ppa for daily work could be a pretty bad idea.

It may gives you latest drivers, true, but you can also get not working drivers.

To remove a PPA and downgrade the packages replaced by it (so going back to the ones available on the official repositories), first install ppa-purge:

sudo apt-get install ppa-purge

And then remove the PPA, downgrading gracefully to official packages:

sudo ppa-purge ppaname

This should downgrade your packages back to official ones.

Other packages that were in PPA but not in official repositories won't be uninstalled. You should manually tell the package manager to remove them, for example using apt:

sudo apt-get purge packagename

You can find the name of the ppa looking at the "Software Sources" section of Ubuntu Settings, and see a list of packages it provides on its launchpad page (or looking at the "Origin" section of Synaptic Package Manager, if installed).

Solution 2:

I had the same problem today, I noticed that ~2 weeks ago I installed updates to my system and still had ubuntu-x-swat ppa enabled which had a new nvidia driver. The old one was fine, the new one broke my system (only slightly, it took me a while to notice).

So I looked in /var/log/apt/history.log to find the previous version number of the nvidia driver package I had installed and then tried to find the package in /var/cache/apt/archives, where you'll normally find all packages downloaded by apt, but it wasn't there. And the ppa does not keep previous version of its packages around once they are superseded by a newer version so I couldn't get it from there either.

But, the diff from the previous package version to the newer is kept in the ppa for all versions, and together with the original tarball and its debian patches it is possible to reverse all changes of the newer version and get the previous version sources.

I'll briefly describe the neccessary steps:

  • Go to the ppa, find the newest package version and download the original tarball and the (optional) debian patches, in my case those were found on that page:

    https://launchpad.net/~ubuntu-x-swat/+archive/x-updates/+sourcepub/2087970/+listing-archive-extra
    

    The original tarball is named:

    nvidia-graphics-drivers_290.10.orig.tar.gz
    

    The debian patches that make a buildable package out of the tarball is:

    nvidia-graphics-drivers_290.10-0ubuntu1~lucid~xup1.diff.gz
    
  • Extract those somewhere preferably in a new and empty directory, then apply the patches to the source tree

    ~/nvidia> tar xvzf nvidia-graphics-drivers_290.10.orig.tar.gz
    [...]
    ~/nvidia> gzip -d nvidia-graphics-drivers_290.10-0ubuntu1\~lucid\~xup1.diff.gz
    ~/nvidia> patch -p0 < nvidia-graphics-drivers_290.10-0ubuntu1\~lucid\~xup1.diff
    [...]
    

    You should not get any rejected chunks when patching.

  • On the same ppa page you'll find a diff from the previous package version to the one you are looking at, under the "Available Diffs" secton.

    For me that was:

    diff from 285.05.09-0ubuntu1~lucid~xup1 to 290.10-0ubuntu1~lucid~xup1
    
  • Download that, extract and reverse apply it to the patched original sources:

    ~/nvidia> gzip -d nvidia-graphics-drivers_285.05.09-0ubuntu1\~lucid\~xup1_290.10-0ubuntu1\~lucid\~xup1.diff.gz
    ~/nvidia> patch -R -p0 < nvidia-settings_285.05.09-0ubuntu1\~lucid\~xup1_290.10-0ubuntu1\~lucid\~xup1.diff
    [...]
    
  • Presto! Now you should have the previous version source tree ready to build a package:

    ~/nvidia> mv nvidia-settings-290.10/ nvidia-settings-285.05.09
    ~/nvidia> cd nvidia-settings-285.05.09/
    ~/n/nvidia-settings-285.05.09> dpkg-buildpackage
    
  • Which should give you a the previous version package that can be installed with dpkg:

     ~/n/nvidia-settings-285.05.09> cd ..
     ~/nvidia> sudo dpkg -i nvidia-current_285.05.09-0ubuntu1\~lucid\~xup1_amd64.deb
     [...]