[Rpm-maint] Using environment variables in spec files?

Jim Galarowicz jeg at krellinst.org
Wed Dec 19 03:07:43 UTC 2007


I hope this is the correct list to post this question. If not,
sorry about that! I would greatly appreciate a pointer to the
correct list.

In our project we are trying to create rpm spec files that would
install our components into an alternative location. We have several
components that are required by our main tool. We build the individual
components in an order based on dependency building each additional
component pointing to the alternative location of the previously built
components so that we use the previously built component's include files
and libraries as input to the build of the current component.

We define an environment variable OPENSS_PREFIX outside of the spec file.
OPENSS_PREFIX indicates the location (path) we are intending to install into.
We use this environment variable to create a define that is used inside the
spec file.

I've been looking for examples of this type of spec file environment
variable usage by searching the internet. I haven't found any examples,
which leads me to believe that the way we are doing things might not be correct.

Here is an example of what we are trying to do:

Summary: Dynamic Instrumentation Library
Name: dyninst
Version: 5.1r
Release: 1
License: non-gpl opensource - see description
Group: Development/OpenSpeedShop
URL: http://www.dyninst.org/
Source: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Prefix: /opt/OSS



%define depend_prefix %(echo $OPENSS_PREFIX)


depend_prefix is later used in the configure statement
and to create a file that is created within the spec file
and written into the components build directory.

./configure --with-dyninst=%{depend_prefix} --enable-manual-start \
--prefix=$RPM_BUILD_ROOT%{prefix} --includedir=$RPM_BUILD_ROOT%{prefix}/include/dpcl \
--libdir=$RPM_BUILD_ROOT%{prefix}/lib64 --with-libelf=%{elf_prefix}


cat << EOF > make.config.local
ifeq (\$(LIBELFDIR),%{depend_prefix})
LIBELFDIR = %{depend_prefix}


On some systems this works and on others we get blanks ( for %{depend_prefix} )
where we expected to get the path contained in the OPENSS_PREFIX environment variable.
Is this a valid approach? Does anyone have a better scheme for this?

Thanks very much for your time!

Jim G.

More information about the Rpm-maint mailing list