RPM spec: How to erase an RPM before one is installed

1

I have an RPM called dcca-img.rpm In the spec file of above RPM, in PreReqs we have mysql-client and mysql, as a result before dcca-img.rpm is installed both are getting installed as expected.

PreReq: perl, mysql-client >= 5.5.43, libmysqlclient15 >= 5.0.96, libmysqlclient_r15 >= 5.0.96, mysql >= 5.5.43

The problem is, because of this requirement: If there is n existing and lower version of mysql installed in the machine, it should be erased, before the newer version is installed.

Now, in %pre section i can put rpm -e 'rpm -qa | grep mysql' but that won't solve, because by then the higher version would already have got installed, as %pre means before RPM dcca-img.rpm is installed not before dependencies of dcca-img.rpm gets installed.

How can i make sure, that mysql-5.5.43 is installed, only AFTER dcca-img.rpm is installed, (resulting in %post getting invoked to erase a prior version one)?

kingsmasher1

Posted 2016-07-15T11:08:09.507

Reputation: 299

AFAIK, it is impossible to control other package installation from your spec file. Only way i can think of is have wrapper script which erases lower-versioned rpm.s before installing your rpm (and the dependencies). – Fazlin – 2016-07-15T12:18:54.943

That's really unfortunate – kingsmasher1 – 2016-07-15T12:25:52.813

I would be happy to be proved wrong :) – Fazlin – 2016-07-15T12:33:23.163

No answers