您不能像在 ~/.rpmmacros 文件中那样在规范文件中真正制作多行宏。有点傻。
我创建了一个子目录 SPECS/inc/ ,其中包含作为多行宏的规范文件,为我的站点创建的所有包都使用这些宏。%foo您可以不使用宏作为,而只需执行%include inc/foo.spec. 您还可以创建快捷方式来避免包含语法%global foo %include inc/foo.spec。然后它就像一个多行宏一样工作。
这是一个完整的例子。
公司/环境规范
%global foo %include inc/foo.spec
%global bar %include inc/bar.spec
#Lots of other common things to all packages
Run Code Online (Sandbox Code Playgroud)
公司/foo.spec
a
b
c
d
Run Code Online (Sandbox Code Playgroud)
然后在我的包规范文件中,mylib.spec:
%include inc/env.spec
Name: mylib
Version: X.Y
#etc...
%foo
Run Code Online (Sandbox Code Playgroud)
第一行至少必须有部分值,即:
%define LIST a\
b\
c
Run Code Online (Sandbox Code Playgroud)
这个宏定义就可以工作了。如果您打算将它们用作命令,即类似
%define DOSOMETHING rm file1\
rm file2\
rm file3
...
%build
%DOSOMETHING
Run Code Online (Sandbox Code Playgroud)
这是行不通的。可执行部分中的行首先被分成单独的命令,然后宏被扩展。即定义宏将起作用,但将其作为三个单独的命令执行则不起作用。
如果你想执行3个单独的命令,这样做更容易
%define DOSOMETHING rm file1; rm file2; rm file3
Run Code Online (Sandbox Code Playgroud)