Search code examples
rpmrpmbuildrpm-spec

rpm: how to allow w/o touching the old package seamless switch between the old and new packages w/ different name


In short, I want to implement seamless switch between the old and new packages with different name. However, I want to achieve this without touching the old package's spec file. Seamless switch includes that the other packages dependent on either the new or the old packages won't have to be removed and re-installed just due to the switch.

I am about to adding, say, Y, to a Redhat-based Linux distro(s). However, there has long been a package X in the distro. They are the same set of software, having many files installed in the same location, etc. The only major difference is version. X is a relatively old and stable version. Y is almost the same version as the open source community has just released. Say, the software is Foo, and X is Foo 1.4 while Y is Foo 2.1.

As Y is an experimental version, we would like to allow users to switch back and forth between X and Y, seamlessly. In other words, as users have a few packages that depend on X or Y, we do not want the users to have to remove & re-install those packages when they switch from X to Y and from Y to X.

The problem is I would like to avoid as much as possible modifying X. I can do whatever with Y's spec file, etc.

Adding "Obsoletes: X" to Y allowed that installing Y automatically removes X without touching any other software package that depend on X or Y. I really would like to do the same for X but can't touch the spec file of X.

Adding "Conflicts: X" to Y forces the user to "remove" Y first before installing X. The thing is that when the user removes Y, all software packages dependent on X or Y are gone with Y. X is not yet installed, and Y is about to being gone. Thus, they would have neither X nor Y. This is what I want to avoid.

%P.S. I did have a similar question here: how to make an existing rpm obsolete a new rpm without modify the existing rpm's spec file

It was a couple of days ago, and I had little knowledge. I was advised that I use "Conflicts: X" in Y's spec file. Later on, I have discovered another problem that the third party packages should be removed & reinstalled when I switch back to X from Y. That made me post this new question. The answer here indeed solved my problem. The answers to my old question helped me a lot but did not completely resolve my problem.


Solution

  • As stated in https://fedoraproject.org/wiki/Packaging:Guidelines#Renaming.2FReplacing_Existing_Packages :

    Provides: oldpackagename = $provEVR
    Obsoletes: oldpackagename < $obsEVR
    

    If you want to go back to old X then you can do that using:

    yum swap package_to_remove package_to_install
    

    in your terminology:

    yum swap Y X
    

    however, if you have Y in your repo then yum upgrade will always want to upgrade to Y.

    If you want to go there and back and have precise control what you install on a machine I recommend Katello project - or Red Hat Satellite if you want support.