Operating System - Linux
1848217 Members
4771 Online
104022 Solutions
New Discussion

RPM that romoves other RPM

 
SOLVED
Go to solution
Eli_pok
Frequent Advisor

RPM that romoves other RPM

How can I use the RPM command inside a %pre or %post script in a spec file in order to remove another RPM?
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: RPM that romoves other RPM

Shalom,

Better to use a tool like yum to calculate dependencies. Centos yum can be installed and used even on Red Hat 2,3,4 systems. Its standard on RHEL 5.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Matti_Kurkela
Honored Contributor

Re: RPM that romoves other RPM

Why do you want to do that?

I'm not a RPM wizard, but trying to start one rpm process inside another is going to be unable to get the RPM database lock at the very least. A different approach is required.

If you want to replace an old RPM with a new one that has a different name, you would generally set the dependencies to something like this:

Provides: OldPackage-version

where is something that is greater than any known version of OldPackage.

The end result will be that the RPM system will automatically remove the OldPackage before even starting to install your package: it will consider you new package as an "upgrade" for the OldPackage.

As it is an upgrade (and because RPM never removes any configuration files), the configuration files of the OldPackage will still be there. You can then convert them or extract whatever information you'll need out of them in the %pre or %post scripts of your new package.

If you have built other packages that require the presence of OldPackage, the next releases of them should probably have new dependency information, maybe with a "Conflicts: OldPackage < version" thrown in.

If you want to remove another RPM only if some condition is fulfilled and that condition cannot be expressed with the dependency information, the problem is much trickier.

MK
MK
Eli_pok
Frequent Advisor

Re: RPM that romoves other RPM

Thanks for your replies, I'll try to explain my needs.

I'm using a central YUM repository in my organization. The repository includes a lot of RPM's including RPM's that were written by us.

When I included the Glance and OVPA RPM's into the YUM, I encountered an interesting problem.
One of Glance's dependencies is xorgs-libs, somehow YUM decided that the best way to install the xorgs libs is through an IAS RPM (which is 500 Megabytes!!!!).

What I'm trying to do now is to write a RPM that will install xorgs in his %pre and then install all the other RPM's in the requires section.
In the end I will have 1 RPM written by me and another 13 RPM's that are actually the glance and OVPA products required by my RPM.

The question is, how can I make my RPM that when it's removed it will remove the other 13 RPM's it required in its install ?
Matti_Kurkela
Honored Contributor
Solution

Re: RPM that romoves other RPM

That is not something you can do with only RPM packages.

Yum (or another package manager) would have to keep track of package installation reasons. It would need to have two classes of installed packages.

Class A would be packages installed because the sysadmin specifically requested to install them. These packages would never be removed unless the sysadmin specifically requests to remove them.

Class B would be packages installed to satisfy the dependencies of other packages. These could be removed automatically as soon as nothing depends on them any more.

Of course there must be a way to switch an installed package into another class if/when necessary. Having to uninstall & reinstall a package just because of this would be silly.

Debian's "aptitude" package manager has been doing this for a while. It has been one of the cool features of .deb packaging system, but I don't see why it could not be implemented with RPMs too. It seems to be just the fact that nobody has done the work :-(

To solve your problem now, you would need a tool that can parse the database of installed RPMs and find any packages that are not needed by any other packages (the "leaves" in a dependency tree graph, in Comp Sci terminology).

Armed with this tool and a list of packages you might like to remove (perhaps gathered from the dependency information of packages you already _did_ remove), you can solve your problem automatically.

I know there are several tools for this in various Linux distributions, but as you did not specify your distribution(s) I cannot really recommend anything. If a tool is not available in your distribution, you would have to make sure it is compatible with your RPM database version.

MK
MK
Eli_pok
Frequent Advisor

Re: RPM that romoves other RPM

I'm using RedHat 4.4 (going into 5.3 soon).