Is there any syntax or trick to be able to create a multi-line macro of the rpm specification file

Background.

$ rpmbuild --version
RPM version 4.3.3

I am working on a specification file that should handle a list of files in several scenarios. DRY (don’t repeat it yourself), I define the list once as a macro that expands into various helper scripts. Maintaining a list is a pain because I have not seen a way to avoid placing all the files on the same line.

% define LIST \
a \
b 

gives an error

% define LIST a \
b \

also gives an error

% define LIST a
% define LIST% LIST b

Failed to execute recursion error

+3
source share
6

, . spec:

Source1:        flist

%{expand:%global LIST %(cat %{SOURCE1})}

Source1 ( flist):

a \
b \
c 

rpm 4.4.6, , .

+2

RPM, . ( make). , script, . , , 3 . , , , , rpmbuild, . , , , . !

+1

, ~/.rpmmacros. .

SPECS/inc/ spec, , , . %foo %include inc/foo.spec. , include %global foo %include inc/foo.spec. , .

.

/env.spec

%global foo %include inc/foo.spec
%global bar %include inc/bar.spec
#Lots of other common things to all packages

/foo.spec

a
b
c
d

mylib.spec:

%include inc/env.spec

Name: mylib
Version: X.Y
#etc...

%foo
+1

, :

%define LIST a\
b\
c

. , -

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

. , . , , .

3 , ,

%define DOSOMETHING rm file1; rm file2; rm file3
0

, .

%{_sourcedir}/LIST:

a
b
c
d

:

%define process_files() \
    for i in %(cat %{_sourcedir}/LIST)
    do \
        echo "process list of files here" \
    done
0

:

cat file.spec

%define MAKE make \\\
 status=success \\\
 #EOL

%build
${MAKE}


cat Makefile

status?=fail
default: 
    echo "status=${status}"
0

Source: https://habr.com/ru/post/1778184/


All Articles