RPM-Build -How to print error message at rpm install at client

meet patel picture meet patel · Dec 4, 2012 · Viewed 10.9k times · Source

my requirement is that i want to print some message on screen if rpm install fails in any case at client machine.or display message on screen like rpm install fail due to any of the generated reasons.like other standard rpm gives.

and i am not making any c file or make command in my .spec file . Everything i was doing in spec file itself.plz suggest how to print such type of things in client console using spec file.


yes that is not my concern --test i have give just example.my excet requirement is below spec file content are.

#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

then i try to uninstall the rpm using command

rpm -ev xyz

output : both message are printed according to service status.i want if client uninstall with option -v then and then it display message on screen otherwise not. how can i do this?

Answer

Aaron D. Marasco picture Aaron D. Marasco · Dec 4, 2012

Printing to STDERR will always be shown to the client. STDOUT is shown if they install with verbose options.

echo 'Something may be wrong!' > /dev/stderr