Search code examples
rpmyumobsolete

Can yum be forced to uninstall an obsolete package before installing the new package?


The use case is this:

I have PkgA which is already installed.

Now I created PkgB which obsoletes PkgA.

In this case: yum install PkgB will do the following operations:

  1. install PkgB
  2. uninstall PkgA

The problem is that in PkgA has a bug, and it when uninstalling removes a folder which contains files installed by PkgB. I cannot change the location of this file because they are needed for backwards compatibility.

Is there a way in which I could force yum to first uninstall PkgA and then install PkgB?

I am using CentOS Linux release 7.2.1511 (Core)

Yum and RPM versions:

# yum --version

3.4.3

Installed: rpm-4.11.3-17.el7.x86_64 at 2017-06-12 21:14

Installed: yum-3.4.3-132.el7.centos.0.1.noarch at 2017-06-12 21:14

Installed: yum-plugin-fastestmirror-1.1.31-34.el7.noarch at 2017-06-12 21:14


Solution

  • This should work. But I did not tried:

    yum swap -- remove pkgA -- install pkgB
    

    Otherwise just

    rpm -e --nodeps pkgA && yum install pkgdB
    

    If there is something dependent on pkgA. Otherwise you can omit the --nodeps.