问题
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?
回答1:
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
回答2:
You can define %pre
, %post
, %preun
and %postun
sections. They get the number of present installations of the package as a parameter. See here.
The respective section of the RPM book goes into detail concerning these scripts. Essentially, the scripte gets written into a file before execution and then runs.
来源:https://stackoverflow.com/questions/13698832/rpm-build-how-to-print-error-message-at-rpm-install-at-client