Linux 安装时可以将用户定义的参数传递给 RPM 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11204964/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Passing user defined argument to RPM is possible while installing?
提问by sakthi
Passing User defined argument to RPM is possible while installing?.
安装时可以将用户定义的参数传递给 RPM 吗?。
for example:
例如:
~>rpm -i sample.rpm -license_path=/path/
or
或者
~>rpm -i -license_path=/path/ sample.rpm
or
或者
~>rpm -i -somearg sample.rpm
-Sakthi
-萨克蒂
采纳答案by pwan
RPMs aren't meant to take user defined arguments.
RPM 并不意味着采用用户定义的参数。
See RPM - Install time parameters
请参阅RPM - 安装时间参数
Another similar question is at https://superuser.com/questions/408852/is-it-possible-to-get-users-input-during-installation-of-rpm
另一个类似的问题是在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 的安装后脚本要求来自 stdin 的输入,在这种情况下,您可以通过从文件或此处的文档重定向 stdio 来传递答案。
>rpm -i sample.rpm <<__NOT_RECOMMENDED__
somearg
__NOT_RECOMMENDED__
回答by nohup
It looks like you are trying to create a relocatable RPM.
看起来您正在尝试创建一个可重定位的 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
在.spec
文件的序言中,放置可以重定位的文件路径的前缀。例如,如果文件的完整路径是
/base/path/to/my/file
then /base
can be changed during RPM installation but /path/to/my/file
will remain the same.
然后/base
可以在 RPM 安装期间更改,但/path/to/my/file
将保持不变。
Here's what you put in your .spec
file:
这是您放入.spec
文件的内容:
#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 consideras well.
确保在列出文件的%install
和%files
部分中的所有可重定位文件时提及此前缀.spec
。在某些情况下,可重定位的 RPM 可能不起作用,因此也请查看这些要考虑的事项。
%files
%{prefix}/path/to/my/file
Now when you install the RPM, you can specify a different prefix.
现在,当您安装 RPM 时,您可以指定不同的前缀。
rpm -i sample.rpm --prefix /tmp
This will install the file in /tmp/path/to/my/file
.
这会将文件安装在/tmp/path/to/my/file
.