From bfb7c794651b1512d17334f1ab87059e3cf3dac2 Mon Sep 17 00:00:00 2001 From: Ronald van Zantvoort Date: Thu, 9 Aug 2018 12:39:30 +0200 Subject: [PATCH] Fedora Py3 compat --- bootstrap-salt.sh | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 401a6bc..72ac705 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -3415,9 +3415,22 @@ install_debian_check_services() { # install_fedora_deps() { + if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then + # Packages are named python3- + PY_PKG_VER=3 + __PACKAGES="python3-m2crypto python3-PyYAML" + else + PY_PKG_VER=2 + __PACKAGES="m2crypto" + if [ "$DISTRO_MAJOR_VERSION" -ge 28 ]; then + __PACKAGES="${__PACKAGES} python2-pyyaml" + else + __PACKAGES="${__PACKAGES} PyYAML" + fi + fi - __PACKAGES="dnf-utils libyaml m2crypto PyYAML python-crypto python-jinja2" - __PACKAGES="${__PACKAGES} python2-msgpack python2-requests python-zmq" + __PACKAGES="dnf-utils ${__PACKAGES} python${PY_PKG_VER}-crypto python${PY_PKG_VER}-requests python${PY_PKG_VER}-zmq" + __PACKAGES="${__PACKAGES} libyaml python${PY_PKG_VER}-jinja2 python${PY_PKG_VER}-msgpack" # shellcheck disable=SC2086 dnf install -y ${__PACKAGES} || return 1 @@ -3474,6 +3487,12 @@ install_fedora_stable_post() { } install_fedora_git_deps() { + if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then + # Packages are named python3- + PY_PKG_VER=3 + else + PY_PKG_VER=2 + fi if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then dnf install -y ca-certificates || return 1 @@ -3487,10 +3506,10 @@ install_fedora_git_deps() { __git_clone_and_checkout || return 1 - __PACKAGES="python2-tornado systemd-python" + __PACKAGES="python${PY_PKG_VER}-tornado python${PY_PKG_VER}-systemd" if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __PACKAGES="${__PACKAGES} python-libcloud python-netaddr" + __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-libcloud python${PY_PKG_VER}-netaddr" fi # shellcheck disable=SC2086 @@ -3506,10 +3525,17 @@ install_fedora_git_deps() { } install_fedora_git() { - if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then - python setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install || return 1 + if [ "${_PY_EXE}" != "" ]; then + _PYEXE=${_PY_EXE} + echoinfo "Using the following python version: ${_PY_EXE} to install salt" else - python setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1 + _PYEXE='python2' + fi + + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then + ${_PYEXE} setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 + else + ${_PYEXE} setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 fi return 0 }