This should list all the pkgs that satisfy this requirement. We have constructed a system for doing this in our installer scripts, here is an example that installs "SNMP" and "Config::IniFiles".
Code: Select all
#
# Copyright (c) 2010 Nagios Enterprises, LLC. All rights reserved.
#
# $Id: NagiosXI-SNMPTrap.sh 322 2010-06-23 17:12:33Z mmestnik $
export MEID='$Id: NagiosXI-SNMPTrap.sh 322 2010-06-23 17:12:33Z mmestnik $'
# Check whether we have sufficient privileges
if [ $(( $(id -u) )) -ne 0 ]; then
echo "This script needs to be run as root/superuser."
echo "$MEID"
exit 1
fi
# Install prerequisite packages
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
yum -yq check-update > /dev/null
yum -yq install rpmdevtools
# Install prerequisite Perl modules
function yumperlget () {
echo "Some packages will fail to install, this is normal."
yum -yq provides perl"($1)" |
awk '/^Repo/ { print pkg; next; };
/^[^ ].* : / { pkg = $1; next; };' | {
# Here we write our guidelines for pkg selection.
read verlist
while read i
do for topver in $verlist; do rpmdev-vercmp "$topver" "$i"
ret=$(( $? ))
[ $(( $ret )) -eq 11 -o $(( $ret )) -eq 0 ] && {
verlist="$(sed "s/$topver/$i $topver/" \
<<< "$verlist")"
break
}
[ $(( $ret )) -eq 1 ] && {
# Bail.
echo "Failed to sort a version: $i"
verlist="$verlist $i"
break
}
done
grep -qF "$i" <<< "$verlist" || verlist="$verlist $i"
done
for ech in $verlist; do yum -qy install "$ech"; done
}
}
yumperlget "SNMP"
yumperlget "Config::IniFiles"