Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any syntax or trick to be able to create a multiline rpm spec file macro

Background.

$ rpmbuild --version
RPM version 4.3.3

I am working on a spec file that needs to process a list of files in multiple scriptlets. DRY (don't repeat youself) has me defining the list once as a macro which is expanded into the various helper scripts. Maintaining the list is a pain since I haven't seen a way to avoid putting all the files on the same line.

%define LIST \
a \
b 

gives an error

%define LIST a\
b\

gives an error as well

%define LIST a
%define LIST %LIST b

Fails due to a recursion error

like image 426
Chaim Geretz Avatar asked Dec 02 '10 20:12

Chaim Geretz


1 Answers

You have to have at least some part of the value on the first line, i.e.:

%define LIST a\
b\
c

This macro definition will work. If you plan to use these as commands, i.e. something like

%define DOSOMETHING rm file1\
rm file2\
rm file3
...
%build
%DOSOMETHING

this will not work. The lines in executable sections are split into separate commands first, THEN the macros are expanded. I.e. defining the macro will work, executing it as three separate commands will not.

If you want to execute 3 separate commands, it's easier to do it like

%define DOSOMETHING rm file1; rm file2; rm file3
like image 118
m1tk4 Avatar answered Sep 21 '22 20:09

m1tk4