[Rpm-ecosystem] Trying to understand %buildsubdir and debuginfo generation

Jason L Tibbitts III tibbs at math.uh.edu
Thu Apr 26 18:48:46 UTC 2018


A question came up in the Fedora Packaging Committee: Why is a %build
section required for debuginfo packages to be generated.

We were looking into the R packaging guidelines.  R modules are built
and installed in one step which cannot be split, so in Fedora everything
is just done in the %install step and the %build section is empty.
%prep is present as usual and has a normal call to %setup.  But for some
reason %build must be present, or debuginfo packages aren't generated.

Looking at the macros, everything related to debuginfo packages is hung
off of a redefinition of the %install macro:

%install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
%%install\
%{nil}
(from the redhat-rpm-config macros file)

Obviously %_enable_debug_packages and %buildsubdir must be defined for
this to happen, and %_enable_debug_packages is set to 1 in the same
macros file, so it must be that %buildsubdir is not getting defined.
And that implies that somehow %buildsubdir gets set when %build is
parsed or processed.

But looking in the rpm source, I see only one place where that macro is
set: in the doSetupMacro function (in build/parsePrep.c):

    rpmPushMacro(spec->macros, "buildsubdir", NULL, spec->buildSubdir, rpmPushMacro(spec->RMIL_SPEC);

The stock macros file seems to agree that this is defined by %setup:

#       The sub-directory (relative to %{_builddir}) where sources are compiled.
#       This macro is set after processing %setup, either explicitly from the
#       value given to -n or the default name-version.
#
#%buildsubdir

But the package does have %prep and it does call %setup.  So obviously
I'm missing something.  Most likely I'm misunderstanding how a internal
macro like that gets set in the rpm source.  I do see in the doScript
function from build/build.c how spec->buildSubdir gets used in %build,
but I don't see anything there spec->that sets it or pushes that value
into a macro definition.

Could someone please enlighten me?  Thanks,

 - J<


More information about the Rpm-ecosystem mailing list