8

Passing User defined argument to RPM is possible while installing?.

for example:

~>rpm -i sample.rpm -license_path=/path/

or

~>rpm -i -license_path=/path/ sample.rpm

or

~>rpm -i -somearg sample.rpm

-Sakthi

malenkiy_scot
  • 16,415
  • 6
  • 64
  • 87

2 Answers2

6

RPMs aren't meant to take user defined arguments.

See RPM - Install time parameters

Another similar question is at https://superuser.com/questions/408852/is-it-possible-to-get-users-input-during-installation-of-rpm

One workaround is to have the rpm's postinstall script ask for input from stdin, in which case you can pass in the answers by redirecting stdio from a file or here document.

>rpm -i sample.rpm <<__NOT_RECOMMENDED__
somearg
__NOT_RECOMMENDED__
Community
  • 1
  • 1
pwan
  • 2,894
  • 2
  • 24
  • 38
1

It looks like you are trying to create a relocatable RPM.

In the preamble of your .spec file, put the prefix of the file path that can be relocated. For example, if the full path to your file is

/base/path/to/my/file

then /base can be changed during RPM installation but /path/to/my/file will remain the same.

Here's what you put in your .spec file:

#Preamble: Summary, Name, etc.
Prefix: /base

Ensure that you mention this prefix while listing all relocatable files in the %install and %files sections in the .spec file. There are conditions where a relocatable RPM may not work, so check out these things to consider as well.

%files
%{prefix}/path/to/my/file

Now when you install the RPM, you can specify a different prefix.

rpm -i sample.rpm  --prefix /tmp

This will install the file in /tmp/path/to/my/file.

nohup
  • 517
  • 3
  • 4