Search code examples
centosredhatrpmrpmbuild

RPM spec variable for (sub)package name?


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?


Solution

  • 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.