Passing user defined argument to RPM is possible while installing?

12,646

Solution 1

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__

Solution 2

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.

Share:
12,646
Sakthivadivel Anbalagan
Author by

Sakthivadivel Anbalagan

Updated on June 16, 2022

Comments

  • Sakthivadivel Anbalagan
    Sakthivadivel Anbalagan almost 2 years

    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