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

发布于 2024-09-29 05:33:00 字数 338 浏览 1 评论 0原文

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

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

.spec 文件中的示例如下所示:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

離殇 2024-10-06 05:33:00

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

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

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

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

短暂陪伴 2024-10-06 05:33:00
%pre
df /data|awk 'END{if ($2 < 10000000) exit 1;}'; 
if [ $? == 1 ]; 
    then echo ERROR not enough space;exit 1;
fi
%pre
df /data|awk 'END{if ($2 < 10000000) exit 1;}'; 
if [ $? == 1 ]; 
    then echo ERROR not enough space;exit 1;
fi
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文