Use 'dnf repoquery' when system uses DNF

repoquery is part of dnf so we can use 'dnf repoquery' directly rather
than install dnf-utils, which isn't installed by default on e.g. RHEL8.

When using yum, command -v repoquery will still be used as it was
before this update.

Change-Id: Iea8822084988b23652e6d3f8b5828c05734158af
This commit is contained in:
Julie Pichon 2019-06-11 15:51:00 +01:00
parent 367f3e032a
commit 8fa6dd7dde
1 changed files with 11 additions and 4 deletions

View File

@ -2,10 +2,19 @@
set -eou pipefail
PKG="$(command -v dnf || command -v yum)"
PKG_MGR="$(echo ${PKG:(-3)})"
if [ $PKG_MGR == "dnf" ]; then
REPOQUERY_CMD="$PKG repoquery"
else
REPOQUERY_CMD="$(command -v repoquery)"
fi
packages_for_update=
if [ -n "$1" ] && command -v repoquery >/dev/null 2>&1; then
if [ -n "$1" ] && [[ -n $REPOQUERY_CMD ]]; then
installed_versions=$(rpm -qa --qf "%{NAME} = %{VERSION}-%{RELEASE}\n" | sort)
available_versions=$(repoquery --quiet --provides --disablerepo='*' --enablerepo=$1 -a | sort)
available_versions=$($REPOQUERY_CMD --quiet --provides --disablerepo='*' --enablerepo=$1 -a | sort)
uptodate_versions=$(comm -12 <(printf "%s\n" "$installed_versions") <(printf "%s\n" "$available_versions"))
@ -22,8 +31,6 @@ if [ -z "$packages_for_update" ]; then
exit
fi
PKG="$(command -v dnf || command -v yum)"
PKG_MGR="$(echo ${PKG:(-3)})"
if [ $PKG_MGR == "dnf" ]; then
if ! echo $installed | grep -qw dnf-plugins-core; then