[英]Is there an alternative way to identify the parameter or arguments that is used with rpm command in the rpm spec file
In the rpm spec file, I need to identify the user has used rpm -ivh
or rpm -Uvh
. 在rpm规范文件中,我需要确定用户已使用
rpm -ivh
或rpm -Uvh
。 In general, $1
value will be verified in the %pre
. 通常,将在
%pre
验证$1
值。 But in my case in the new rpm, we are modifying install location. 但是在我的新rpm中,我们正在修改安装位置。 In this case, when is check
$1
is showing the same value for both the -ivh
and -Uvh
. 在这种情况下,何时check
$1
对-ivh
和-Uvh
都显示相同的值。
%pre
if [ "$1" -ge 2 ]; then
legacy_exist=true
if legacy_exist; then
rm -rf *.txt
else
mkdir xxx
fi
pre
%pre
if [ "$1" -ge 2 ]; then
legacy_exist=false
if legacy_exist; then
rpm -e xxx
else
mkdir xxx
fi
pre
I want the removal of files to be done only in -Uvh usage but in my case when I have path changed rpm while setting true in both case and $1
value is showing 2 only. 我希望仅在使用-Uvh的情况下删除文件,但是在我的情况下,当我将路径更改为rpm时,在两种情况下都设置为true,并且
$1
值仅显示2。 If the rpm is not having the installation path change the code works fine. 如果rpm没有安装路径更改,则代码工作正常。
You should not check the command line args. 您不应该检查命令行参数。
rpm -U
behaves exactly the same way as rpm -i
when there is no package of that name installed. 当未安装该名称的软件包时,
rpm -U
行为与rpm -i
完全相同。
The $1
variable is the number of packages of this name which will be left on the system when the action completes. $1
变量是此名称的软件包数,操作完成后将保留在系统上。 For a full set of possible values see: https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax 有关完整的可能值的集合,请参见: https : //docs.fedoraproject.org/zh-CN/packaging-guidelines/Scriptlets/#_syntax
And please do not call rpm from scriptlet. 并且请不要从scriptlet调用rpm。 RPM is not reentrant.
RPM不可重入。 Sooner or later you will break rpmdb.
迟早您将破坏rpmdb。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.