Ubuntu – Downgrade a bunch of packages

aptpackage-management

Maybe you have installed packages from a PPA or an external source (e.g. downloaded a .deb for a package that is available through the Ubuntu repos.).
Then you decide to drop these upgraded versions in favour to the official repositories.
First step is to remove the entries of the sources.list.

Is there a way to downgrade all to the highest available version? I know you can install specific versions with

apt-get install [package]=[version]

But can you downgrade all?

Best Answer

A bit late to the party but I found this question when looking for an answer and now I have my own answer to share.

I believe you can do this via the mysterious world of apt_preferences.

Try making a file called /tmp/a_p (or whatever) like so...

Package: *
Pin: release a=*-backports
Pin-Priority: 100

Package: *
Pin: release n=*
Pin-Priority: 1001

Then run:

sudo apt-get -o Dir::Etc::Preferences=/tmp/a_p dist-upgrade

The second section of the file basically does what the OP requested, in that it bumps the priority of all packages in any live repository to make them install even if it means a downgrade.

The first section prevents the second section from triggering the installation of all backports. You may or may not care about or want this. I'd suggest tinkering to see what works. You can use apt-cache -o Dir::Etc::Preferences=/tmp/a_p policy somepkg to see what effect the a_p file is having on specific packages.

TIM