I recently ran into a bug in a script where I tried to do the following:
yum -y install another_package.x86_64 some_package.x86_64 && run_my_script
The script ran well on a newer CentOS, but when I tried to execute it on Cent OS 5, some_package.x86_64
was not available. But instead of erroring and stopping yum
just printed the message:
No package some_package.x86_64 available.
How can I force yum
to error in such situations (which IMO should be the default) to make my scripts more robust?
Best Answer
As you've found, this behaviour changed between RHEL 5 and 6 (see https://bugzilla.redhat.com/show_bug.cgi?id=736694 for some discussion). From that link, checking the return code of
yum info <pkg>
should allow you to abort your script as required. Something like: