Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a spec file which unpacks a library which is deployed at location which is exported in the shell.



This fails with :

error: File not found: root/rpmbuild/BUILDROOT/i386/${AXIS2_C}/bin/services/services.xml

I.e the shell variable does not get expanded. Is there any way around this ?


share|improve this question
up vote 6 down vote accepted

Unfortunately, anything defined in the shell started by the %prep, %build or %install sections isn't preserved in the build environment. You'd need to define %{AXIS2_C}, a MACRO variable (not a shell variable):

%define AXIS2_C /usr/local/something

and then refer to it in both your shells as

make whatever FOO=%{AXIS2_C} # or however you used the env variable

and then in the %files section, use


Usually, the initial %define is at the top of the spec file, with some documentation about what it is for. If you need to dynamically set the macro, you'll have to use more complex RPM spec macro commands like %() to do shell expansions.

share|improve this answer
Cheers! This got it done. %define AXISHOME %(echo ${AXIS2C_HOME}) – Ricko M Jan 31 '11 at 15:10
%file %AXISHOME/blah.xml – Ricko M Jan 31 '11 at 15:18

What happens if you do not enclosure it in { }, and only use " "


(or even without " " at all)

share|improve this answer
Tried and failed :( – Ricko M Jan 28 '11 at 17:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.