Change to 'dnf' as package manager for Fedora 22->

If you are installing Saltstack on Fedora 22 onwards, the default package manager
is dnf (instead of yum).
This patch decide which package manager to use based on Fedora version and the
availability of dnf on the current system. If found, uses dnf to install packages
needed by saltstack.

Using this patch final user will not see yum deprecation warnings like:
Yum command has been deprecated, redirecting to '/usr/bin/dnf install -y yum-utils..
See 'man dnf' and 'man yum2dnf' for more information.
To transfer transaction metadata from yum to DNF, run:
'dnf install python-dnf-plugins-extras-migrate && dnf-2 migrate'
This commit is contained in:
Michele Bologna 2015-10-01 23:16:59 +02:00
parent a8d4992393
commit 5208ac6c8c

View file

@ -2626,7 +2626,17 @@ install_debian_check_services() {
#
# Fedora Install Functions
#
FEDORA_PACKAGE_MANAGER="yum"
fedora_get_package_manager() {
if [ "$DISTRO_MAJOR_VERSION" -lt 22 ] || [ "$(which dnf)" != "" ]; then
FEDORA_PACKAGE_MANAGER="dnf"
fi
}
install_fedora_deps() {
fedora_get_package_manager
if [ "$_ENABLE_EXTERNAL_ZMQ_REPOS" -eq $BS_TRUE ]; then
__install_saltstack_copr_zeromq_repository || return 1
fi
@ -2640,22 +2650,23 @@ install_fedora_deps() {
fi
# shellcheck disable=SC2086
yum install -y ${__PACKAGES} || return 1
$FEDORA_PACKAGE_MANAGER install -y ${__PACKAGES} || return 1
if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then
yum -y update || return 1
$FEDORA_PACKAGE_MANAGER -y update || return 1
fi
if [ "${_EXTRA_PACKAGES}" != "" ]; then
echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}"
# shellcheck disable=SC2086
yum install -y ${_EXTRA_PACKAGES} || return 1
$FEDORA_PACKAGE_MANAGER install -y ${_EXTRA_PACKAGES} || return 1
fi
return 0
}
install_fedora_stable() {
fedora_get_package_manager
__PACKAGES=""
if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} salt-minion"
@ -2664,7 +2675,7 @@ install_fedora_stable() {
__PACKAGES="${__PACKAGES} salt-master"
fi
# shellcheck disable=SC2086
yum install -y ${__PACKAGES} || return 1
$FEDORA_PACKAGE_MANAGER install -y ${__PACKAGES} || return 1
return 0
}
@ -2686,13 +2697,14 @@ install_fedora_stable_post() {
}
install_fedora_git_deps() {
fedora_get_package_manager
install_fedora_deps || return 1
if [ "$(which git)" = "" ]; then
yum install -y git || return 1
$FEDORA_PACKAGE_MANAGER install -y git || return 1
fi
yum install -y systemd-python || return 1
$FEDORA_PACKAGE_MANAGER install -y systemd-python || return 1
__git_clone_and_checkout || return 1
@ -2700,7 +2712,7 @@ install_fedora_git_deps() {
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO="$(grep tornado "${__SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")"
if [ "${__REQUIRED_TORNADO}" != "" ]; then
yum install -y python-tornado
$FEDORA_PACKAGE_MANAGER install -y python-tornado
fi
fi