如果SPEC文件脚本的%pre部分返回false,如何回滚RPM安装

时间:2016-08-05 12:26:20

标签: rpm rpmbuild rpm-spec

我是RPM建设的新手。我必须构建RPM,只有在目标机器上存在文件/ etc / i-am-a-requirement时才会安装软件包。所以我写了

%pre
if test -f "/etc/i-am-a-requirement"; then 
echo "I'm OK to continue"
else
echo "The file is not found, the RPM won't be installed"
-- How to add failure here? --
fi

我知道通常我们希望RPM具有依赖包,但在这种情况下,“/ etc / i-am-a-requirement”以二进制形式分发,因此它根本没有包。

1 个答案:

答案 0 :(得分:1)

%pre%post和其他脚本无法停止rpm的安装。一旦进入scriptlets;安装将继续执行scriptlet的退出代码。

您应该使用需要:

Requires: /etc/i-am-a-requirement
相关问题