Yum rollback and repackage

Introduction –
Fedora’s package management tools — including yum, pup, and pirut — are all based on the RPM package format and management system. One little-known secret about RPM is that it can be configured to repackage files from an RPM package during package uninstallation, saving the (possibly modified) files into a new RPM package. The repackaged RPM incorporates any changes that you have made to the configuration files, scripts, and data files that were originally included with the software. This means that it’s possible to rollback the uninstallation of software, which will restore the package to the state it was in before it was removed.

The rollback mechanism can also undo package installations by uninstalling the newly-installed packages, and since a software update is a performed by installing a new package version and then removing the old one, the rollback mechanism can also undo package updates.

Open /etc/yum.conf file and put below two line

#yum rollback select enable
tsflags=repackage

or append it a simple way 🙂

[root@testbed ~]# echo “tsflags=repackage” >> /etc/yum.conf

Now create or edit /etc/rpm/macros and put “%_repackage_all_erasures 1” entry in it.

Now you can check your previous versions of python & mkinitrd, nash packages.

[root@testbed ~]# rpm -qa|grep -E ‘python|mkinitrd|nash’

The repackage/rollback approach is far from perfect — for example, data files created and used with a package (but not in files provided as part of the package) are not saved during repackaging, and some RPM scripts assume that packages are only upgraded and never downgraded. Nonetheless, package rollback can be a very useful feature, especially when an update breaks something that used to work.Repackaging can take a lot of space, so it’s disabled by default, and there is no way to enable it or to perform a rollback from the command line. Here, in a nutshell, are instructions for using this feature:

2 Replies to “Yum rollback and repackage”

Very nice guide.
Just a note:
The repackage and rollback options were removed in RPM 4.6. Apparently rollback mechanism was reintroduced in RPM 5.x.
Many machines out there use distros ,such as RHEL sever 6, which comes with RPM 4.8, which doesn’t have this feature.

If anyone knows a good alternative solution, I would love to hear from you.