0
votes

While installing a rpm,if a newer version is already installed,installation halts.

How do i implement the same logic in the %postun section of the spec file ?

enter image description here

In the above illustration,i want users to be able to uninstall the latest upgrade only.

Edit in response to Chris Maes's comment

Yes this is a strange approach. But upgrading using rpm -Uvh <rpm-name> uninstalls the previous version .But we would like to allow the user to rollback to previous versions as well.

Suppose,there have been 3 consecutive upgrades,namely Upgrade A,B & C.

The user may want to uninstall C and go back to B or may be even A.

Using the rpm -U way,after upgrade C,we do not have a way to progressively downgrade from C to B and then to A. So we decided to go by this way and on each upgrade install,we will back up the files altered. During downgrades , we can simply replace the files of the previous upgrade.

However,we want to ensure that user follows the same order while uninstalling.

The approach I am using may be wrong. Please feel free to suggest alternatives.

2
wow; this is strange usage of rpms; can you be more clear about what happens exactly and what you would like to happen? How come you have several instances of the same rpm (mayur-upgrade) installed? Or do you have no version numbers? - Chris Maes
@Chris Maes : Yes we do have version numbers.In mayur-upgrade-x-y.x86_64.rpm,x is the release number and y is the version number. Will edit the question to answer your other questions - Mayur Buragohain

2 Answers

1
votes

If your update consists in a file (or bunch of files; for simplicity named upgrade.file below) I don't see the problem in the approach:

  • keep all your mayur-upgrade-x-y.rpm available in your repository
  • mayur-upgrade installs upgrade.file

now if you install mayur-upgrade-1.4; it will install upgrade.file (version 1.4). When you now force a downgrade (using zypper in -f mayur-upgrade-1-2; then the rpm file managment system will automatically remove your upgrade.file (version 1.4) and install again upgrade.file (version 1.2). So rpm does all the bookkeeping for you...

0
votes

There is upgrade/downgrade of executable and upgrade/downgrade of data. You are mixing those two together.

Of course mayur-upgrade-x-y.x86_64.rpm will know everything about anything older than x-y. So I recommend you to have only one mayur-upgrade. And if user downgrade mayur than he should call mayur-upgrade X-Y (this version can be even detected) which will upgrade/downgrade his data. And you are under control of that script, then it is up to you to code that in correct order.