can an RPM spec file "include" other files?

davka picture davka · May 26, 2011 · Viewed 12.8k times · Source

Is there a kind of "include" directive in RPM spec? I couldn't find an answer by googling.

Motivation: I have a RPM spec template which the build process modifies with the version, revision and other build-specific data. This is done by sed currently. I think it would be cleaner if the spec would #include a build-specific definitions file, which would be generated by the build process, so I don't need to search and replace in the spec.

If there is no include, is there an idiomatic way to do this (quite common, I believe) task?

Answer

Міша picture Міша · Jan 19, 2012

Sufficiently recent versions of rpmbuild certainly do support %include:

%include common.inc

Unfortunately, they aren't very smart about it -- there is no known set of directories, in which it will look for the requested files, for example. But it is there and variables are expanded, for example:

%include %{_topdir}/Common/common.inc