Automatically remove a %preun broken RPM

rpmyum

We have an error in the %preun script of an RPM we distributed in the past. This has been corrected, but, now, upgrading to the newer version is failing because the previous version is not deinstalling cleanly:

Error in PREUN scriptlet in rpm package perl-perfSONAR-OPPD-MP-server
/var/tmp/rpm-tmp.veW9Jb: line 5: syntax error: unexpected end of file
error: %preun(perl-perfSONAR-OPPD-MP-server-3.4-1.pSPS.noarch) scriptlet
failed, exit status 2

This can be solved by uninstalling the outdated package manually without executing the %preun part and then reinstalling the new one:

rpm -e --nopreun perl-perfSONAR-OPPD-MP-server-3.4-1.pSPS.noarch
rpm -i --replacepkgs perl-perfSONAR-OPPD-MP-server-3.5-0.0.a1.pSPS.noarch.rpm

This is a manual procedure that requires intervention of the system administrator which we'd like to avoid.

Do someone know a way to do the same through yum so that the previous package is removed for the new one to get installed without errors, all that with a single yum command or through yum automatic upgrades?

We're using CentOS 6, if that matters.

Best Answer

There is no known way to automate yum upgrades with buggy scripts: yum doesn't parse nor pass the necessary disablers to rpm lib.