0

I am writing a spec file which creates multiple packages. Can I use a for loop over %files directive with different names, like this:

for name in {package1, package2, package3} ; do
  %files -n $name
  %attr(644, root, root) /etc/systemd/system/$name.service
done
TomTom
  • 141
  • 1
  • 4

3 Answers3

2

In long words due to minimal post length restriction: No.

Spec files are not any form of scripting language.

Sven
  • 98,649
  • 14
  • 180
  • 226
1

Spec file is not scripting language, you still can use your own script file to create file list and feed the list to spec file. From document "Directives For the %files list":

-f <file> — Read the %files List From <file>

The -f option is used to direct RPM to read the %files list from the named file. Like the %files list in a spec file, the file named using the -f option should contain one filename per line and also include any of the directives named in this section.

%files latex -f tetex-latex-skel

Here, the filenames present in the file tetex-latex-skel would be packaged.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
0
%{expand:%(/bin/bash -c "for name in package1 package2 package3; do
cat <<EOF
%files -n \$name
%attr(644, root, root) /etc/systemd/system/\$name.service
EOF
done")}
Ming Wang
  • 1
  • 1