在规范步骤中以编程方式失败RPM安装

Pau*_*bel 11 fedora rpm

我正在制作RPM.此特定RPM的要求不能表示为RPM先决条件,我们可以将它们称为特定的文件系统/磁盘配置.目前,在安装后,在运行时,当不满足要求时,会发生故障.

我可以在我的脚本的%install部分中检查所需的先决条件.但是,如果满足某些条件,我无法弄清楚如何使安装失败.是否可以通过%install(或其他一些)部分中的某些触发器在运行时失败rpm安装?

在.spec文件中,示例看起来像这样:

%install
if [ -f /some/file ]
then
    FAIL_RPM_INSTALL ## What is this command?
fi
Run Code Online (Sandbox Code Playgroud)

Pau*_*bel 17

事实证明,如果你在%pre舞台上退出,rpm安装将失败.

%pre
if [ -f /some/file ]
then
    echo "/some/file exists, it shouldn't"
    exit 1
fi
Run Code Online (Sandbox Code Playgroud)

参考:https://fedoraproject.org/wiki/Packaging:ScriptletSnippets