2
votes

RPM spec files have many special variables available within them. Do any of these variables expose the name of the current package being processed?

For single-package RPMs, the answer would be obvious, but a single spec can also produce multiple RPMs. Is there a variable, such as $RPM_PACKAGE_NAME, that rpmbuild automatically updates to align with the current %files or %pre or %post section?

2
not as far as I know... - Chris Maes

2 Answers

1
votes

I don't see anything obvious in the RPM source code. There does not seem to be a possibility to access the current list of defined subpackages using RPM macros, or the package header under construction, neither using RPM macros or Lua.

What we use instead is to generate the entire package stanza in Lua, using the built-in Lua interpreter. An example is in glibc.spec; search for “Array of languages” and %package langpack-]]..lang..[[. Note that the syntax highlighting in the Pagure viewer is a bit off, it is confused by this cross-language nesting.

0
votes

You cannot do that with the name. There is a macro for package name %name, but that contains only the name of the main package. However, if you really need to do this, and you are willing to do dirty hacks, you can do:

%package base
Summary: Filesystem for %{name}
Group: foo

%post base
echo %group

which will print foo. Similarly for %summary, but %group is safest because group is not used for anything useful.

Ehmm, did I mentioned that this is dirty dirty hack? What Florian suggested is definitely a more cleaner way.