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?