gpt4 book ai didi

RPM 规范文件查找已安装的版本

转载 作者:行者123 更新时间:2023-12-04 18:34:14 26 4
gpt4 key购买 nike

我需要在安装 rpm 时找到以前版本的包(如果已经安装的话)。我的spec文件如下

在 POST 中

%post
if [ "$1" = "1" ]; then
# Perform new install
fi
elif [ "$1" = "2" ]; then
# Perform update
<强> # what I need is value for Version
if [ $Version = 1.0]; then
# do upgrade 1
fi
elif [ "$Version" = "2" ]; then
#do upgrade 2
fi

fi

在上面的代码中,我如何获取 Version 的值。我尝试使用执行 rpm-qi | grep <rpm_package> 还有其他方法吗?

最佳答案

不检查版本。检查数据是旧的还是新的。

参见: https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Saving_state_between_scriptlets

%pre
grep OLDDATA /etc/myconfig >/dev/null && touch %{_localstatedir}/lib/rpm-state/%{name}.DoSomethingLater

%posttrans
if [ -e %{_localstatedir}/lib/rpm-state/%{name}.DoSomethingLater ]; then
# do some conditional stuff
rm -f %{_localstatedir}/lib/rpm-state/%{name}.DoSomethingLater
fi

关于RPM 规范文件查找已安装的版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35357916/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com