rpmbuild is not reading macros from rpmrc file

744 views Asked by At

I am trying to build a code on SLES-15 and in Makefile it executes rpmbuild command as below.

rpmbuild -ba --rcfile $(BUILDROOT)/scripts/rpmrc --rmsource --target $(RPM_TARGET_ARCH) $(DEBUG_OPTION) $(RPMDIR)/SPECS/$(SPECFILE)

rpmrc file has below contents:

macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/%{_target}/macros:/usr/lib/rpm/redhat/macros:/etc/rpm/macros.specspo:/etc/rpm/macros.cdb:/etc/rpm/macros.prelink:/etc/rpm/macros.solve:/etc/rpm/macros.up2date:/etc/rpm/macros:/etc/rpm/%{_target}/macros:~/.rpmmacros:/home/build/builds/Sourcecode/rpm/rpmmacros

the file /home/build/builds/Sourcecode/rpm/rpmmacros has definition

%_topdir /home/build/builds/code/build/Linux-i686-SLES11/Release/tools
#Override default __os_install_post macro
#Do not strip comment section of binaries as this
#causes aveserver to fail its integrity check

#XXX: Apparently, only RedHat strips in post install by default
#so explicitly strip everything

%__os_install_post
/usr/lib/rpm/brp-compress
/usr/lib/rpm/brp-strip
/usr/lib/rpm/brp-strip-shared
/usr/lib/rpm/brp-strip-static-archive
%{nil}

#Enable debuginfo packages for SuSE build #XXX: This requires a working eu-strip from the elfutils package #which normally does not come with SLES %install %{debug_package}
%%install
%{nil}

But when rpmbuild command is executed It actually picks different value of ‘_topdir’ (which it reads from /usr/lib/rpm/macros) and failed with error XXX not found.

The _topdir problem was solved by adding extra macro definition to rpmbuild command (as below)

rpmbuild -ba **--define='_topdir $(RPMDIR)'** --rcfile $(BUILDROOT)/scripts/rpmrc --rmsource --target $(RPM_TARGET_ARCH) $(DEBUG_OPTION) $(RPMDIR)/SPECS/$(SPECFILE)

but later on fails with different directory not found error, which I believe is due as it not reading/picking macros from rpmrc file. Any Solution for this? Why its not reading macros from user provided macro/rpmrc files.

This code builds on SLES-11 but failes on SLES-15
RPM version on SLES-15 Version: 4.14.3 Release: 40.1
RPM version on SLES-11 Version: 4.4.2.3 Release: 37.16.37

Note: rpmbuild is picking macro definition from /usr/lib/rpm/suse/macros and /usr/lib/rpm/macros. Also, /usr/lib/rpm/suse/macros overrides the definition from /usr/lib/rpm/macros. For eg if '%_XXX' is defined in both files /usr/lib/rpm/macros and /usr/lib/rpm/suse/macros, then rpmbuild picks value of %_XXX from /usr/lib/rpm/suse/macros.

1

There are 1 answers

0
Rakesh Mehta On

RPM stops supporting macrofiles reading from rcfile from v4.6 onwards. The solution is to copy rpmmacros files to ~/.rpmmacros. Other solution was to provide macros file list separated with ":" with --macros= from rpmbuild.