RPM Community Forums

Mailing List Message of <rpm-users>

Re: Where to put distrubtion-specific macros

From: Jeff Johnson <n3npq.jbj@gmail.com>
Date: Tue 14 Oct 2008 - 17:34:35 CEST
Message-Id: <8804C0B8-6E15-4DB7-A0FA-6B83594EE45B@mac.com>

On Oct 14, 2008, at 11:19 AM, Eric MSP Veith wrote:

> Hash: SHA1
> Hello list,
> while switching from rpm-4.4.x to rpm-5.1.x I'm also giving my  
> build system
> a complete revamp. While doing this, I'd like to integrate alot of  
> extra
> functionality used by my specs into the standard macro collection  
> hat comes
> with installing rpm-build, e. g. %{__find} or %{__fakeroot}.
> One way would be patching the source for /usr/lib/rpm/macros. While  
> this is
> possible, I'd like to ask before doing this whether there is a more  
> elegant
> way on defining and shipping my own macros?

There's lots of ways to change where macros are loaded from, too many  
in fact ;-)

One quick and easy way to design your paths to macros files is to
use the --macros option. The --macro option argument is a colon
separated set of paths to attempt to load macros from. One can
also include macros within the paths, the only gotcha is that you need
to ensure that macros you use are defined before expanding; otherwise  
will get literally the macro name, not its expanded value,  
substituted into
the path. But %{_target_cpu} is always defined, and is the commonest
usage case having per-arch macros.

E.g. here's the ~/bin/xxxrpm wrapper to rpm that I use daily,  
it just inserts a different set of paths from which to load macros:


case  in
-t*|-b*)        rpm=/usr/bin/rpmbuild;;
*)      rpm=/usr/bin/rpm;;

exec  --macros  

You can also compile a different set of paths to load macros from
if you configure with
   --with-path-macros=ARG  build with colon-separated RPM macro files  
A number of other paths can be changed by configure, see
     ./configure --help
for the goop.

The only rule for the colon separated list is that the first path  
*must* exist.
Usually /usr/lib/rpm/macros is the 1st element in the list.

BTW, there's also a
macro primitive that can be added to your spec files to specifically
load a pre-defined custom set of macros when building.


73 de Jeff
Received on Tue Oct 14 18:41:34 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.