yum_update.sh improvements
* Use <yum|dnf> repoquery instead of repoquery directly "repoquery" is part of <yum|dnf>-utils which may not be installed, in which case no packages would end up updated. * Use the --quiet flag with repoquery This prevents notices such as subscription-related stderr warnings from being added to the output and messing with the sorted order. * Remove the : after else It seems using else without a colon is the bash standard. This gets rid of the following error on RHEL8: "/tmp/yum_update.sh: line 34: else:: command not found" Depends-On: https://review.opendev.org/662317 Change-Id: Id03405d49dc213d018941c44129521cca845e7d6
This commit is contained in:
parent
f1dfdc63d9
commit
c475c8394a
@ -2,10 +2,12 @@
|
||||
|
||||
set -eou pipefail
|
||||
|
||||
PKG="$(command -v dnf || command -v yum)"
|
||||
|
||||
packages_for_update=
|
||||
if [ -n "$1" ] && command -v repoquery >/dev/null 2>&1; then
|
||||
if [ -n "$1" ] && $PKG repoquery >/dev/null 2>&1; then
|
||||
installed_versions=$(rpm -qa --qf "%{NAME} = %{VERSION}-%{RELEASE}\n" | sort)
|
||||
available_versions=$(repoquery --provides --disablerepo='*' --enablerepo=$1 -a | sort)
|
||||
available_versions=$($PKG repoquery --quiet --provides --disablerepo='*' --enablerepo=$1 -a | sort)
|
||||
uptodate_versions=$(comm -12 <(printf "%s\n" "$installed_versions") <(printf "%s\n" "$available_versions"))
|
||||
|
||||
|
||||
@ -22,14 +24,13 @@ 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
|
||||
$PKG install -y dnf-plugins-core
|
||||
fi
|
||||
else:
|
||||
else
|
||||
if ! echo $installed | grep -qw yum-plugin-priorities; then
|
||||
$PKG install -y yum-plugin-priorities
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user