diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/php/install.sh | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/php/install.sh b/src/php/install.sh index f922a69..8fb49a3 100755 --- a/src/php/install.sh +++ b/src/php/install.sh @@ -11,7 +11,7 @@ set -eux # Clean up rm -rf /var/lib/apt/lists/* -VERSION=${VERSION:-"latest"} +PHP_VERSION=${VERSION:-"latest"} INSTALL_COMPOSER=${INSTALLCOMPOSER:-"true"} OVERRIDE_DEFAULT_VERSION=${OVERRIDEDEFAULTVERSION:-"true"} @@ -20,7 +20,7 @@ USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}" UPDATE_RC=${UPDATE_RC:-"true"} # Comma-separated list of php versions to be installed -# alongside VERSION, but not set as default. +# alongside PHP_VERSION, but not set as default. ADDITIONAL_VERSIONS=${ADDITIONALVERSIONS:-""} export DEBIAN_FRONTEND=noninteractive @@ -92,7 +92,7 @@ find_version_from_git_tags() { local last_part="${escaped_separator}[0-9]+" local regex="\\K[0-9]+${escaped_separator}[0-9]+${last_part}$" local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)" - VERSION="$(echo "${version_list}" | head -n 1)" + PHP_VERSION="$(echo "${version_list}" | head -n 1)" } # Install PHP Composer @@ -112,8 +112,15 @@ addcomposer() { # Persistent / runtime dependencies RUNTIME_DEPS="wget ca-certificates git build-essential xz-utils" +. /etc/os-release +LIBARGON_DEP="libargon2-dev" + +if [[ "bionic" = *"${VERSION_CODENAME}"* ]]; then + LIBARGON_DEP="libargon2-0-dev" +fi + # PHP dependencies -PHP_DEPS="libssl-dev libcurl4-openssl-dev libedit-dev libsqlite3-dev libxml2-dev zlib1g-dev libsodium-dev libargon2-dev libonig-dev" +PHP_DEPS="libssl-dev libcurl4-openssl-dev libedit-dev libsqlite3-dev libxml2-dev zlib1g-dev libsodium-dev ${LIBARGON_DEP} libonig-dev" # Dependencies required for running "phpize" PHPIZE_DEPS="autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2c" @@ -122,16 +129,16 @@ PHPIZE_DEPS="autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2c" check_packages $RUNTIME_DEPS $PHP_DEPS $PHPIZE_DEPS install_php() { - VERSION="$1" + PHP_VERSION="$1" # Fetch latest version of PHP if needed - if [ "${VERSION}" = "latest" ] || [ "${VERSION}" = "lts" ]; then + if [ "${PHP_VERSION}" = "latest" ] || [ "${PHP_VERSION}" = "lts" ]; then find_version_from_git_tags fi - PHP_INSTALL_DIR="${PHP_DIR}/${VERSION}" + PHP_INSTALL_DIR="${PHP_DIR}/${PHP_VERSION}" if [ -d "${PHP_INSTALL_DIR}" ]; then - echo "(!) PHP version ${VERSION} already exists." + echo "(!) PHP version ${PHP_VERSION} already exists." exit 1 fi @@ -140,7 +147,7 @@ install_php() { fi usermod -a -G php "${USERNAME}" - PHP_URL="https://www.php.net/distributions/php-${VERSION}.tar.gz" + PHP_URL="https://www.php.net/distributions/php-${PHP_VERSION}.tar.gz" PHP_INI_DIR="${PHP_INSTALL_DIR}/ini" CONF_DIR="${PHP_INI_DIR}/conf.d" @@ -160,7 +167,7 @@ install_php() { # PHP 7.4+, the pecl/pear installers are officially deprecated and are removed in PHP 8+ # Thus, requiring an explicit "--with-pear" IFS="." - read -a versions <<< "${VERSION}" + read -a versions <<< "${PHP_VERSION}" PHP_MAJOR_VERSION=${versions[0]} PHP_MINOR_VERSION=${versions[1]} @@ -210,7 +217,7 @@ install_php() { updaterc "if [[ \"\${PATH}\" != *\"${CURRENT_DIR}\"* ]]; then export PATH=\"${CURRENT_DIR}/bin:\${PATH}\"; fi" } -install_php "${VERSION}" +install_php "${PHP_VERSION}" # Additional php versions to be installed but not be set as default. if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then |