本文介绍了RPM:从包括RPM宏返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个后续问题。

我试图定义一些实用功能如宏,所以后来我能%包含他们构建RPM包的时候了。比方说,我想有一个函数 testfunc(),我想用它来检查,​​如果事情是在目标系统上present。如果条件未得到满足的是,我想打破我的RPM的执行%pre 小脚本。

I am trying to define some utility functions as macros, so later I can %include them when building other RPM packages too. Let's say I want to have a function testfunc() which I want use to check if something is present on the target system. If the condition is unmet, I want to break the execution of my RPM %pre scriptlet.

事情我已经试过:

在宏定义bash函数

common.spec

%define importfunction() (testfunc() { echo "Cancelling installation!" ; exit 1 ; })

package.spec

%include SPECS/common.spec

...

%pre
%importfunction

testfunc

RPM安装的输出

testfunc:找不到命令

直接从宏观退出

common.spec

%define testfunc() (echo "Cancelling installation!" ; exit 1)

package.spec

%include SPECS/common.spec

...

%pre
%testfunc

echo "Installation still running :("

RPM安装的输出

取消安装!

安装仍在运行:(

问题是,%pre 小脚本是不是在这种情况下退出。

The problem is that the %pre scriptlet is not exiting in this case.

问题


  • 如何突破%pre 执行从我的宏碁

  • 是否有可能在%pre 从宏观返回一个值,并将其存储在一个变量?

  • How can I break the execution of %pre from my macro?
  • Is it possible to return a value from the macro and store them in a variable during %pre?

推荐答案

停止包裹的宏体在()

这是从退出<$ C $生成一个子shell和preventing,从被视为在第一种情况和preventing的退出功能C>%pre 小脚本本身在第二种情况下。

That's spawning a sub-shell and preventing the function from being seen in the first case and preventing the exit from exiting the %pre scriptlet itself in the second case.

这篇关于RPM:从包括RPM宏返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:26