Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

ie

%file
${AXIS2_C}/bin/services/services.xml

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 ?

Thanks!

share|improve this question

2 Answers 2

up vote 5 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

%file
%{AXIS2_C}/bin/services/services.xml

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
1  
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 " "

%file
"$AXIS2_C"/bin/services/services.xml

(or even without " " at all)

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

Your Answer

 
discard

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.