Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm creating an RPM package (let's call it Foo) that contains a gpg key that will be used to sign other RPMs. During the postinstall script for Foo, I execute 'rpm --import [keyfile]' to import the key into the RPM system. That works fine.

In an effort to clean up after myself, I would like to undo this import when Foo is uninstalled. I see from other forums that a way to undo the import is to do "rpm -e gpg-pubkey-[keyid]". However, when I try to do that in the Foo's postuninstall script, the RPM uninstall hangs because the rpm command to remove the key cannot grab the transaction lock (since it's already in use to remove Foo).

So... is there a way for me to cleanly remove that gpg key when the original Foo RPM package is removed?

share|improve this question

1 Answer 1

Yes the transaction lock will prevent rpm -e.

You can rename the lock (it's in /var/lib/rpm) in %preun, then erase the gpg-pubkey, and then rename the lock back into place. Renaming has the advantage of being a KISS and expedient hack and will "work".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.