我想在卸载时在客户端打印消息,如果错误然后我总是打印,如果它是简单的消息,如rpm卸载成功那么它是可选的.client使用选项-v然后它打印(详细其他明智不)
rpm -ivh xyz.rpm for install and rpm -ev xyz for uninstall as below.
#Pre-Uninstall部分
%preun
Processes=`ps -Ao"%p:%a" --cols 150 |
egrep "Launcher|rmiregistry" | grep -v grep | cut -d ":" -f1`
if [ -n "$Processes" ]; then
echo 'xyz is running ,first stop it then uninstall.' > /dev/stderr;
exit 1;
else
echo 'xyz service is not running' >/dev/stdout;
fi
目前上面的代码打印每次rpm卸载。
答案 0 :(得分:2)
您需要在%preun中区分升级和删除。
我在* .spec文件中使用此模式:
%preun
if [ "$1" = "0" ]; then
# package removal
true; # bash doesn't like 'empty' conditional blocks
elif [ "$1" = "1" ]; then
# package upgrade
true; # bash doesn't like 'empty' conditional blocks
fi
一些exrta信息:https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Syntax