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

时间:2010-10-27 20:28:46

标签: fedora rpm

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

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

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

%install
if [ -f /some/file ]
then
    FAIL_RPM_INSTALL ## What is this command?
fi

2 个答案:

答案 0 :(得分:17)

事实证明,如果退出%pre阶段,rpm安装将失败。

%pre
if [ -f /some/file ]
then
    echo "/some/file exists, it shouldn't"
    exit 1
fi

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

答案 1 :(得分:2)

%pre
df /data|awk 'END{if ($2 < 10000000) exit 1;}'; 
if [ $? == 1 ]; 
    then echo ERROR not enough space;exit 1;
fi
相关问题