Failing an RPM install programmatically in a spec step

亡梦爱人 提交于 2019-12-17 19:35:00

问题


I'm making an RPM. This particular RPM has requirements that can't be expressed as RPM prerequisites, lets call them a particular filesystem/disk configuration. Currently the failure happens after install, at runtime, when the requirements aren't met.

I can check for the required prerequisites in the %install, section of my script. However, I can't figure out how to fail the install if certain criteria are met. Is it possible to fail an rpm install at runtime via some trigger in the %install (or some other) section?

An example would look something like so, in a .spec file:

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

回答1:


It turns out that if you exit in the %pre stage the rpm install will fail.

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

Reference: https://fedoraproject.org/wiki/Packaging:ScriptletSnippets




回答2:


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


来源:https://stackoverflow.com/questions/4037410/failing-an-rpm-install-programmatically-in-a-spec-step

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!