【问题标题】:rpm build:spec file display message at clientrpm build:spec 文件在客户端显示消息
【发布时间】:2012-11-25 14:44:48
【问题描述】:

我想在卸载时在客户端打印消息,如果出现错误,那么我总是打印,如果它是简单的消息,如 rpm 卸载成功,那么它是可选的。客户端使用选项 -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都会打印出来。

【问题讨论】:

    标签: linux rpm rpmbuild specifications rpm-spec


    【解决方案1】:

    你需要在 %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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-05
      • 2012-01-20
      • 2013-03-18
      • 2017-09-30
      相关资源
      最近更新 更多