Is it safe to verify the RPM that has just been installed from a %posttrans?

时间:2015-06-26 09:42:01

标签: rpm rpm-spec

I know this is non-standard, but it's intended to overcome a short term problem with a proprietary distribution. Because there are dependencies that are unique to our deployment systems, we have to compile some libraries from the %post. Because failing here could result in corruption to the RPM database, we fail silently or to put it more accurately, we fail successfully :-/

Using a %verifyscript, we are able to verify if compilation is incomplete and then exit appropriately. The idea is that we can do something like this:

rpm -Uvvvh proprietary-dist-1.0-2.i686.rpm
rpm --verify proprietary-dist || rpm -Uvvvh proprietary-dist-1.0-1.1686.rpm

Or like this:

rpm -Uvvvh proprietary-dist-1.0-2.i686.rpm
rpm --verify proprietary-dist || rpm --rollback proprietary-dist

However, making use of the %posttrans, I figured we could simplify this down to:

rpm -Uvvvh proprietary-dist-1.0-2.i686.rpm || rpm --rollback proprietary-dist

It seems to be unclear from the documentation as to whether exiting non-zero from a %posttrans is safe and won't cause RPMDB corruption - well, at least the documentation that says you shouldn't exit non-zero pre-dates when %pretrans and %posttrans were introduced.

I am assuming that %posttrans is run after the RPMDB has been updated and committed, so in effect, the RPM is considered installed. But is that a bad assumption?

1 个答案:

答案 0 :(得分:0)

是的,你正确的是在rpmdb更新后运行%posttrans(你可能使用的rpm中没有提交)。同时rpmdb仍处于打开状态,fsync(2)通常被禁用(性能)。

%posttrans中的非零最多被忽略,否则将留下需要手动“修复”的“不成功”部分安装。

YMMV。如果rpm使用%posttrans中断,则可以保留所有部分。