env variable is not defined when running rpmbuild --rebuild

"Erez Zilber" <[email protected]> Mon, 11 Aug 2008 10:46:23 +0300
Newsgroups gmane.linux.redhat.rpm.general
Message-ID <[email protected]>
Hi,

I have a problem with an env variable while running rpmbuild --rebuild
/usr/src/redhat/SRPMS/mypackage-0-0.1.src.rpm:

before running rpmbuild, I run the following commands:

[erez.zilber@klab002:~/work/]$ sudo bash -c 'export MY_ENV_VAR=some_val'
[erez.zilber@klab002:~/work/]$ sudo echo $MY_ENV_VAR
some_val

In the spec file, I print this env var:

%build
echo "MY_ENV_VAR = $MY_ENV_VAR"

but when I run rpmbuild --rebuild
/usr/src/redhat/SRPMS/mypackage-0-0.1.src.rpm, I get:

+ LANG=C
+ export LANG
+ unset DISPLAY
+ echo 'MY_ENV_VAR = '
MY_ENV_VAR =

I guess that it opens another shell in which the env var is not
defined. How can I solve that (without adding the env var to .bashrc
which is not a possible solution for me).

Thanks,
Erez