From ee18ee16642b850dd413b9fac77d698ff6c82b9e Mon Sep 17 00:00:00 2001 From: Adrien Ferrand Date: Thu, 25 Jul 2019 12:20:33 +0200 Subject: [PATCH] Add logic --- .../letsencrypt-auto.template | 10 ++++- .../pieces/bootstrappers/rpm_python3.sh | 7 ---- .../bootstrappers/rpm_python3_legacy.sh | 42 +++++++++++++++++++ 3 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 letsencrypt-auto-source/pieces/bootstrappers/rpm_python3_legacy.sh diff --git a/letsencrypt-auto-source/letsencrypt-auto.template b/letsencrypt-auto-source/letsencrypt-auto.template index c064580bd..923b10c7b 100755 --- a/letsencrypt-auto-source/letsencrypt-auto.template +++ b/letsencrypt-auto-source/letsencrypt-auto.template @@ -298,6 +298,7 @@ DeterminePythonVersion() { {{ bootstrappers/deb_common.sh }} {{ bootstrappers/rpm_common_base.sh }} {{ bootstrappers/rpm_common.sh }} +{{ bootstrappers/rpm_python3_legacy.sh }} {{ bootstrappers/rpm_python3.sh }} {{ bootstrappers/suse_common.sh }} {{ bootstrappers/arch_common.sh }} @@ -336,7 +337,14 @@ elif [ -f /etc/redhat-release ]; then if [ "$RPM_DIST_NAME" = "fedora" ]; then RPM_DIST_VERSION=`(. /etc/os-release 2> /dev/null && echo $VERSION_ID) || echo "0"` fi - if [ "$RPM_DIST_NAME" = "fedora" -a "$RPM_DIST_VERSION" -ge 29 -o "$PYVER" -eq 26 ]; then + if [ "$PYVER" -eq 26 ]; then + Bootstrap() { + BootstrapMessage "Legacy RedHat-based OSes that will use Python3" + BootstrapRpmPython3Legacy + } + USE_PYTHON_3=1 + BOOTSTRAP_VERSION="BootstrapRpmPython3Legacy $BOOTSTRAP_RPM_PYTHON3_LEGACY_VERSION" + elif [ "$RPM_DIST_NAME" = "fedora" -a "$RPM_DIST_VERSION" -ge 29 -o "$PYVER" -eq 26 ]; then Bootstrap() { BootstrapMessage "RedHat-based OSes that will use Python3" BootstrapRpmPython3 diff --git a/letsencrypt-auto-source/pieces/bootstrappers/rpm_python3.sh b/letsencrypt-auto-source/pieces/bootstrappers/rpm_python3.sh index f33b07ca9..ac0553db5 100644 --- a/letsencrypt-auto-source/pieces/bootstrappers/rpm_python3.sh +++ b/letsencrypt-auto-source/pieces/bootstrappers/rpm_python3.sh @@ -4,7 +4,6 @@ BOOTSTRAP_RPM_PYTHON3_VERSION=1 BootstrapRpmPython3() { # Tested with: - # - CentOS 6 # - Fedora 29 InitializeRPMCommonBase @@ -15,12 +14,6 @@ BootstrapRpmPython3() { python3-virtualenv python3-devel " - # EPEL uses python34 - elif $TOOL list python34 >/dev/null 2>&1; then - python_pkgs="python34 - python34-devel - python34-tools - " else error "No supported Python package available to install. Aborting bootstrap!" exit 1 diff --git a/letsencrypt-auto-source/pieces/bootstrappers/rpm_python3_legacy.sh b/letsencrypt-auto-source/pieces/bootstrappers/rpm_python3_legacy.sh new file mode 100644 index 000000000..49b4b2b59 --- /dev/null +++ b/letsencrypt-auto-source/pieces/bootstrappers/rpm_python3_legacy.sh @@ -0,0 +1,42 @@ +# If new packages are installed by BootstrapRpmPython3 below, this version +# number must be increased. +BOOTSTRAP_RPM_PYTHON3_LEGACY_VERSION=1 + +BootstrapRpmPython3Legacy() { + + InitializeRPMCommonBase + + if ! $TOOL list rh-python36 >/dev/null 2>&1; then + echo "To use Certbot, packages from the SCL repository need to be installed." + if ! $TOOL list centos-release-scl >/dev/null 2>&1; then + error "Enable the SCL repository and try running Certbot again." + exit 1 + fi + if [ "$ASSUME_YES" = 1 ]; then + /bin/echo -n "Enabling the SCL repository in 3 seconds..." + sleep 1s + /bin/echo -ne "\e[0K\rEnabling the SCL repository in 2 seconds..." + sleep 1s + /bin/echo -e "\e[0K\rEnabling the SCL repository in 1 second..." + sleep 1s + fi + if ! $TOOL install $YES_FLAG $QUIET_FLAG centos-release-scl; then + error "Could not enable SCL. Aborting bootstrap!" + exit 1 + fi + fi + + # CentOS 6 must use rh-python36 from SCL + if $TOOL list python3-virtualenv >/dev/null 2>&1; then + python_pkgs="rh-python36 + " + else + error "No supported Python package available to install. Aborting bootstrap!" + exit 1 + fi + + # Insert the SCL specific path in PATH to resolve the correct virtualenv binary from SCL + PATH="/opt/rh/rh-python36/root/usr/bin:$PATH" + + BootstrapRpmCommonBase "$python_pkgs" +}