My goal is to come up with a spec file that defines subpackages dynamically.
Currently, I have a macro defined in the spec file so that I can call it with different parameters to generate different %package sections. Eg.
%define create_pkg(n:)\
%package -n subpackage-%1\
Summary: Subpackage %1\
…\
%{nil}
%create_pkg sub1
%create_pkg sub2
%create_pkg sub3
However, I can only hard-code the parameters (sub1, sub2, sub3) of the create_pkg macro in the specfile. Is there a way to make the specfile read a separate file, which would contain the names of the subpackages I want? eg. subpackages.txt would have the following:
sub1
sub2
sub3
and the spec file would read subpackages.txt and call %create_pkg with the names read from the txt file.
Answering my own question. If the rpm has lua script build-in (it’s a build time option I think), then you can use lua scripts in the file
1) define the sub packages in a separate file, eg. targets.txt:
2) include targets.txt at the beginning of the spec file:
3) use lua script to iterate through the targets in the preamble section:
then the %package directive for the sub packages will be dynamically generated.