2

Release 1 contains the following packages

Package A-1.0
Package B-1.0

Release 2 contains the following packages

Package A-2.0
Package B-2.0
Package C-2.0

In Release 2, Package B-1.0 was split into two packages - package B-2.0 and package C-2.0.

Now when Release 2 is installed, how do I downgrade to Release 1?

yum downgrade A B tries to install package B-1.0 which has file conflicts with package C-2.0.

yum downgrade A B C does not work because there is no older version for Package C.

Is there a single command through which it erases the new package (package C-2.0) and downgrades packages A and B?

CR7
  • 125
  • 1
  • 10
  • you say B-1.0 has file conflics with C-2.0. Doesn't yum propose you a solution to uninstall C-2.0 then? – Chris Maes Apr 26 '16 at 06:40
  • from some yum downgrade documentation: "Downgrades are tricky but in yum versions 3.2.27 and above it can do _some_ downgrades. They are not perfect and should be used with care" --> if you want to do this often, maybe look for other options than yum downgrade – Chris Maes Apr 26 '16 at 06:41
  • @ChrisMaes, Uninstalling C alone would mess it up due to inter-dependencies (in my case). So I need a single step that would uninstall C as well as downgrade A and B – CR7 Apr 28 '16 at 07:58

4 Answers4

3

If you upgraded several packages and then you want to downgrade just those two, then it cannot be done. Not using just yum (unless you use --nodeps and temporary break deps). There are high level tools like RH Satellite, which can do that.

If you upgrade just those in separate transaction then you can run:

   yum history list
   yum history undo <ID>

or

   yum history undo last

And it will rollback that transaction. I.e. in your case downgrade those packages. See man page of yum for details about history command.

msuchy
  • 5,162
  • 1
  • 14
  • 26
  • That really does the job, but we can't document this to our customers since it's more like a workaround. Yes, we're supporting downgrade!! And the customer can choose to downgrade months later also. – CR7 Apr 28 '16 at 08:01
2

It might be too late as you have already released packages A-2.0 and B-2.0, but what you should have done (and can still do if you can delete your A-2.0 and B-2.0 packages):

In spec file of A-2.0 and B-2.0 add: Requires: C

This has multiple advantages you search (and more):

  • when updating A and/or B; C will be automatically installed.
  • when uninstalling C A and B will be downgraded.

However:

  • when downgrading A and B; C will not be uninstalled.

There is an alternative which I use for my projects: I use a meta-package:

  • meta-package-1.0: Requires A-1.0, B-1.0, Conflicts C
  • meta-package-2.0: Requires A-2.0, B-2.0, C-2.0

(and I use a branch with an unstable meta-package preparing next release: meta-package: Requires A, B)

Chris Maes
  • 35,025
  • 12
  • 111
  • 136
  • Really good approach. Only reason we can't do this is because `Release 1` is already released and can't be modified now. – CR7 May 25 '16 at 04:52
2

You can use yum shell to write multiple operations before executing them all in a single transaction.

In your case, you can use the following:

yum shell
yum downgrade A B
yum remove C
run
0

you just need to use the repo that was referred while executing the earlier yum command.

yum history undo <yum_history_id> --enablerepo=<yum_repo>

RvKmR
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 10 '22 at 22:30