2

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?

rkb
  • 3,442
  • 19
  • 25
meet patel
  • 181
  • 1
  • 2
  • 17

2 Answers2

4

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
Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
  • the size of the file is 0.it link another files /dev/stdout --> /proc/self/fd/1 --> /dev/pts/0 – meet patel Dec 04 '12 at 10:19
  • @miteshpatel Yes, but that's ok. These are just system internals for the normal processing of the process IO. `/dev/pts/0` is the (virtual) terminal you work at, e. g. one tab in your terminal emulation or your SSH connection. – glglgl Dec 04 '12 at 10:21
  • What is your command line? I ask because yesterday you claimed it didn't work because you are using `--test` and I already mentioned that in the other answer's comments. – Aaron D. Marasco Dec 06 '12 at 00:39
-1

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.

glglgl
  • 89,107
  • 13
  • 149
  • 217
  • can u please give more details. – meet patel Dec 04 '12 at 09:51
  • ya but my requirement is like after build rpm when i install in client machine then suppose the install command is rpm -ivh demo.rpm in place of that i use rpm -ivh --test demo.rpm it gives no error kind of message.i am not sure if it is possible or not. – meet patel Dec 04 '12 at 10:31
  • That's because `--test` will only test if the transaction would work or not. It's not going to execute any of the scripts run from a read-only operation. – Aaron D. Marasco Dec 04 '12 at 23:36