rpm - 出现错误时如何退出rpm安装

标签 rpm rpmbuild rpm-spec

如果某些条件为假,我正在寻找一种退出 rpm 安装的方法。我在 %pre 部分添加了一个小脚本,如果我的条件失败,它会退出安装。

我面临的问题是我看到 %pre scriptlet 已执行,并且 rpm 安装失败。然而,在它的最后,我得到了这 2 行我不想要的 - 已安装......然后是完成!

Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
missing file zyWhg1. exiting install..
error: %pre(tyr-3.2.1.x86_64) scriptlet failed, exit status 255
error:   install: %pre scriptlet failed (2), skipping tyr-3.2.1

Installed: tyr-3.2.1.x86_64 0:3.2.1
Complete!

最佳答案

如果你需要这样做只是为了确保文件系统中有某个文件,你可以做简单的

Requires: /path/to/expected/file

否则你可能真的不走运。

我可以想到非常丑陋的解决方案,其中涉及从 scriptlet 中杀死 rpm,但那是邪恶的:-)

关于rpm - 出现错误时如何退出rpm安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9932562/

相关文章:

linux - 找到已安装(但未打包)的文件

linux - rpm 构建 :spec file display message at client

linux - 如何动态定义子包

shell - 从编译的二进制文件创建 RPM 规范文件

rpm - 尝试签署 RPM 时出错

rpmbuild:使用 %pre 脚本中包中包含的脚本文件

linux - RPM %post 小脚本最佳实践

linux - 在 RPM 存储库中识别 RPM 包最新版本的过程是什么?

linux - 你如何指定$? rpm 文件中的选项

php - 安装 src.rpm 是否运行 %install?