0

i want to print message at client side at time of uninstall like if error then i always print and if it is simple message like rpm uninstall successfully then it is optional .client use the option -v then it print (verbose other wise not)

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

#Pre-Uninstall section

%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

currently the above code print each and every time of rpm uninstall.

meet patel
  • 181
  • 1
  • 2
  • 17

1 Answers1

2

You need to distinguish between upgrade and removal in %preun.

I use this pattern in my *.spec files:

%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

Some exrta information at: https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Syntax

Chisel
  • 91
  • 5