diff options
Diffstat (limited to 'tests/letstest/scripts/test_leauto_upgrades.sh')
-rwxr-xr-x | tests/letstest/scripts/test_leauto_upgrades.sh | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/tests/letstest/scripts/test_leauto_upgrades.sh b/tests/letstest/scripts/test_leauto_upgrades.sh index 0c2b374f2..fc7632793 100755 --- a/tests/letstest/scripts/test_leauto_upgrades.sh +++ b/tests/letstest/scripts/test_leauto_upgrades.sh @@ -15,27 +15,37 @@ if ! command -v git ; then exit 1 fi fi -# 0.17.0 is the oldest version of letsencrypt-auto that has precompiled -# cryptography and the tagged commit is in master. 0.16.0 was the first version -# to use precompiled cryptography, but the release PR was squashed losing the -# commit. We want to use a precompiled version of cryptography for stability. -# Previous versions that have to compile against OpenSSL on installation -# started failing on newer distros with newer versions of OpenSSL. -INITIAL_VERSION="0.17.0" +# If we're on a RHEL 6 based system, we can be confident Python is already +# installed because the package manager is written in Python. +if command -v python && [ $(python -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//') -eq 26 ]; then + # 0.20.0 is the latest version of letsencrypt-auto that doesn't install + # Python 3 on RHEL 6. + INITIAL_VERSION="0.20.0" + RUN_RHEL6_TESTS=1 +else + # 0.37.x is the oldest version of letsencrypt-auto that works on RHEL 8. + INITIAL_VERSION="0.37.1" +fi + git checkout -f "v$INITIAL_VERSION" letsencrypt-auto -if ! ./letsencrypt-auto -v --debug --version --no-self-upgrade 2>&1 | grep "$INITIAL_VERSION" ; then +if ! ./letsencrypt-auto -v --debug --version --no-self-upgrade 2>&1 | tail -n1 | grep "^certbot $INITIAL_VERSION$" ; then echo initial installation appeared to fail exit 1 fi +# This script sets the environment variables PYTHON_NAME, VENV_PATH, and +# VENV_SCRIPT based on the version of Python available on the system. For +# instance, Fedora uses Python 3 and Python 2 is not installed. +. tests/letstest/scripts/set_python_envvars.sh + # Now that python and openssl have been installed, we can set up a fake server # to provide a new version of letsencrypt-auto. First, we start the server and # directory to be served. MY_TEMP_DIR=$(mktemp -d) PORT_FILE="$MY_TEMP_DIR/port" -SERVER_PATH=$(tools/readlink.py tools/simple_http_server.py) +SERVER_PATH=$("$PYTHON_NAME" tools/readlink.py tools/simple_http_server.py) cd "$MY_TEMP_DIR" -"$SERVER_PATH" 0 > $PORT_FILE & +"$PYTHON_NAME" "$SERVER_PATH" 0 > $PORT_FILE & SERVER_PID=$! trap 'kill "$SERVER_PID" && rm -rf "$MY_TEMP_DIR"' EXIT cd ~- @@ -68,8 +78,7 @@ iQIDAQAB -----END PUBLIC KEY----- " -if [ $(python -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//') -eq 26 ]; then - RUN_PYTHON3_TESTS=1 +if [ "$RUN_RHEL6_TESTS" = 1 ]; then if command -v python3; then echo "Didn't expect Python 3 to be installed!" exit 1 @@ -79,13 +88,12 @@ if [ $(python -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//') -eq 26 ]; echo "Certbot shouldn't have updated to a new version!" exit 1 fi - if [ -d "/opt/eff.org" ]; then - echo "New directory shouldn't have been created!" - exit 1 - fi - # Create a 2nd venv at the new path to ensure we properly handle this case - export VENV_PATH="/opt/eff.org/certbot/venv" - if ! sudo -E ./letsencrypt-auto -v --debug --version --no-self-upgrade 2>&1 | grep "$INITIAL_VERSION" ; then + # Create a 2nd venv at the old path to ensure we properly handle the (unlikely) case of two separate virtual environments below. + HOME=${HOME:-~root} + XDG_DATA_HOME=${XDG_DATA_HOME:-~/.local/share} + OLD_VENV_PATH="$XDG_DATA_HOME/letsencrypt" + export VENV_PATH="$OLD_VENV_PATH" + if ! sudo -E ./letsencrypt-auto -v --debug --version --no-self-upgrade 2>&1 | tail -n1 | grep "^certbot $INITIAL_VERSION$" ; then echo second installation appeared to fail exit 1 fi @@ -98,7 +106,7 @@ if ./letsencrypt-auto -v --debug --version | grep "WARNING: couldn't find Python fi EXPECTED_VERSION=$(grep -m1 LE_AUTO_VERSION certbot-auto | cut -d\" -f2) -if ! /opt/eff.org/certbot/venv/bin/letsencrypt --version 2>&1 | grep "$EXPECTED_VERSION" ; then +if ! /opt/eff.org/certbot/venv/bin/letsencrypt --version 2>&1 | tail -n1 | grep "^certbot $EXPECTED_VERSION$" ; then echo upgrade appeared to fail exit 1 fi @@ -108,7 +116,9 @@ if ! diff letsencrypt-auto letsencrypt-auto-source/letsencrypt-auto ; then exit 1 fi -if [ "$RUN_PYTHON3_TESTS" = 1 ]; then +if [ "$RUN_RHEL6_TESTS" = 1 ]; then + # Add the SCL python release to PATH in order to resolve python3 command + PATH="/opt/rh/rh-python36/root/usr/bin:$PATH" if ! command -v python3; then echo "Python3 wasn't properly installed" exit 1 @@ -117,11 +127,10 @@ if [ "$RUN_PYTHON3_TESTS" = 1 ]; then echo "Python3 wasn't used in venv!" exit 1 fi -fi -echo upgrade appeared to be successful -if [ "$(tools/readlink.py ${XDG_DATA_HOME:-~/.local/share}/letsencrypt)" != "/opt/eff.org/certbot/venv" ]; then - echo symlink from old venv path not properly created! - exit 1 + if [ "$("$PYTHON_NAME" tools/readlink.py $OLD_VENV_PATH)" != "/opt/eff.org/certbot/venv" ]; then + echo symlink from old venv path not properly created! + exit 1 + fi fi -echo symlink properly created +echo upgrade appeared to be successful |