Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
ee18ee1
Add logic
adferrand Jul 25, 2019
a519b3a
Rebuilt letsencrypt-auto
adferrand Jul 25, 2019
541ea83
Fix logic
adferrand Jul 25, 2019
736809c
Focus on specific packages
adferrand Jul 25, 2019
c2d165e
Maintain PATH for further invocations of letsencrypt-auto after boots…
adferrand Jul 25, 2019
bbade20
Various corrections
adferrand Jul 30, 2019
7b456cd
Fix farm test for RHEL6
Jul 30, 2019
66d1d40
Working centos6 letsencrypt-auto self tests
adferrand Jul 31, 2019
12fa60b
Merge branch 'master' into centos6-migrate-python36
adferrand Aug 8, 2019
6e5cc6d
Merge branch 'master' into centos6-migrate-python36
Aug 11, 2019
d73a426
Fix test_sdist for CentOS 6
Aug 11, 2019
cd69e26
Merge branch 'master' into centos6-migrate-python36
Sep 6, 2019
52188c9
Corrections
Sep 6, 2019
6200623
Work in progress
adferrand Sep 10, 2019
6944b92
Working configuration
Sep 10, 2019
9e18b4c
Fix typo
Sep 10, 2019
122c373
Remove EPEL. Add a test.
Sep 10, 2019
670fc47
Update letsencrypt-auto-source/letsencrypt-auto.template
adferrand Sep 11, 2019
bcadc53
Improvements after review
Sep 17, 2019
50cd32c
Improvements
Sep 18, 2019
153050d
Add a comment
Sep 18, 2019
588f1ba
Add a test
Sep 18, 2019
7a2a15a
Update a test
Sep 18, 2019
1ff005b
Corrections
adferrand Sep 20, 2019
20d9e5a
Merge branch 'master-upstream' into centos6-migrate-python36
adferrand Sep 20, 2019
04f2f35
Update function return
adferrand Sep 23, 2019
f1e580d
Merge branch 'master-upstream' into centos6-migrate-python36
Sep 30, 2019
61a96bd
Merge branch 'master-upstream' into centos6-migrate-python36
Oct 1, 2019
4bc4bce
Work in progress
Oct 1, 2019
6f11219
Correct behavior on oracle linux 6.
Oct 1, 2019
e856d95
Corrections
Oct 2, 2019
4b6ef3e
Merge branch 'master-upstream' into centos6-migrate-python36
adferrand Oct 4, 2019
147e2c3
Rebuild script
adferrand Oct 4, 2019
b3342eb
Add letsencrypt-auto tests for oraclelinux6
Oct 4, 2019
97de34a
Merge branch 'master' into centos6-migrate-python36
adferrand Oct 17, 2019
f17ea9b
Update tox.ini
adferrand Oct 17, 2019
3fcb2c2
Update letsencrypt-auto-source/letsencrypt-auto
adferrand Oct 17, 2019
c625efd
Update letsencrypt-auto-source/tests/oraclelinux6_tests.sh
adferrand Oct 17, 2019
b1ba95c
Update letsencrypt-auto-source/letsencrypt-auto.template
adferrand Oct 17, 2019
c12fb5d
Update letsencrypt-auto-source/letsencrypt-auto
adferrand Oct 17, 2019
8488d8b
Update letsencrypt-auto-source/letsencrypt-auto
adferrand Oct 17, 2019
7207e0a
Update letsencrypt-auto-source/letsencrypt-auto.template
adferrand Oct 17, 2019
a29f8cf
Update letsencrypt-auto-source/tests/oraclelinux6_tests.sh
adferrand Oct 17, 2019
1df1421
Remove specific code for scientific linux
adferrand Oct 20, 2019
f7c1e52
Change some variables names
adferrand Oct 20, 2019
e166c32
Update letsencrypt-auto-source/tests/oraclelinux6_tests.sh
adferrand Oct 20, 2019
836c804
Various corrections
adferrand Oct 20, 2019
541cf26
Fix tests
adferrand Oct 20, 2019
5f57e49
Add a comment
adferrand Oct 20, 2019
5d422eb
Update message
adferrand Oct 20, 2019
84646a9
Fix test message
adferrand Oct 21, 2019
dedd426
Update letsencrypt-auto-source/letsencrypt-auto.template
adferrand Oct 23, 2019
3a7165d
Update letsencrypt-auto-source/letsencrypt-auto
adferrand Oct 23, 2019
e66f324
Update letsencrypt-auto-source/letsencrypt-auto
adferrand Oct 23, 2019
34db794
Update scripts
adferrand Oct 23, 2019
8ab1733
More focused assertion
adferrand Oct 23, 2019
03c2570
Add back a test
adferrand Oct 23, 2019
50d0d6f
Update script
adferrand Oct 23, 2019
89c1075
Update letsencrypt-auto-source/letsencrypt-auto.template
adferrand Oct 23, 2019
a150ab6
Update letsencrypt-auto-source/letsencrypt-auto.template
adferrand Oct 23, 2019
83ad288
Check quiet mode
adferrand Oct 23, 2019
ca6c994
Add changelog
adferrand Oct 24, 2019
ff9f343
Merge branch 'master-upstream' into centos6-migrate-python36
adferrand Oct 24, 2019
a2509a2
Update letsencrypt-auto-source/tests/oraclelinux6_tests.sh
adferrand Oct 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ matrix:
- sudo: required
env: TOXENV=le_auto_centos6
services: docker
- sudo: required
env: TOXENV=le_auto_oraclelinux6
services: docker
<<: *extended-test-suite
- sudo: required
env: TOXENV=docker_dev
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Certbot adheres to [Semantic Versioning](https://semver.org/).
staging server instead of the live server when `--dry-run` is used.
* Updated certbot-dns-google to depend on newer versions of
google-api-python-client and oauth2client.
* Migrated CentOS 6 certbot-auto users from Python 3.4 to Python 3.6.

### Fixed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# For running tests, build a docker image with a passwordless sudo and a trust
# store we can manipulate.

FROM centos:6
ARG REDHAT_DIST_FLAVOR
FROM ${REDHAT_DIST_FLAVOR}:6

RUN yum install -y epel-release
ARG REDHAT_DIST_FLAVOR

RUN curl -O https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm \
&& rpm -ivh epel-release-latest-6.noarch.rpm

# Install pip and sudo:
RUN yum install -y python-pip sudo
Expand All @@ -27,11 +31,18 @@ RUN mkdir -p /home/lea/certbot
COPY ./tests/certs/ca/my-root-ca.crt.pem /usr/local/share/ca-certificates/
RUN update-ca-trust

# Copy code:
# Copy current letsencrypt-auto:
COPY . /home/lea/certbot/letsencrypt-auto-source

# Fetch previous letsencrypt-auto that was installing python 3.4
RUN curl https://raw.githubusercontent.com/certbot/certbot/v0.38.0/letsencrypt-auto-source/letsencrypt-auto \
-o /home/lea/certbot/letsencrypt-auto-source/letsencrypt-auto_py_34 \
&& chmod +x /home/lea/certbot/letsencrypt-auto-source/letsencrypt-auto_py_34

RUN cp /home/lea/certbot/letsencrypt-auto-source/tests/${REDHAT_DIST_FLAVOR}6_tests.sh /home/lea/certbot/letsencrypt-auto-source/tests/redhat6_tests.sh \
&& chmod +x /home/lea/certbot/letsencrypt-auto-source/tests/redhat6_tests.sh

USER lea
WORKDIR /home/lea

RUN sudo chmod +x certbot/letsencrypt-auto-source/tests/centos6_tests.sh
CMD sudo certbot/letsencrypt-auto-source/tests/centos6_tests.sh
CMD ["sudo", "certbot/letsencrypt-auto-source/tests/redhat6_tests.sh"]
212 changes: 153 additions & 59 deletions letsencrypt-auto-source/letsencrypt-auto
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,28 @@ DeprecationBootstrap() {
fi
}

MIN_PYTHON_VERSION="2.7"
MIN_PYVER=$(echo "$MIN_PYTHON_VERSION" | sed 's/\.//')
MIN_PYTHON_2_VERSION="2.7"
MIN_PYVER2=$(echo "$MIN_PYTHON_2_VERSION" | sed 's/\.//')
MIN_PYTHON_3_VERSION="3.5"
MIN_PYVER3=$(echo "$MIN_PYTHON_3_VERSION" | sed 's/\.//')
# Sets LE_PYTHON to Python version string and PYVER to the first two
# digits of the python version
# digits of the python version.
# MIN_PYVER and MIN_PYTHON_VERSION are also set by this function, and their
# values depend on if we try to use Python 3 or Python 2.
DeterminePythonVersion() {
# Arguments: "NOCRASH" if we shouldn't crash if we don't find a good python
#
# If no Python is found, PYVER is set to 0.
if [ "$USE_PYTHON_3" = 1 ]; then
MIN_PYVER=$MIN_PYVER3
MIN_PYTHON_VERSION=$MIN_PYTHON_3_VERSION
for LE_PYTHON in "$LE_PYTHON" python3; do
# Break (while keeping the LE_PYTHON value) if found.
$EXISTS "$LE_PYTHON" > /dev/null && break
done
else
MIN_PYVER=$MIN_PYVER2
MIN_PYTHON_VERSION=$MIN_PYTHON_2_VERSION
for LE_PYTHON in "$LE_PYTHON" python2.7 python27 python2 python; do
# Break (while keeping the LE_PYTHON value) if found.
$EXISTS "$LE_PYTHON" > /dev/null && break
Expand All @@ -285,7 +293,7 @@ DeterminePythonVersion() {
fi
fi

PYVER=`"$LE_PYTHON" -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//'`
PYVER=$("$LE_PYTHON" -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//')
if [ "$PYVER" -lt "$MIN_PYVER" ]; then
if [ "$1" != "NOCRASH" ]; then
error "You have an ancient version of Python entombed in your operating system..."
Expand Down Expand Up @@ -368,7 +376,9 @@ BootstrapDebCommon() {

# Sets TOOL to the name of the package manager
# Sets appropriate values for YES_FLAG and QUIET_FLAG based on $ASSUME_YES and $QUIET_FLAG.
# Enables EPEL if applicable and possible.
# Note: this function is called both while selecting the bootstrap scripts and
# during the actual bootstrap. Some things like prompting to user can be done in the latter
# case, but not in the former one.
InitializeRPMCommonBase() {
if type dnf 2>/dev/null
then
Expand All @@ -388,26 +398,6 @@ InitializeRPMCommonBase() {
if [ "$QUIET" = 1 ]; then
QUIET_FLAG='--quiet'
fi

if ! $TOOL list *virtualenv >/dev/null 2>&1; then
echo "To use Certbot, packages from the EPEL repository need to be installed."
if ! $TOOL list epel-release >/dev/null 2>&1; then
error "Enable the EPEL repository and try running Certbot again."
exit 1
fi
if [ "$ASSUME_YES" = 1 ]; then
/bin/echo -n "Enabling the EPEL repository in 3 seconds..."
sleep 1s
/bin/echo -ne "\e[0K\rEnabling the EPEL repository in 2 seconds..."
sleep 1s
/bin/echo -e "\e[0K\rEnabling the EPEL repository in 1 second..."
sleep 1s
fi
if ! $TOOL install $YES_FLAG $QUIET_FLAG epel-release; then
error "Could not enable EPEL. Aborting bootstrap!"
exit 1
fi
fi
}

BootstrapRpmCommonBase() {
Expand Down Expand Up @@ -488,13 +478,88 @@ BootstrapRpmCommon() {
BootstrapRpmCommonBase "$python_pkgs"
}

# If new packages are installed by BootstrapRpmPython3 below, this version
# number must be increased.
BOOTSTRAP_RPM_PYTHON3_LEGACY_VERSION=1

# Checks if rh-python36 can be installed.
Python36SclIsAvailable() {
InitializeRPMCommonBase >/dev/null 2>&1;

if "${TOOL}" list rh-python36 >/dev/null 2>&1; then
return 0
fi
if "${TOOL}" list centos-release-scl >/dev/null 2>&1; then
return 0
fi
return 1
}

# Try to enable rh-python36 from SCL if it is necessary and possible.
EnablePython36SCL() {
if "$EXISTS" python3.6 > /dev/null 2> /dev/null; then
return 0
fi
if ! scl --list 2>/dev/null | grep -q rh-python36; then
return 0
fi
set +e
. scl_source enable rh-python36
set -e
}

# This bootstrap concerns old RedHat-based distributions that do not ship by default
# with Python 2.7, but only Python 2.6. We bootstrap them by enabling SCL and installing
# Python 3.6. Some of these distributions are: CentOS/RHEL/OL/SL 6.
BootstrapRpmPython3Legacy() {
# Tested with:
# - CentOS 6

InitializeRPMCommonBase

if ! "${TOOL}" list rh-python36 >/dev/null 2>&1; then
echo "To use Certbot on this operating system, 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
Comment thread
adferrand marked this conversation as resolved.
fi
if [ "${ASSUME_YES}" = 1 ]; then
/bin/echo -n "Enabling the SCL repository in 3 seconds... (Press Ctrl-C to cancel)"
sleep 1s
/bin/echo -ne "\e[0K\rEnabling the SCL repository in 2 seconds... (Press Ctrl-C to cancel)"
sleep 1s
/bin/echo -e "\e[0K\rEnabling the SCL repository in 1 second... (Press Ctrl-C to cancel)"
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 rh-python36 >/dev/null 2>&1; then
python_pkgs="rh-python36-python
rh-python36-python-virtualenv
rh-python36-python-devel
"
else
error "No supported Python package available to install. Aborting bootstrap!"
exit 1
fi

BootstrapRpmCommonBase "${python_pkgs}"

# Enable SCL rh-python36 after bootstrapping.
EnablePython36SCL
}

# If new packages are installed by BootstrapRpmPython3 below, this version
# number must be increased.
BOOTSTRAP_RPM_PYTHON3_VERSION=1

BootstrapRpmPython3() {
# Tested with:
# - CentOS 6
# - Fedora 29

InitializeRPMCommonBase
Expand All @@ -505,12 +570,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
Expand Down Expand Up @@ -769,31 +828,50 @@ elif [ -f /etc/redhat-release ]; then
RPM_DIST_VERSION=0
fi

# Starting to Fedora 29, python2 is on a deprecation path. Let's move to python3 then.
# RHEL 8 also uses python3 by default.
if [ "$RPM_DIST_NAME" = "fedora" -a "$RPM_DIST_VERSION" -ge 29 -o "$PYVER" -eq 26 ]; then
RPM_USE_PYTHON_3=1
elif [ "$RPM_DIST_NAME" = "rhel" -a "$RPM_DIST_VERSION" -ge 8 ]; then
RPM_USE_PYTHON_3=1
elif [ "$RPM_DIST_NAME" = "centos" -a "$RPM_DIST_VERSION" -ge 8 ]; then
RPM_USE_PYTHON_3=1
else
RPM_USE_PYTHON_3=0
fi
# Handle legacy RPM distributions
if [ "$PYVER" -eq 26 ]; then
# Check if an automated bootstrap can be achieved on this system.
if ! Python36SclIsAvailable; then
INTERACTIVE_BOOTSTRAP=1
fi

if [ "$RPM_USE_PYTHON_3" = 1 ]; then
Bootstrap() {
BootstrapMessage "RedHat-based OSes that will use Python3"
BootstrapRpmPython3
BootstrapMessage "Legacy RedHat-based OSes that will use Python3"
Comment thread
adferrand marked this conversation as resolved.
BootstrapRpmPython3Legacy
}
USE_PYTHON_3=1
BOOTSTRAP_VERSION="BootstrapRpmPython3 $BOOTSTRAP_RPM_PYTHON3_VERSION"
BOOTSTRAP_VERSION="BootstrapRpmPython3Legacy $BOOTSTRAP_RPM_PYTHON3_LEGACY_VERSION"

# Try now to enable SCL rh-python36 for systems already bootstrapped
# NB: EnablePython36SCL has been defined along with BootstrapRpmPython3Legacy in certbot-auto
EnablePython36SCL
else
Bootstrap() {
BootstrapMessage "RedHat-based OSes"
BootstrapRpmCommon
}
BOOTSTRAP_VERSION="BootstrapRpmCommon $BOOTSTRAP_RPM_COMMON_VERSION"
# Starting to Fedora 29, python2 is on a deprecation path. Let's move to python3 then.
# RHEL 8 also uses python3 by default.
if [ "$RPM_DIST_NAME" = "fedora" -a "$RPM_DIST_VERSION" -ge 29 ]; then
RPM_USE_PYTHON_3=1
elif [ "$RPM_DIST_NAME" = "rhel" -a "$RPM_DIST_VERSION" -ge 8 ]; then
RPM_USE_PYTHON_3=1
elif [ "$RPM_DIST_NAME" = "centos" -a "$RPM_DIST_VERSION" -ge 8 ]; then
RPM_USE_PYTHON_3=1
else
RPM_USE_PYTHON_3=0
fi

if [ "$RPM_USE_PYTHON_3" = 1 ]; then
Bootstrap() {
BootstrapMessage "RedHat-based OSes that will use Python3"
BootstrapRpmPython3
}
USE_PYTHON_3=1
BOOTSTRAP_VERSION="BootstrapRpmPython3 $BOOTSTRAP_RPM_PYTHON3_VERSION"
else
Bootstrap() {
BootstrapMessage "RedHat-based OSes"
BootstrapRpmCommon
}
BOOTSTRAP_VERSION="BootstrapRpmCommon $BOOTSTRAP_RPM_COMMON_VERSION"
fi
fi

LE_PYTHON="$prev_le_python"
Expand Down Expand Up @@ -1078,8 +1156,15 @@ if [ "$1" = "--le-auto-phase2" ]; then
# If the selected Bootstrap function isn't a noop and it differs from the
# previously used version
if [ -n "$BOOTSTRAP_VERSION" -a "$BOOTSTRAP_VERSION" != "$PREV_BOOTSTRAP_VERSION" ]; then
# if non-interactive mode or stdin and stdout are connected to a terminal
if [ \( "$NONINTERACTIVE" = 1 \) -o \( \( -t 0 \) -a \( -t 1 \) \) ]; then
# Check if we can rebootstrap without manual user intervention: this requires that
# certbot-auto is in non-interactive mode AND selected bootstrap does not claim to
# require a manual user intervention.
if [ "$NONINTERACTIVE" = 1 -a "$INTERACTIVE_BOOTSTRAP" != 1 ]; then
CAN_REBOOTSTRAP=1
fi
# Check if rebootstrap can be done non-interactively and current shell is non-interactive
# (true if stdin and stdout are not attached to a terminal).
if [ \( "$CAN_REBOOTSTRAP" = 1 \) -o \( \( -t 0 \) -a \( -t 1 \) \) ]; then
if [ -d "$VENV_PATH" ]; then
rm -rf "$VENV_PATH"
fi
Expand All @@ -1090,12 +1175,21 @@ if [ "$1" = "--le-auto-phase2" ]; then
ln -s "$VENV_PATH" "$OLD_VENV_PATH"
fi
RerunWithArgs "$@"
# Otherwise bootstrap needs to be done manually by the user.
else
error "Skipping upgrade because new OS dependencies may need to be installed."
error
error "To upgrade to a newer version, please run this script again manually so you can"
error "approve changes or with --non-interactive on the command line to automatically"
error "install any required packages."
# If it is because bootstrapping is interactive, --non-interactive will be of no use.
if [ "$INTERACTIVE_BOOTSTRAP" = 1 ]; then
error "Skipping upgrade because new OS dependencies may need to be installed."
error "This requires manual user intervention: please run this script again manually."
# If this is because of the environment (eg. non interactive shell without
# --non-interactive flag set), help the user in that direction.
else
error "Skipping upgrade because new OS dependencies may need to be installed."
error
error "To upgrade to a newer version, please run this script again manually so you can"
error "approve changes or with --non-interactive on the command line to automatically"
error "install any required packages."
fi
# Set INSTALLED_VERSION to be the same so we don't update the venv
INSTALLED_VERSION="$LE_AUTO_VERSION"
# Continue to use OLD_VENV_PATH if the new venv doesn't exist
Expand Down
Loading