SPEC %files attribute and Shell variables

7,509

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:
7,509

Related videos on Youtube

Ricko M
Author by

Ricko M

Developer

Updated on September 17, 2022

Comments

  • Ricko M
    Ricko M over 1 year

    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!

  • Ricko M
    Ricko M about 13 years
    Tried and failed :(
  • Ricko M
    Ricko M about 13 years
    Cheers! This got it done. %define AXISHOME %(echo ${AXIS2C_HOME})
  • Ricko M
    Ricko M about 13 years
    %file %AXISHOME/blah.xml