I've used the following method, which might not be foolproof, but seems to work:
Assuming the variable PACKAGES contains the list of packages you want to install, then:
- Run
yum -y install $PACKAGES (I assume if this is a script, you really want to pass -y to avoid prompting). - Check its exit status in order to detect some failure conditions.
- Run
rpm --query --queryformat "" $PACKAGES, which will output nothing for each package that was installed successfully, and will output package <name> is not installed for each failure. - Check its exit status, which appears to be the number of packages that were not successfully installed, i.e. will be 0 on success as usual.
This will only work if PACKAGES contains plain package names that yum is expected to find in a repository, not if it contains other things that yum accepts like URLs, file names or Provides: names.
LC_ALL=Cshould switch to English.