certbot-auto OS dependency update system (#4971)

* Add version number to bootstrap scripts.

* Always determine Bootstrap function and version.

* Write bootstrap version into venv.

* Add PrevBootstrapVersion function.

* Add OS bootstrapping check to phase 2.

* Differentiate -n and renew when rebootstrapping.

* Quote all environment variables.

* Correct test condition

* Add loud warning about hardcoded version list.

* s/VENV_BOOTSTRAP_VERSION/BOOTSTRAP_VERSION_PATH

* Properly handle noop bootstrap functions.
This commit is contained in:
Brad Warren
2017-08-23 11:01:20 -07:00
committed by GitHub
parent 8ca36a0b62
commit a5fae7eab5
11 changed files with 326 additions and 60 deletions
+163 -30
View File
@@ -30,6 +30,7 @@ if [ -z "$VENV_PATH" ]; then
export VENV_PATH="/opt/eff.org/certbot/venv" export VENV_PATH="/opt/eff.org/certbot/venv"
fi fi
VENV_BIN="$VENV_PATH/bin" VENV_BIN="$VENV_PATH/bin"
BOOTSTRAP_VERSION_PATH="$VENV_PATH/certbot-auto-bootstrap-version.txt"
LE_AUTO_VERSION="0.18.0.dev0" LE_AUTO_VERSION="0.18.0.dev0"
BASENAME=$(basename $0) BASENAME=$(basename $0)
USAGE="Usage: $BASENAME [OPTIONS] USAGE="Usage: $BASENAME [OPTIONS]
@@ -80,7 +81,7 @@ for arg in "$@" ; do
h) h)
HELP=1;; HELP=1;;
n) n)
ASSUME_YES=1;; NONINTERACTIVE=1;;
q) q)
QUIET=1;; QUIET=1;;
v) v)
@@ -96,8 +97,8 @@ if [ $BASENAME = "letsencrypt-auto" ]; then
HELP=0 HELP=0
fi fi
# Set ASSUME_YES to 1 if QUIET (i.e. --quiet implies --non-interactive) # Set ASSUME_YES to 1 if QUIET or NONINTERACTIVE
if [ "$QUIET" = 1 ]; then if [ "$QUIET" = 1 -o "$NONINTERACTIVE" = 1 ]; then
ASSUME_YES=1 ASSUME_YES=1
fi fi
@@ -256,6 +257,10 @@ DeterminePythonVersion() {
fi fi
} }
# If new packages are installed by BootstrapDebCommon below, this version
# number must be increased.
BOOTSTRAP_DEB_COMMON_VERSION=1
BootstrapDebCommon() { BootstrapDebCommon() {
# Current version tested with: # Current version tested with:
# #
@@ -372,6 +377,10 @@ BootstrapDebCommon() {
fi fi
} }
# If new packages are installed by BootstrapRpmCommon below, this version
# number must be increased.
BOOTSTRAP_RPM_COMMON_VERSION=1
BootstrapRpmCommon() { BootstrapRpmCommon() {
# Tested with: # Tested with:
# - Fedora 20, 21, 22, 23 (x64) # - Fedora 20, 21, 22, 23 (x64)
@@ -473,6 +482,10 @@ BootstrapRpmCommon() {
fi fi
} }
# If new packages are installed by BootstrapSuseCommon below, this version
# number must be increased.
BOOTSTRAP_SUSE_COMMON_VERSION=1
BootstrapSuseCommon() { BootstrapSuseCommon() {
# SLE12 don't have python-virtualenv # SLE12 don't have python-virtualenv
@@ -496,6 +509,10 @@ BootstrapSuseCommon() {
ca-certificates ca-certificates
} }
# If new packages are installed by BootstrapArchCommon below, this version
# number must be increased.
BOOTSTRAP_ARCH_COMMON_VERSION=1
BootstrapArchCommon() { BootstrapArchCommon() {
# Tested with: # Tested with:
# - ArchLinux (x86_64) # - ArchLinux (x86_64)
@@ -531,6 +548,10 @@ BootstrapArchCommon() {
fi fi
} }
# If new packages are installed by BootstrapGentooCommon below, this version
# number must be increased.
BOOTSTRAP_GENTOO_COMMON_VERSION=1
BootstrapGentooCommon() { BootstrapGentooCommon() {
PACKAGES=" PACKAGES="
dev-lang/python:2.7 dev-lang/python:2.7
@@ -559,6 +580,10 @@ BootstrapGentooCommon() {
esac esac
} }
# If new packages are installed by BootstrapFreeBsd below, this version number
# must be increased.
BOOTSTRAP_FREEBSD_VERSION=1
BootstrapFreeBsd() { BootstrapFreeBsd() {
if [ "$QUIET" = 1 ]; then if [ "$QUIET" = 1 ]; then
QUIET_FLAG="--quiet" QUIET_FLAG="--quiet"
@@ -571,6 +596,10 @@ BootstrapFreeBsd() {
libffi libffi
} }
# If new packages are installed by BootstrapMac below, this version number must
# be increased.
BOOTSTRAP_MAC_VERSION=1
BootstrapMac() { BootstrapMac() {
if hash brew 2>/dev/null; then if hash brew 2>/dev/null; then
say "Using Homebrew to install dependencies..." say "Using Homebrew to install dependencies..."
@@ -616,11 +645,19 @@ BootstrapMac() {
fi fi
} }
# If new packages are installed by BootstrapSmartOS below, this version number
# must be increased.
BOOTSTRAP_SMARTOS_VERSION=1
BootstrapSmartOS() { BootstrapSmartOS() {
pkgin update pkgin update
pkgin -y install 'gcc49' 'py27-augeas' 'py27-virtualenv' pkgin -y install 'gcc49' 'py27-augeas' 'py27-virtualenv'
} }
# If new packages are installed by BootstrapMageiaCommon below, this version
# number must be increased.
BOOTSTRAP_MAGEIA_COMMON_VERSION=1
BootstrapMageiaCommon() { BootstrapMageiaCommon() {
if [ "$QUIET" = 1 ]; then if [ "$QUIET" = 1 ]; then
QUIET_FLAG='--quiet' QUIET_FLAG='--quiet'
@@ -649,23 +686,41 @@ BootstrapMageiaCommon() {
} }
# Install required OS packages: # Set Bootstrap to the function that installs OS dependencies on this system
Bootstrap() { # and BOOTSTRAP_VERSION to the unique identifier for the current version of
if [ "$NO_BOOTSTRAP" = 1 ]; then # that function. If Bootstrap is set to a function that doesn't install any
return # packages (either because --no-bootstrap was included on the command line or
elif [ -f /etc/debian_version ]; then # we don't know how to bootstrap on this system), BOOTSTRAP_VERSION is not set.
if [ "$NO_BOOTSTRAP" = 1 ]; then
Bootstrap() {
:
}
elif [ -f /etc/debian_version ]; then
Bootstrap() {
BootstrapMessage "Debian-based OSes" BootstrapMessage "Debian-based OSes"
BootstrapDebCommon BootstrapDebCommon
elif [ -f /etc/mageia-release ]; then }
# Mageia has both /etc/mageia-release and /etc/redhat-release BOOTSTRAP_VERSION="BootstrapDebCommon $BOOTSTRAP_DEB_COMMON_VERSION"
elif [ -f /etc/mageia-release ]; then
# Mageia has both /etc/mageia-release and /etc/redhat-release
Bootstrap() {
ExperimentalBootstrap "Mageia" BootstrapMageiaCommon ExperimentalBootstrap "Mageia" BootstrapMageiaCommon
elif [ -f /etc/redhat-release ]; then }
BOOTSTRAP_VERSION="BootstrapMageiaCommon $BOOTSTRAP_MAGEIA_COMMON_VERSION"
elif [ -f /etc/redhat-release ]; then
Bootstrap() {
BootstrapMessage "RedHat-based OSes" BootstrapMessage "RedHat-based OSes"
BootstrapRpmCommon BootstrapRpmCommon
elif [ -f /etc/os-release ] && `grep -q openSUSE /etc/os-release` ; then }
BOOTSTRAP_VERSION="BootstrapRpmCommon $BOOTSTRAP_RPM_COMMON_VERSION"
elif [ -f /etc/os-release ] && `grep -q openSUSE /etc/os-release` ; then
Bootstrap() {
BootstrapMessage "openSUSE-based OSes" BootstrapMessage "openSUSE-based OSes"
BootstrapSuseCommon BootstrapSuseCommon
elif [ -f /etc/arch-release ]; then }
BOOTSTRAP_VERSION="BootstrapSuseCommon $BOOTSTRAP_SUSE_COMMON_VERSION"
elif [ -f /etc/arch-release ]; then
Bootstrap() {
if [ "$DEBUG" = 1 ]; then if [ "$DEBUG" = 1 ]; then
BootstrapMessage "Archlinux" BootstrapMessage "Archlinux"
BootstrapArchCommon BootstrapArchCommon
@@ -677,25 +732,76 @@ Bootstrap() {
error "--debug flag." error "--debug flag."
exit 1 exit 1
fi fi
elif [ -f /etc/manjaro-release ]; then }
BOOTSTRAP_VERSION="BootstrapArchCommon $BOOTSTRAP_ARCH_COMMON_VERSION"
elif [ -f /etc/manjaro-release ]; then
Bootstrap() {
ExperimentalBootstrap "Manjaro Linux" BootstrapArchCommon ExperimentalBootstrap "Manjaro Linux" BootstrapArchCommon
elif [ -f /etc/gentoo-release ]; then }
BOOTSTRAP_VERSION="BootstrapArchCommon $BOOTSTRAP_ARCH_COMMON_VERSION"
elif [ -f /etc/gentoo-release ]; then
Bootstrap() {
DeprecationBootstrap "Gentoo" BootstrapGentooCommon DeprecationBootstrap "Gentoo" BootstrapGentooCommon
elif uname | grep -iq FreeBSD ; then }
BOOTSTRAP_VERSION="BootstrapGentooCommon $BOOTSTRAP_GENTOO_COMMON_VERSION"
elif uname | grep -iq FreeBSD ; then
Bootstrap() {
DeprecationBootstrap "FreeBSD" BootstrapFreeBsd DeprecationBootstrap "FreeBSD" BootstrapFreeBsd
elif uname | grep -iq Darwin ; then }
BOOTSTRAP_VERSION="BootstrapFreeBsd $BOOTSTRAP_FREEBSD_VERSION"
elif uname | grep -iq Darwin ; then
Bootstrap() {
DeprecationBootstrap "macOS" BootstrapMac DeprecationBootstrap "macOS" BootstrapMac
elif [ -f /etc/issue ] && grep -iq "Amazon Linux" /etc/issue ; then }
BOOTSTRAP_VERSION="BootstrapMac $BOOTSTRAP_MAC_VERSION"
elif [ -f /etc/issue ] && grep -iq "Amazon Linux" /etc/issue ; then
Bootstrap() {
ExperimentalBootstrap "Amazon Linux" BootstrapRpmCommon ExperimentalBootstrap "Amazon Linux" BootstrapRpmCommon
elif [ -f /etc/product ] && grep -q "Joyent Instance" /etc/product ; then }
BOOTSTRAP_VERSION="BootstrapRpmCommon $BOOTSTRAP_RPM_COMMON_VERSION"
elif [ -f /etc/product ] && grep -q "Joyent Instance" /etc/product ; then
Bootstrap() {
ExperimentalBootstrap "Joyent SmartOS Zone" BootstrapSmartOS ExperimentalBootstrap "Joyent SmartOS Zone" BootstrapSmartOS
else }
BOOTSTRAP_VERSION="BootstrapSmartOS $BOOTSTRAP_SMARTOS_VERSION"
else
Bootstrap() {
error "Sorry, I don't know how to bootstrap Certbot on your operating system!" error "Sorry, I don't know how to bootstrap Certbot on your operating system!"
error error
error "You will need to install OS dependencies, configure virtualenv, and run pip install manually." error "You will need to install OS dependencies, configure virtualenv, and run pip install manually."
error "Please see https://letsencrypt.readthedocs.org/en/latest/contributing.html#prerequisites" error "Please see https://letsencrypt.readthedocs.org/en/latest/contributing.html#prerequisites"
error "for more info." error "for more info."
exit 1 exit 1
}
fi
# Sets PREV_BOOTSTRAP_VERSION to the identifier for the bootstrap script used
# to install OS dependencies on this system. PREV_BOOTSTRAP_VERSION isn't set
# if it is unknown how OS dependencies were installed on this system.
SetPrevBootstrapVersion() {
if [ -f $BOOTSTRAP_VERSION_PATH ]; then
PREV_BOOTSTRAP_VERSION=$(cat "$BOOTSTRAP_VERSION_PATH")
# The list below only contains bootstrap version strings that existed before
# we started writing them to disk.
#
# DO NOT MODIFY THIS LIST UNLESS YOU KNOW WHAT YOU'RE DOING!
elif grep -Fqx "$BOOTSTRAP_VERSION" << "UNLIKELY_EOF"
BootstrapDebCommon 1
BootstrapMageiaCommon 1
BootstrapRpmCommon 1
BootstrapSuseCommon 1
BootstrapArchCommon 1
BootstrapGentooCommon 1
BootstrapFreeBsd 1
BootstrapMac 1
BootstrapSmartOS 1
UNLIKELY_EOF
then
# If there's no bootstrap version saved to disk, but the currently selected
# bootstrap script is from before we started saving the version number,
# return the currently selected version to prevent us from rebootstrapping
# unnecessarily.
PREV_BOOTSTRAP_VERSION="$BOOTSTRAP_VERSION"
fi fi
} }
@@ -709,18 +815,39 @@ if [ "$1" = "--le-auto-phase2" ]; then
# Phase 2: Create venv, install LE, and run. # Phase 2: Create venv, install LE, and run.
shift 1 # the --le-auto-phase2 arg shift 1 # the --le-auto-phase2 arg
if [ -f "$VENV_BIN/letsencrypt" ]; then SetPrevBootstrapVersion
# --version output ran through grep due to python-cryptography DeprecationWarnings
# grep for both certbot and letsencrypt until certbot and shim packages have been released INSTALLED_VERSION="none"
INSTALLED_VERSION=$("$VENV_BIN/letsencrypt" --version 2>&1 | grep "^certbot\|^letsencrypt" | cut -d " " -f 2) if [ -d "$VENV_PATH" ]; then
if [ -z "$INSTALLED_VERSION" ]; then # If the selected Bootstrap function isn't a noop and it differs from the
error "Error: couldn't get currently installed version for $VENV_BIN/letsencrypt: " 1>&2 # previously used version
"$VENV_BIN/letsencrypt" --version if [ -n "$BOOTSTRAP_VERSION" -a "$BOOTSTRAP_VERSION" != "$PREV_BOOTSTRAP_VERSION" ]; then
exit 1 # if non-interactive mode or stdin and stdout are connected to a terminal
if [ \( "$NONINTERACTIVE" = 1 \) -o \( \( -t 0 \) -a \( -t 1 \) \) ]; then
rm -rf "$VENV_PATH"
"$0" "$@"
exit 0
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."
# Set INSTALLED_VERSION to be the same so we don't update the venv
INSTALLED_VERSION="$LE_AUTO_VERSION"
fi
elif [ -f "$VENV_BIN/letsencrypt" ]; then
# --version output ran through grep due to python-cryptography DeprecationWarnings
# grep for both certbot and letsencrypt until certbot and shim packages have been released
INSTALLED_VERSION=$("$VENV_BIN/letsencrypt" --version 2>&1 | grep "^certbot\|^letsencrypt" | cut -d " " -f 2)
if [ -z "$INSTALLED_VERSION" ]; then
error "Error: couldn't get currently installed version for $VENV_BIN/letsencrypt: " 1>&2
"$VENV_BIN/letsencrypt" --version
exit 1
fi
fi fi
else
INSTALLED_VERSION="none"
fi fi
if [ "$LE_AUTO_VERSION" != "$INSTALLED_VERSION" ]; then if [ "$LE_AUTO_VERSION" != "$INSTALLED_VERSION" ]; then
say "Creating virtual environment..." say "Creating virtual environment..."
DeterminePythonVersion DeterminePythonVersion
@@ -731,6 +858,12 @@ if [ "$1" = "--le-auto-phase2" ]; then
virtualenv --no-site-packages --python "$LE_PYTHON" "$VENV_PATH" > /dev/null virtualenv --no-site-packages --python "$LE_PYTHON" "$VENV_PATH" > /dev/null
fi fi
if [ -n "$BOOTSTRAP_VERSION" ]; then
echo "$BOOTSTRAP_VERSION" > "$BOOTSTRAP_VERSION_PATH"
elif [ -n "$PREV_BOOTSTRAP_VERSION" ]; then
echo "$PREV_BOOTSTRAP_VERSION" > "$BOOTSTRAP_VERSION_PATH"
fi
say "Installing Python packages..." say "Installing Python packages..."
TEMP_DIR=$(TempDir) TEMP_DIR=$(TempDir)
trap 'rm -rf "$TEMP_DIR"' EXIT trap 'rm -rf "$TEMP_DIR"' EXIT
+127 -30
View File
@@ -30,6 +30,7 @@ if [ -z "$VENV_PATH" ]; then
export VENV_PATH="/opt/eff.org/certbot/venv" export VENV_PATH="/opt/eff.org/certbot/venv"
fi fi
VENV_BIN="$VENV_PATH/bin" VENV_BIN="$VENV_PATH/bin"
BOOTSTRAP_VERSION_PATH="$VENV_PATH/certbot-auto-bootstrap-version.txt"
LE_AUTO_VERSION="{{ LE_AUTO_VERSION }}" LE_AUTO_VERSION="{{ LE_AUTO_VERSION }}"
BASENAME=$(basename $0) BASENAME=$(basename $0)
USAGE="Usage: $BASENAME [OPTIONS] USAGE="Usage: $BASENAME [OPTIONS]
@@ -80,7 +81,7 @@ for arg in "$@" ; do
h) h)
HELP=1;; HELP=1;;
n) n)
ASSUME_YES=1;; NONINTERACTIVE=1;;
q) q)
QUIET=1;; QUIET=1;;
v) v)
@@ -96,8 +97,8 @@ if [ $BASENAME = "letsencrypt-auto" ]; then
HELP=0 HELP=0
fi fi
# Set ASSUME_YES to 1 if QUIET (i.e. --quiet implies --non-interactive) # Set ASSUME_YES to 1 if QUIET or NONINTERACTIVE
if [ "$QUIET" = 1 ]; then if [ "$QUIET" = 1 -o "$NONINTERACTIVE" = 1 ]; then
ASSUME_YES=1 ASSUME_YES=1
fi fi
@@ -266,23 +267,41 @@ DeterminePythonVersion() {
{{ bootstrappers/smartos.sh }} {{ bootstrappers/smartos.sh }}
{{ bootstrappers/mageia_common.sh }} {{ bootstrappers/mageia_common.sh }}
# Install required OS packages: # Set Bootstrap to the function that installs OS dependencies on this system
Bootstrap() { # and BOOTSTRAP_VERSION to the unique identifier for the current version of
if [ "$NO_BOOTSTRAP" = 1 ]; then # that function. If Bootstrap is set to a function that doesn't install any
return # packages (either because --no-bootstrap was included on the command line or
elif [ -f /etc/debian_version ]; then # we don't know how to bootstrap on this system), BOOTSTRAP_VERSION is not set.
if [ "$NO_BOOTSTRAP" = 1 ]; then
Bootstrap() {
:
}
elif [ -f /etc/debian_version ]; then
Bootstrap() {
BootstrapMessage "Debian-based OSes" BootstrapMessage "Debian-based OSes"
BootstrapDebCommon BootstrapDebCommon
elif [ -f /etc/mageia-release ]; then }
# Mageia has both /etc/mageia-release and /etc/redhat-release BOOTSTRAP_VERSION="BootstrapDebCommon $BOOTSTRAP_DEB_COMMON_VERSION"
elif [ -f /etc/mageia-release ]; then
# Mageia has both /etc/mageia-release and /etc/redhat-release
Bootstrap() {
ExperimentalBootstrap "Mageia" BootstrapMageiaCommon ExperimentalBootstrap "Mageia" BootstrapMageiaCommon
elif [ -f /etc/redhat-release ]; then }
BOOTSTRAP_VERSION="BootstrapMageiaCommon $BOOTSTRAP_MAGEIA_COMMON_VERSION"
elif [ -f /etc/redhat-release ]; then
Bootstrap() {
BootstrapMessage "RedHat-based OSes" BootstrapMessage "RedHat-based OSes"
BootstrapRpmCommon BootstrapRpmCommon
elif [ -f /etc/os-release ] && `grep -q openSUSE /etc/os-release` ; then }
BOOTSTRAP_VERSION="BootstrapRpmCommon $BOOTSTRAP_RPM_COMMON_VERSION"
elif [ -f /etc/os-release ] && `grep -q openSUSE /etc/os-release` ; then
Bootstrap() {
BootstrapMessage "openSUSE-based OSes" BootstrapMessage "openSUSE-based OSes"
BootstrapSuseCommon BootstrapSuseCommon
elif [ -f /etc/arch-release ]; then }
BOOTSTRAP_VERSION="BootstrapSuseCommon $BOOTSTRAP_SUSE_COMMON_VERSION"
elif [ -f /etc/arch-release ]; then
Bootstrap() {
if [ "$DEBUG" = 1 ]; then if [ "$DEBUG" = 1 ]; then
BootstrapMessage "Archlinux" BootstrapMessage "Archlinux"
BootstrapArchCommon BootstrapArchCommon
@@ -294,25 +313,76 @@ Bootstrap() {
error "--debug flag." error "--debug flag."
exit 1 exit 1
fi fi
elif [ -f /etc/manjaro-release ]; then }
BOOTSTRAP_VERSION="BootstrapArchCommon $BOOTSTRAP_ARCH_COMMON_VERSION"
elif [ -f /etc/manjaro-release ]; then
Bootstrap() {
ExperimentalBootstrap "Manjaro Linux" BootstrapArchCommon ExperimentalBootstrap "Manjaro Linux" BootstrapArchCommon
elif [ -f /etc/gentoo-release ]; then }
BOOTSTRAP_VERSION="BootstrapArchCommon $BOOTSTRAP_ARCH_COMMON_VERSION"
elif [ -f /etc/gentoo-release ]; then
Bootstrap() {
DeprecationBootstrap "Gentoo" BootstrapGentooCommon DeprecationBootstrap "Gentoo" BootstrapGentooCommon
elif uname | grep -iq FreeBSD ; then }
BOOTSTRAP_VERSION="BootstrapGentooCommon $BOOTSTRAP_GENTOO_COMMON_VERSION"
elif uname | grep -iq FreeBSD ; then
Bootstrap() {
DeprecationBootstrap "FreeBSD" BootstrapFreeBsd DeprecationBootstrap "FreeBSD" BootstrapFreeBsd
elif uname | grep -iq Darwin ; then }
BOOTSTRAP_VERSION="BootstrapFreeBsd $BOOTSTRAP_FREEBSD_VERSION"
elif uname | grep -iq Darwin ; then
Bootstrap() {
DeprecationBootstrap "macOS" BootstrapMac DeprecationBootstrap "macOS" BootstrapMac
elif [ -f /etc/issue ] && grep -iq "Amazon Linux" /etc/issue ; then }
BOOTSTRAP_VERSION="BootstrapMac $BOOTSTRAP_MAC_VERSION"
elif [ -f /etc/issue ] && grep -iq "Amazon Linux" /etc/issue ; then
Bootstrap() {
ExperimentalBootstrap "Amazon Linux" BootstrapRpmCommon ExperimentalBootstrap "Amazon Linux" BootstrapRpmCommon
elif [ -f /etc/product ] && grep -q "Joyent Instance" /etc/product ; then }
BOOTSTRAP_VERSION="BootstrapRpmCommon $BOOTSTRAP_RPM_COMMON_VERSION"
elif [ -f /etc/product ] && grep -q "Joyent Instance" /etc/product ; then
Bootstrap() {
ExperimentalBootstrap "Joyent SmartOS Zone" BootstrapSmartOS ExperimentalBootstrap "Joyent SmartOS Zone" BootstrapSmartOS
else }
BOOTSTRAP_VERSION="BootstrapSmartOS $BOOTSTRAP_SMARTOS_VERSION"
else
Bootstrap() {
error "Sorry, I don't know how to bootstrap Certbot on your operating system!" error "Sorry, I don't know how to bootstrap Certbot on your operating system!"
error error
error "You will need to install OS dependencies, configure virtualenv, and run pip install manually." error "You will need to install OS dependencies, configure virtualenv, and run pip install manually."
error "Please see https://letsencrypt.readthedocs.org/en/latest/contributing.html#prerequisites" error "Please see https://letsencrypt.readthedocs.org/en/latest/contributing.html#prerequisites"
error "for more info." error "for more info."
exit 1 exit 1
}
fi
# Sets PREV_BOOTSTRAP_VERSION to the identifier for the bootstrap script used
# to install OS dependencies on this system. PREV_BOOTSTRAP_VERSION isn't set
# if it is unknown how OS dependencies were installed on this system.
SetPrevBootstrapVersion() {
if [ -f $BOOTSTRAP_VERSION_PATH ]; then
PREV_BOOTSTRAP_VERSION=$(cat "$BOOTSTRAP_VERSION_PATH")
# The list below only contains bootstrap version strings that existed before
# we started writing them to disk.
#
# DO NOT MODIFY THIS LIST UNLESS YOU KNOW WHAT YOU'RE DOING!
elif grep -Fqx "$BOOTSTRAP_VERSION" << "UNLIKELY_EOF"
BootstrapDebCommon 1
BootstrapMageiaCommon 1
BootstrapRpmCommon 1
BootstrapSuseCommon 1
BootstrapArchCommon 1
BootstrapGentooCommon 1
BootstrapFreeBsd 1
BootstrapMac 1
BootstrapSmartOS 1
UNLIKELY_EOF
then
# If there's no bootstrap version saved to disk, but the currently selected
# bootstrap script is from before we started saving the version number,
# return the currently selected version to prevent us from rebootstrapping
# unnecessarily.
PREV_BOOTSTRAP_VERSION="$BOOTSTRAP_VERSION"
fi fi
} }
@@ -326,18 +396,39 @@ if [ "$1" = "--le-auto-phase2" ]; then
# Phase 2: Create venv, install LE, and run. # Phase 2: Create venv, install LE, and run.
shift 1 # the --le-auto-phase2 arg shift 1 # the --le-auto-phase2 arg
if [ -f "$VENV_BIN/letsencrypt" ]; then SetPrevBootstrapVersion
# --version output ran through grep due to python-cryptography DeprecationWarnings
# grep for both certbot and letsencrypt until certbot and shim packages have been released INSTALLED_VERSION="none"
INSTALLED_VERSION=$("$VENV_BIN/letsencrypt" --version 2>&1 | grep "^certbot\|^letsencrypt" | cut -d " " -f 2) if [ -d "$VENV_PATH" ]; then
if [ -z "$INSTALLED_VERSION" ]; then # If the selected Bootstrap function isn't a noop and it differs from the
error "Error: couldn't get currently installed version for $VENV_BIN/letsencrypt: " 1>&2 # previously used version
"$VENV_BIN/letsencrypt" --version if [ -n "$BOOTSTRAP_VERSION" -a "$BOOTSTRAP_VERSION" != "$PREV_BOOTSTRAP_VERSION" ]; then
exit 1 # if non-interactive mode or stdin and stdout are connected to a terminal
if [ \( "$NONINTERACTIVE" = 1 \) -o \( \( -t 0 \) -a \( -t 1 \) \) ]; then
rm -rf "$VENV_PATH"
"$0" "$@"
exit 0
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."
# Set INSTALLED_VERSION to be the same so we don't update the venv
INSTALLED_VERSION="$LE_AUTO_VERSION"
fi
elif [ -f "$VENV_BIN/letsencrypt" ]; then
# --version output ran through grep due to python-cryptography DeprecationWarnings
# grep for both certbot and letsencrypt until certbot and shim packages have been released
INSTALLED_VERSION=$("$VENV_BIN/letsencrypt" --version 2>&1 | grep "^certbot\|^letsencrypt" | cut -d " " -f 2)
if [ -z "$INSTALLED_VERSION" ]; then
error "Error: couldn't get currently installed version for $VENV_BIN/letsencrypt: " 1>&2
"$VENV_BIN/letsencrypt" --version
exit 1
fi
fi fi
else
INSTALLED_VERSION="none"
fi fi
if [ "$LE_AUTO_VERSION" != "$INSTALLED_VERSION" ]; then if [ "$LE_AUTO_VERSION" != "$INSTALLED_VERSION" ]; then
say "Creating virtual environment..." say "Creating virtual environment..."
DeterminePythonVersion DeterminePythonVersion
@@ -348,6 +439,12 @@ if [ "$1" = "--le-auto-phase2" ]; then
virtualenv --no-site-packages --python "$LE_PYTHON" "$VENV_PATH" > /dev/null virtualenv --no-site-packages --python "$LE_PYTHON" "$VENV_PATH" > /dev/null
fi fi
if [ -n "$BOOTSTRAP_VERSION" ]; then
echo "$BOOTSTRAP_VERSION" > "$BOOTSTRAP_VERSION_PATH"
elif [ -n "$PREV_BOOTSTRAP_VERSION" ]; then
echo "$PREV_BOOTSTRAP_VERSION" > "$BOOTSTRAP_VERSION_PATH"
fi
say "Installing Python packages..." say "Installing Python packages..."
TEMP_DIR=$(TempDir) TEMP_DIR=$(TempDir)
trap 'rm -rf "$TEMP_DIR"' EXIT trap 'rm -rf "$TEMP_DIR"' EXIT
@@ -1,3 +1,7 @@
# If new packages are installed by BootstrapArchCommon below, this version
# number must be increased.
BOOTSTRAP_ARCH_COMMON_VERSION=1
BootstrapArchCommon() { BootstrapArchCommon() {
# Tested with: # Tested with:
# - ArchLinux (x86_64) # - ArchLinux (x86_64)
@@ -1,3 +1,7 @@
# If new packages are installed by BootstrapDebCommon below, this version
# number must be increased.
BOOTSTRAP_DEB_COMMON_VERSION=1
BootstrapDebCommon() { BootstrapDebCommon() {
# Current version tested with: # Current version tested with:
# #
@@ -1,3 +1,7 @@
# If new packages are installed by BootstrapFreeBsd below, this version number
# must be increased.
BOOTSTRAP_FREEBSD_VERSION=1
BootstrapFreeBsd() { BootstrapFreeBsd() {
if [ "$QUIET" = 1 ]; then if [ "$QUIET" = 1 ]; then
QUIET_FLAG="--quiet" QUIET_FLAG="--quiet"
@@ -1,3 +1,7 @@
# If new packages are installed by BootstrapGentooCommon below, this version
# number must be increased.
BOOTSTRAP_GENTOO_COMMON_VERSION=1
BootstrapGentooCommon() { BootstrapGentooCommon() {
PACKAGES=" PACKAGES="
dev-lang/python:2.7 dev-lang/python:2.7
@@ -1,3 +1,7 @@
# If new packages are installed by BootstrapMac below, this version number must
# be increased.
BOOTSTRAP_MAC_VERSION=1
BootstrapMac() { BootstrapMac() {
if hash brew 2>/dev/null; then if hash brew 2>/dev/null; then
say "Using Homebrew to install dependencies..." say "Using Homebrew to install dependencies..."
@@ -1,3 +1,7 @@
# If new packages are installed by BootstrapMageiaCommon below, this version
# number must be increased.
BOOTSTRAP_MAGEIA_COMMON_VERSION=1
BootstrapMageiaCommon() { BootstrapMageiaCommon() {
if [ "$QUIET" = 1 ]; then if [ "$QUIET" = 1 ]; then
QUIET_FLAG='--quiet' QUIET_FLAG='--quiet'
@@ -1,3 +1,7 @@
# If new packages are installed by BootstrapRpmCommon below, this version
# number must be increased.
BOOTSTRAP_RPM_COMMON_VERSION=1
BootstrapRpmCommon() { BootstrapRpmCommon() {
# Tested with: # Tested with:
# - Fedora 20, 21, 22, 23 (x64) # - Fedora 20, 21, 22, 23 (x64)
@@ -1,3 +1,7 @@
# If new packages are installed by BootstrapSmartOS below, this version number
# must be increased.
BOOTSTRAP_SMARTOS_VERSION=1
BootstrapSmartOS() { BootstrapSmartOS() {
pkgin update pkgin update
pkgin -y install 'gcc49' 'py27-augeas' 'py27-virtualenv' pkgin -y install 'gcc49' 'py27-augeas' 'py27-virtualenv'
@@ -1,3 +1,7 @@
# If new packages are installed by BootstrapSuseCommon below, this version
# number must be increased.
BOOTSTRAP_SUSE_COMMON_VERSION=1
BootstrapSuseCommon() { BootstrapSuseCommon() {
# SLE12 don't have python-virtualenv # SLE12 don't have python-virtualenv