For the underlying issue, there maybe two additional solutions that are present in all rpm versions that I am aware of.
- Subpackages
macro
and rpmrc
files.
Subpackages
Another alternative (and perhaps the "RPM way") is to use sub-packages. Maximum RPM also has information and examples of subpackages.
I think the question is trying to structure something like,
- two spec files; say rpm_debug.spec and rpm_production.spec
- both use
%include common.spec
debug and production could also be client and server, etc. For the examples of redefining a variable, each subpackage can have it's own list of variables.
Limitations
The main advantage of subpackages is that only one build takes place; This may also be a disadvantage. The debug and production example may highlight this. That can be worked around using strip
to create variants or compiling twice with different output; perhaps using VPATH
with Gnu Make). Having to compile large packages and then only have simple variations, like with/without developer info, like headers
, static libraries, etc. can make you appreciate this approach.
Macros and Rpmrc
Subpackages don't solve the problem of structural defines that you wish for an entire rootfs hierarchy, or larger collection of RPMs. We have rpmbuild --showrc
for this. You can have a large amount of variables and macros defined by altering rpmrc
and macros
when you run rpm
and rpmbuild
. From the man
page,
rpmrc Configuration
/usr/lib/rpm/rpmrc
/usr/lib/rpm/redhat/rpmrc
/etc/rpmrc
~/.rpmrc
Macro Configuration
/usr/lib/rpm/macros
/usr/lib/rpm/redhat/macros
/etc/rpm/macros
~/.rpmmacros
I think these two features can solve all the problems that %include
can. However, %include
is a familiar concept and was probably added to make rpm more full-featured and developer friendly.