Passing user defined argument to RPM is possible while installing?
Asked Answered
T

2

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

Teodoor answered 26/6, 2012 at 10:4 Comment(1)
@malenkiy_scot - Thanks for editing and made question clear.Teodoor
D
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__
Detta answered 26/6, 2012 at 21:38 Comment(0)
O
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.

Oleograph answered 26/6, 2012 at 21:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.