0

我想在卸载时在客户端打印消息,如果错误,那么我总是打印,如果它是简单的消息,如 rpm 卸载成功,那么它是可选的。客户端使用选项 -v 然后它打印(详细的其他明智的不是)

rpm -ivh xyz.rpm for install and rpm -ev xyz for uninstall as below.

#预卸载部分

%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 卸载。

4

1 回答 1

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

于 2013-11-27T12:28:20.967 回答