how to set/unset env variables in spec file

Jonathan Wakely jwakely at redhat.com
Tue Sep 8 15:50:08 UTC 2015


On 08/09/15 17:29 +0200, arnaud gaboury wrote:
>I can see in your spec file you use %global. I couldn't find any entry
>in the Fedora documentation about rpmbuild.
>My issue is a variable environment one. If I source manually the two
>scripts, build goes well. When sourcing from the spec file, it fails.

As already pointed out elsewhere in the thread, you probably just need
to use 'export' i.e.

export CC=icc
export LDFLAGS='-lblah'

Bash (and traditional Bourne sh) do not export shell variables to
child processes by default, so if you just add CC=icc to the spec file
then it only sets it in the parent shell process, not in the child
processes that run configure, make, etc.

By using export you tell the shell to also set those variables in the
environment of child processes.

See "man bash" or "bash -c 'help export'" for more information.


More information about the devel mailing list