Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I remove an RPM from within .spec scripts sections?

I'm building a new version of an existing .spec/rpm and I want to remove a dependency that was required by that is not anymore (previous .spec had "Requires: rpm-xyz).

So on top of removing the Requires: rpm-xyz, I added the following in the "%post" section of the .spec file:

rpm -e rpm-xyz.

When I install the generated rpm with yum, after downloading it and asked me the confirmation to processed, I get this line and it stuck there forever:

warning: waiting for transaction lock on /var/lib/rpm/__db.000

So it looks like a deadlock to me (yum calls rpm, then calls rpm from within). So I have __db.oox file in the /var/lib/rpm and I need to rebuild the rom database to removed them.

So the question is: Am I allow to call the rpm command from within a spec file? I've read on the Obsolete tags, but it does not remove rpm. What would be the best way to remove the rpm?

Thanks,

-Martin

P.S. Extra info: Yes, I need to remove old dependencies and no, no others rpm depend on it.

like image 872
Martin Avatar asked Aug 11 '11 15:08

Martin


People also ask

How do I remove RPM from dependencies?

The first “rpm -qa” lists all RPM packages and the grep finds the package you want to remove. Then you copy the entire name and run the “rpm -e –nodeps” command on that package. It will, without prompting for confirmation, remove that package but none of its dependencies.

What is RPM Scriptlet?

RPM spec files have several sections which allow packages to run code on installation and removal. These bits of code are called scriptlets and are mostly used to update the running system with information from the package.

What is Preun?

Ordering. The scriptlets in %pre and %post are respectively run before and after a package is installed. The scriptlets %preun and %postun are run before and after a package is uninstalled. The scriptlets %pretrans and %posttrans are run at start and end of a transaction.


1 Answers

No, you cannot run rpm from within a scriptlet in your .spec file (whether %post, or something else). What you can do is put a line like

Obsoletes: rpm-xyv <= VERSION

in your .spec file. Yum will then proceed to remove the other package.

See http://yum.baseurl.org/wiki/YumPackageUpdates for more advice on what to do on package renames, etc.

like image 197
Stijn Hoop Avatar answered Nov 13 '22 14:11

Stijn Hoop