RPM:在%pre小脚本加载bash脚本 [英] RPM: loading bash script in %pre scriptlet
问题描述
我已经把一些常见的实用工具脚本到 common.sh
,我想在我的RPM spec文件使用过程中%pre
。 common.sh
位于RPM包的根。
我正打算做的仅仅是调用像源common.sh
,但我怎么能访问 common.sh $ C在
%pre
?
我能解决这个使用的 RPM宏的,按以下方式:
在做之前的rpmbuild
我已经把 common.spec
到产品规格
文件夹中。
common.spec
%定义mymacro()(回声-n我arg是%1睡眠%1;回声完成)
我已经添加了%包括SPECS / common.spec
作为我的实际规范文件的第一行。
使用示例
%pre
%mymacro 5
我arg的5完成。
块引用>多行宏
pretty脆弱语法海事组织,但你可以把使用
\\
换行到您的宏。这将告诉RPM建设者应该继续解析宏。鉴于previous宏作为一个例子:%定义mymacro()(回声-n我arg为1%\\
睡眠%1; \\
回声完成。)这样,code将仍然解析回单行线,因此
;
第一和第二行I've put some common utility scripts into
common.sh
, which I want to use in my RPM specfile during%pre
.common.sh
is located in the root of the RPM package.What I was planning to do is simply call something like
source common.sh
, but how can I accesscommon.sh
from the RPM during%pre
?解决方案I was able to solve this using RPM macros, the following way:
Before doing
rpmbuild
I have putcommon.spec
into theSPECS
folder.common.spec
%define mymacro() (echo -n "My arg is %1 " ; sleep %1 ; echo done.)
I've added
%include SPECS/common.spec
as the first line of my actual spec file.Usage example
%pre %mymacro 5
My arg is 5 done.
Multi-line macros
Pretty fragile syntactically imo, but you can put line breaks into your macros using
\
. That will tell the RPM builder that it should continue parsing the macro. Given the previous macro as an example:%define mymacro() (echo -n "My arg is %1 " ; \ sleep %1 ; \ echo done.)
This way the code will be still parsed back into a single line, hence the
;
on the first and second line.这篇关于RPM:在%pre小脚本加载bash脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!