RPM Community Forums

Mailing List Message of <rpm-devel>

Re: [CVS] RPM: rpm/ CHANGES rpm/rpmio/ macro.c

From: Ralf S. Engelschall <rse+rpm-devel@rpm5.org>
Date: Fri 25 Jan 2008 - 23:34:18 CET
Message-ID: <20080125223418.GA93210@engelschall.com>
On Fri, Jan 25, 2008, Jeff Johnson wrote:

> Nothing wrong with the patch at all, but ...
>
> It does impose certain difficult (for packagers) issues
> wrto when the macro probe is expanded. This is
> the obvious failure case
>     %build
>      export CC=someothercc
>      CC="%{getenv:CC}"
> which will probe rpmbuild's, not the %build, environment surprisingly.
>
> *shrug*

Hmmm... well, yes, but for getting the $CC from %build I still would
just write $CC in the script, of course.

The %{getenv:CC} is not intended (at least not from my perspective) for
use in .spec's sections. I intend it to use in "rpmmacros" files to
really fetch information from the outer environment. To illustrate it:
In OpenPKG since many years I used...

%_buildshell             env -i [...]
%___build_pre            [...] \
                         TERM="%(echo $TERM)"\
                         USER="%(echo $USER)"\
                         LOGNAME="%(echo $LOGNAME)"\
                         [...]

...to provide a "sane build environment". This now can become...

%_buildshell             env -i [...]
%___build_pre            [...] \
                         TERM="%{getenv:$TERM}"\
                         USER="%{getenv:$USER}"\
                         LOGNAME="%{getenv:$LOGNAME}"\
                         [...]

...which now completely avoids spawning the shell just to expand the
environment variables.

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com
Received on Mon Jan 28 21:37:32 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.