When I run yum install <X>
where <X>
has already been installed, yum
exits with a return status of 1 and prints "Error: Nothing to do".
Aside from checking for this string in the output (which seems like a very shaky thing to base my script on), is there some way I can test whether the package already exists? Clearly, yum knows whether or not it already exists, since it's throwing that error, but how can I access that knowledge?
To add to this, some of the packages are downloaded by way of URLs, not package names, so checking yum list installed
doesn't work.
yum
knows by querying the rpm database. for examplerpm
a full URL to the RPM you're interested in. Example which will give you the package name. One note would be that it useswget
internally but seems to silently suppress errors.rpm -qa packageName
except it's printed in a way that makes it look likeyum
output.