0

So I already know how to define macros and include these in my main spec file. However, I also want to be able to include a set of constants; something like this:

hostnames.spec

%define HOST1 host1
%define HOST2 host2
...

main.spec

%include hostnames.spec

...

checkHost %{HOST1}

Is there a way to do this with RPM?

Community
  • 1
  • 1
Daniel Szalay
  • 4,041
  • 12
  • 57
  • 103

1 Answers1

1

Perhaps you can:

  • According to More "RPM argh" or how to use %includes properly , rpm (no version mentioned) allows %include, provided that you list (and package) the included files as sources in the RPM. The blog entry goes on to mention that this complicates the include path, by making it refer to ../SOURCES (under your rpmbuild directory) rather than within the build-directory.
  • Another (can an RPM spec file “include” other files?) asserts that "Sufficiently recent versions of rpmbuild certainly do support %include", and reiterates the problem about the include-directories.
  • "Sufficiently recent" might be not a problem, since the feature is mentioned in a 2002 report about RPM 3.0.6 (Two issues related to %if and %include).
Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • Thanks! Based on the "RPM argh" article, I've figured out that in our production environment which has rpm 4.8.0 bundled, you have to move your spec file to `SOURCES` and also have to list it as a source file in order to get the `%include` directive working. I actually used `%include` in `%pre`, this way the macros are available in `%post` and `%preun` too. With 4.11.0 I just had to use `%include` "C-style" on the first line of the spec file and It was enough to have the file in `SPECS` without listing it as source. – Daniel Szalay Jul 27 '15 at 15:22