Rollback a package installation under openSUSE

Even if the 99,9% of times all the applications released through the official repositories are reliable and perfectly working, sometime a buggy package might get installed on our systems after an update. With a few steps we can rollback to the previous version taking advantage of the feature made available by package managers and repositories.

Chromium, the guilty

The procedure is focused on the recent Chromium failure which, for two contiguous releases of the 83th version, (83.0.4103.97 and 83.0.4103.106) decided to crash every time a page with embedded videos was opened, making the browser practically unusable.

I have to mention that the latest version released when I am writing this article, the number 83.0.4103.116, is perfect and flawless working, nonetheless these instructions might be interesting for further references.

Chromium 83 crashing with a Youtube page

Chromium 83 crashing with a Youtube page

After some minute spent to understand whether or not any further action, like cleaning the cache, restarting the system and so on… might help, I decided to revert the last package update and switch to an older version.

Package managers to the rescue

Thanks to openSUSE we can rely on our favorite package manager, YaST software manager or zypper, to rollback to a specific version with ease.

The only condition is that the remote repository can provide more than the latest available package, or an alternative might be enabling the --keep-packages option for the repository itself and build a local cache.

This option is disabled by default and to know whether or not enable it we must query each repository for a package, looking for the availability of an alternative version. Generally speaking, the standard repositories have a remote cache, while Packman and OBS repositories don’t.

Of course to work properly the local cache has to be enabled long before we get a buggy update.

The installed packages will be stored under the /var/cache/zypp/packages path and to free that space from time to time, the clean command comes in handy:

$ sudo zypper clean

Otherwise with a fine intervention we might delete only the oldest packages.

Last but not least, to avoid that the buggy version is restored with the next update we have to apply a lock on the package itself. We will be responsible to check from time to time for a new version released, unlock it, update it, check it, and rollback again if the bug still persists.

Rollback with YaST

YaST software manager provides a really easy to use interface to achieve all the most important operations.

To rollback a package the only thing we have to do is search the package name and look for the alternative version under the Versions tab.

Package rollback through YaST software manager

Package rollback through YaST software manager

Selecting it and confirming the choice with the Accept button does the trick.

To lock the package to a specific version we have to right-click on it and select the padlock symbol from the contextual menu, or just press the asterisk char *, clicking on the Accept button will confirm the changes.

Locking a package through YaST software manager

Locking a package through YaST software manager

Selecting the Update option from the same contextual menu, or pressing the + key, and confirming the choice with the Accept button will unlock the package, so this action will be performed automatically when we decide to update the package again.

Rollback with zypper

Using the command line requires some more step, first of all, we need the repository name of the package:

$ zypper info chromium

Package info with zypper

Package info with zypper

Then we look for all the packages in that repository among the installed, and with the grep command we filter only those related to Chromium

$ zypper packages -ir openSUSE_Leap_15.1_Update | grep chromium | head -n 15

List of all the available version of Chromium with zypper

List of all the available version of Chromium with zypper

Once detected the previous version we can proceed installing it:

$ sudo zypper in --oldpackage chromium-81.0.4044.138

Then we add the lock:

$ sudo zypper addlock chromium

And to remove it:

$ sudo zypper removelock chromium

Rollback with my custom script

Being a lazy guy but loving also typing in the terminal I have developed a script to automatize all these instruction into a single command.

I guess it will be rarely used but has been too fun to write involving the use of dialog command:

$ package_rollback -l -r chromium

The few options are:

-l
will apply a lock to the package
-L
to unlock the package
-r
allows to rollback the package to a different version
-R
refresh the repositories

Without options it just prints some information about the package and the available versions.

If you are interested to see that script published just comment in the section below, I will try to pack it as soon as I can.

Final thoughts

Applications get day by day more complex and sophisticated, and bugs even more difficult to discover although the number of bug hunters working for that purpose. That’s why an experienced Linux distro as openSUSE provides the right tools to quickly overcome the related problems with a couple of clicks or typing some commands in the terminal.


License

Creative Commons License This work is licensed under a Creative Commons Attribution-NoCommercial-ShareAlike 4.0 International License

Share to


Comments