How to exit rpm install in case of an error

这一生的挚爱 提交于 2019-12-01 04:23:00

问题


I am looking for a way to exit rpm install if some condition is false. I have added a small script in the %pre section that exits install if my condition fails.

The problem I am facing is I see that the %pre scriptlet is executed, and rpm install does fail. Yet at the end of it I get these 2 lines which I don't want -- Installed ... followed by Complete!

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!

回答1:


If you need this just to make sure there is certain file in the filesystem, you can do simple

Requires: /path/to/expected/file

Otherwise you are indeed out of luck probably.

I could think of extremely ugly solution that would involve killing rpm from within scriptlet, but that is beyond evil :-)




回答2:


Did you try to use Verification Scripts? Writing Verification Scripts



来源:https://stackoverflow.com/questions/9932562/how-to-exit-rpm-install-in-case-of-an-error

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