Support DNF package manager in diskimage-create

DNF is the next upcoming major version of Yum. It has been the default
package manager since Fedora 22. This patch tries to use DNF if
available, and falls back to Yum.

Change-Id: Ic011ef8281eb99ae010c61f47a8423bc186c25b7
This commit is contained in:
Carlos Goncalves 2018-09-08 02:52:27 +02:00
parent e99d0d60f4
commit 90ec2ae622

View File

@ -298,10 +298,11 @@ elif [[ $platform =~ "SUSE" ]]; then
else else
# fedora/centos/rhel # fedora/centos/rhel
# Actual qemu-img name may be qemu-img, qemu-img-ev, qemu-img-rhev, ... # Actual qemu-img name may be qemu-img, qemu-img-ev, qemu-img-rhev, ...
# "yum install qemu-img" works for all, but search requires wildcard # "dnf|yum install qemu-img" works for all, but search requires wildcard
PKG_MGR=$(which dnf &>/dev/null && echo dnf || echo yum)
PKG_LIST="qemu-img* git" PKG_LIST="qemu-img* git"
for pkg in $PKG_LIST; do for pkg in $PKG_LIST; do
if ! yum info installed $pkg &> /dev/null; then if ! $PKG_MGR info installed $pkg &> /dev/null; then
echo "Required package " ${pkg/\*} " is not installed. Exiting." echo "Required package " ${pkg/\*} " is not installed. Exiting."
exit 1 exit 1
fi fi