setting package name at install time

Ramin Rad raminsrad at gmail.com
Mon Sep 13 22:20:42 UTC 2010


  I know it might sound crazy, but I was wondering if there is a way to 
set the RPM package name at install time.

I figured out that I can set the package name dynamically at build time, 
by doing this:

%define myprefix %(echo $MY_ENV_VAR)

and then set the package name like this:

Name: %{myprefix}_my_package

But after I build the RPM package file and run "rpm -qip 
package_file.rpm" it shows the Name evaluated to the value set at build 
time.

The purpose behind this exercise is to install the same package multiple 
times with different names on the same server. (The reason the package 
is being installed multiple times is because the scripts in the RPM 
package do different things depending on the environment variable, and 
we don't want to create multiple packages, and we want to avoid using 
--dbpath.)

Why does it work for RPM built-in macros? For example, if on the build 
machine my "%_usr" is "/usr" but on install machine my "%_usr" is set to 
"/opt", how is it that it works?

Your help is appreciated.

-ramin



More information about the Rpm-list mailing list