From b19c1882b7074482a0cd7e2782f4d42f2a1677d1 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Tue, 10 Dec 2019 08:55:09 +0100 Subject: [PATCH 01/12] Prepare for Alpine support --- .travis.yml | 33 ++++++++++++------- README.md | 10 +++--- ...ew-extensions => travisci-test-extensions} | 28 ++++++++++------ 3 files changed, 46 insertions(+), 25 deletions(-) rename scripts/{travisci-test-new-extensions => travisci-test-extensions} (86%) diff --git a/.travis.yml b/.travis.yml index 8526d46..7adc463 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,33 @@ sudo: false +notifications: + email: false + branches: only: - - master + - master services: - docker -env: - global: - - secure: "vsl8z41oBky/MDRDKqs74Bif6BJldCPFVdl2lbPcjehOYG5cZ4YRLIEuhgJfnOglCGdyY6gh/2umSowRI4r5mC/ZR42RKJzWj9xQX2usJbzeOeZj+5eQv5im1DVwRmigUMzQOS743bd/zEeR9J3MLMgTGhKWEPKOJI6CHseUIKazAc0Z8vH6055YtkhGMqnolOe9h0gJx/sLP18qo2LTw82SyjOAMfbyYuHpiLznAqIOpNtwyj9WAujE3qN2oCo+9ALOnnrlINPqeLjnIOxRcSgYO4wIGPGSXIDTquuUht0McszOLuC9/kc6RybcyxmcqsssYRK2y0DQuavzyja5UaB4Pzf2vMrlbozAxdtF3oadZzfsAYfbhzaLbx0g1aAzL1CTJvXrWkZQgiy2c7tboXKJ3SvOqDp+GXEw08kCTpUq1AYSLw8ExlqcWZGiQxJfnfA05fWOkf8xM38ZQ+LPUHyGrt+PIw8FPAGhOV4E+BmHUlOoXOwoNllCEJ4QNkwxYT90eAMS5Rw8q6KASedwDFwyPCv8VtpNEtsl/FVa3m8/6wA7QmtuPxg7E2wceSkzsqHEcGLzERb4DnhVfrW0wv8zRw92vsnBmZdxusBT5uuyp9h5asjj6YhhVJ52g2NdCAGJlobiPk5X4uifshcdlcS8vF/jBMpI03XyJU4V4xc=" +test-extensions-job-template: &test-extensions-job-template + stage: Test extensions + if: type = pull_request + script: ./scripts/travisci-test-extensions -install: - - true +jobs: + include: + - <<: *test-extensions-job-template + name: Test extensions on Alpine Linux + env: DOCKER_DISTRO=alpine -script: - - if test "${TRAVIS_EVENT_TYPE:-}" = 'pull_request'; then ./scripts/travisci-test-new-extensions; fi - - if test "${TRAVIS_EVENT_TYPE:-}" = 'push' && test "${TRAVIS_BRANCH:-}" = 'master'; then ./scripts/travisci-update-readme; fi + - <<: *test-extensions-job-template + name: Test extensions on Debian Linux + env: DOCKER_DISTRO=debian -notifications: - email: false \ No newline at end of file + - stage: Update docs + name: Update README.md + if: branch = master AND type = push + env: + - secure: "vsl8z41oBky/MDRDKqs74Bif6BJldCPFVdl2lbPcjehOYG5cZ4YRLIEuhgJfnOglCGdyY6gh/2umSowRI4r5mC/ZR42RKJzWj9xQX2usJbzeOeZj+5eQv5im1DVwRmigUMzQOS743bd/zEeR9J3MLMgTGhKWEPKOJI6CHseUIKazAc0Z8vH6055YtkhGMqnolOe9h0gJx/sLP18qo2LTw82SyjOAMfbyYuHpiLznAqIOpNtwyj9WAujE3qN2oCo+9ALOnnrlINPqeLjnIOxRcSgYO4wIGPGSXIDTquuUht0McszOLuC9/kc6RybcyxmcqsssYRK2y0DQuavzyja5UaB4Pzf2vMrlbozAxdtF3oadZzfsAYfbhzaLbx0g1aAzL1CTJvXrWkZQgiy2c7tboXKJ3SvOqDp+GXEw08kCTpUq1AYSLw8ExlqcWZGiQxJfnfA05fWOkf8xM38ZQ+LPUHyGrt+PIw8FPAGhOV4E+BmHUlOoXOwoNllCEJ4QNkwxYT90eAMS5Rw8q6KASedwDFwyPCv8VtpNEtsl/FVa3m8/6wA7QmtuPxg7E2wceSkzsqHEcGLzERb4DnhVfrW0wv8zRw92vsnBmZdxusBT5uuyp9h5asjj6YhhVJ52g2NdCAGJlobiPk5X4uifshcdlcS8vF/jBMpI03XyJU4V4xc=" + script: ./scripts/travisci-update-readme diff --git a/README.md b/README.md index aa38a97..58fc04f 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,7 @@ This repository contains a script that can be used to easily install a PHP extension inside the [official PHP Docker images](https://hub.docker.com/_/php/). - -## Known limits - -Currently the script requires the Debian-based images (no Alpine). +The script works both for Alpine and Debian Linux. ## Usage @@ -157,3 +154,8 @@ Some extension has special requirements: Test: gd, zip ``` + + +## Do you want to really say thank you? + +You can offer me a [monthly coffee](https://github.com/sponsors/mlocati) or a [one-time coffee](https://paypal.me/mlocati) :wink: diff --git a/scripts/travisci-test-new-extensions b/scripts/travisci-test-extensions similarity index 86% rename from scripts/travisci-test-new-extensions rename to scripts/travisci-test-extensions index 572ca57..bf48a99 100755 --- a/scripts/travisci-test-new-extensions +++ b/scripts/travisci-test-extensions @@ -26,20 +26,28 @@ fi # # Outputs: # the full docker image ID -getExtensionImage () { +getDockerImageName () { case "${2}" in *) - getExtensionImage_version="${2}" + getDockerImageName_version="${2}" ;; esac - getExtensionImage_result="php:${getExtensionImage_version}-cli" - getExtensionImage_reqs="${TRAVIS_BUILD_DIR}/data/special-requirements" - if test -f "${getExtensionImage_reqs}"; then - if test -n "$(cat "${getExtensionImage_reqs}" | grep -E "^${1}[ \t]+zts[ \t]*$")"; then - getExtensionImage_result="php:${getExtensionImage_version}-zts" + getDockerImageName_suffix='-cli' + getDockerImageName_reqs="${TRAVIS_BUILD_DIR}/data/special-requirements" + if test -f "${getDockerImageName_reqs}"; then + if test -n "$(cat "${getDockerImageName_reqs}" | grep -E "^${1}[ \t]+zts[ \t]*$")"; then + getDockerImageName_suffix="-zts" fi fi - printf '%s' "${getExtensionImage_result}" + case "${DOCKER_DISTRO:-}" in + alpine) + getDockerImageName_distro="-$DOCKER_DISTRO" + ;; + *) + getDockerImageName_distro='' + ;; + esac + printf 'php:%s%s%s' "${getDockerImageName_version}" "${getDockerImageName_suffix}" "${getDockerImageName_distro}" } @@ -58,10 +66,10 @@ testExtension () { printf ' INVALID PHP VERSION: %s\n' "${2}" >&2 return 1 fi - testExtension_Image="$(getExtensionImage "${1}" "${2}")" + testExtension_Image="$(getDockerImageName "${1}" "${2}")" printf ' - Docker image: %s\n' "${testExtension_Image}" testExtension_out=`mktemp` - if $(docker run --rm --volume "${TRAVIS_BUILD_DIR}:/app" --workdir /app "${testExtension_Image}" bash -c "./install-php-extensions '${1}' && php ./scripts/check-installed-extension.php '${1}'" >"${testExtension_out}" 2>&1); then + if $(docker run --rm --volume "${TRAVIS_BUILD_DIR}:/app" --workdir /app "${testExtension_Image}" sh -c "./install-php-extensions --cleanup '${1}' && php ./scripts/check-installed-extension.php '${1}'" >"${testExtension_out}" 2>&1); then rm -rf "${testExtension_out}" printf ' - Passed\n' return 0 From f164c691cdafd0b10242a4bb251ed6b96e59f2d8 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Tue, 10 Dec 2019 09:06:30 +0100 Subject: [PATCH 02/12] Continue implementing Alpine support Test: amqp, apcu, bcmath, bz2, calendar, cmark, dba, enchant, exif, gd, gettext, gmp, igbinary, imagick, imap --- README.md | 6 +- install-php-extensions | 682 +++++++++++++++++++------------ scripts/travisci-test-extensions | 2 +- 3 files changed, 420 insertions(+), 270 deletions(-) diff --git a/README.md b/README.md index 58fc04f..764491a 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,7 @@ COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr RUN install-php-extensions gd xdebug ``` -`install-php-extensions` will install all the required APT packages. -If you want to remove the APT development packages (which shouldn't be needed after the PHP extensions have been installed) and other no longer required packages, you can use the `--cleanup` option (**EXPERIMENTAL**): -``` -install-php-extensions --cleanup gd xdebug -``` +`install-php-extensions` will install all the required APT/APK packages; at the end of the script execution, the no-more needed packages will be removed. ## Supported PHP extensions diff --git a/install-php-extensions b/install-php-extensions index dd0801f..4dec79a 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -18,6 +18,29 @@ resetIFS () { ' } +# Get the distribution name +# +# Output: +# alpine|debian +getDistro () { + getDistro_os_id='' + if test -r /etc/os-release; then + getDistro_os_id="$(cat /etc/os-release | grep -E ^ID= | cut -d = -f 2)" + case "$getDistro_os_id" in + alpine|debian) + ;; + *) + getDistro_os_id='' + ;; + esac + fi + if test -n "$getDistro_os_id"; then + printf '%s' "$getDistro_os_id" + else + printf '%s' 'debian' + fi +} + # Get the PHP Major-Minor version as an integer value, in format MMmm (example: 506 for PHP 5.6.15) # # Output: @@ -36,33 +59,33 @@ getPHPInstalledModules () { ' for getPHPInstalledModules_module in $(php -m); do getPHPInstalledModules_moduleNormalized='' - case "${getPHPInstalledModules_module}" in + case "$getPHPInstalledModules_module" in \[PHP\ Modules\]) ;; \[Zend\ Modules\]) break ;; Core|PDO|PDO_*|Phar|Reflection|SimpleXML|SPL|SQLite|Xdebug) - getPHPInstalledModules_moduleNormalized=$(LC_CTYPE=C printf '%s' "${getPHPInstalledModules_module}" | tr '[:upper:]' '[:lower:]') + getPHPInstalledModules_moduleNormalized=$(LC_CTYPE=C printf '%s' "$getPHPInstalledModules_module" | tr '[:upper:]' '[:lower:]') ;; Zend\ OPcache) getPHPInstalledModules_moduleNormalized='opcache' ;; *\ *|*A*|*B*|*C*|*D*|*E*|*F*|*G*|*H*|*I*|*J*|*K*|*L*|*M*|*N*|*O*|*P*|*Q*|*R*|*S*|*T*|*U*|*V*|*W*|*X*|*Y*|*Z*) - printf '### WARNING Unrecognized module name: %s ###\n' "${getPHPInstalledModules_module}" >&2 + printf '### WARNING Unrecognized module name: %s ###\n' "$getPHPInstalledModules_module" >&2 ;; *) - getPHPInstalledModules_moduleNormalized="${getPHPInstalledModules_module}" + getPHPInstalledModules_moduleNormalized="$getPHPInstalledModules_module" ;; esac - if test -n "${getPHPInstalledModules_moduleNormalized}"; then - if ! stringInList "${getPHPInstalledModules_moduleNormalized}" "${getPHPInstalledModules_result}"; then - getPHPInstalledModules_result="${getPHPInstalledModules_result} ${getPHPInstalledModules_moduleNormalized}" + if test -n "$getPHPInstalledModules_moduleNormalized"; then + if ! stringInList "$getPHPInstalledModules_moduleNormalized" "$getPHPInstalledModules_result"; then + getPHPInstalledModules_result="$getPHPInstalledModules_result $getPHPInstalledModules_moduleNormalized" fi fi done resetIFS - printf '%s' "${getPHPInstalledModules_result}" + printf '%s' "${getPHPInstalledModules_result# }" } # Get the handles of the modules to be installed @@ -71,48 +94,47 @@ getPHPInstalledModules () { # $@: all module handles # # Set: -# DO_APT_REMOVE # PHP_MODULES_TO_INSTALL # # Output: # Nothing -getModulesToInstall () { - getModulesToInstall_alreadyInstalled="$(getPHPInstalledModules)" - getModulesToInstall_endArgs='' - DO_APT_REMOVE='' +processCommandArguments () { + processCommandArguments_alreadyInstalled="$(getPHPInstalledModules)" + processCommandArguments_endArgs=0 PHP_MODULES_TO_INSTALL='' while :; do if test $# -lt 1; then break fi - getModulesToInstall_skip='' - if test -z "${getModulesToInstall_endArgs}"; then - case "${1}" in + processCommandArguments_skip=0 + if test $processCommandArguments_endArgs -eq 0; then + case "$1" in --cleanup) - getModulesToInstall_skip='y' - DO_APT_REMOVE='y' + printf '### WARNING the --cleanup option is deprecated (we always cleanup everything) ###\n' "$1" >&2 + processCommandArguments_skip=1 ;; --) - getModulesToInstall_skip='y' - getModulesToInstall_endArgs='y' + processCommandArguments_skip=1 + processCommandArguments_endArgs=1 ;; -*) - printf 'Unrecognized option: %s\n' "${1}" >&2 + printf 'Unrecognized option: %s\n' "$1" >&2 exit 1 ;; esac fi - if test -z "${getModulesToInstall_skip}"; then - if stringInList "${1}" "${PHP_MODULES_TO_INSTALL}"; then - printf '### WARNING Duplicated module name specified: %s ###\n' "${1}" >&2 - elif stringInList "${1}" "${getModulesToInstall_alreadyInstalled}"; then - printf '### WARNING Module already installed: %s ###\n' "${1}" >&2 + if test $processCommandArguments_skip -eq 0; then + if stringInList "$1" "$PHP_MODULES_TO_INSTALL"; then + printf '### WARNING Duplicated module name specified: %s ###\n' "$1" >&2 + elif stringInList "$1" "$processCommandArguments_alreadyInstalled"; then + printf '### WARNING Module already installed: %s ###\n' "$1" >&2 else - PHP_MODULES_TO_INSTALL="${PHP_MODULES_TO_INSTALL} ${1}" + PHP_MODULES_TO_INSTALL="$PHP_MODULES_TO_INSTALL $1" fi fi shift done + PHP_MODULES_TO_INSTALL="${PHP_MODULES_TO_INSTALL# }" } # Sort the modules to be installed, in order to fix dependencies @@ -123,16 +145,16 @@ getModulesToInstall () { # Output: # Nothing sortModulesToInstall () { - if stringInList 'igbinary' "${PHP_MODULES_TO_INSTALL}"; then - PHP_MODULES_TO_INSTALL="$(removeStringFromList 'igbinary' "${PHP_MODULES_TO_INSTALL}")" + if stringInList 'igbinary' "$PHP_MODULES_TO_INSTALL"; then + PHP_MODULES_TO_INSTALL="$(removeStringFromList 'igbinary' "$PHP_MODULES_TO_INSTALL")" if test -z "$PHP_MODULES_TO_INSTALL"; then PHP_MODULES_TO_INSTALL='igbinary' else PHP_MODULES_TO_INSTALL="igbinary $PHP_MODULES_TO_INSTALL" fi fi - if stringInList 'msgpack' "${PHP_MODULES_TO_INSTALL}"; then - PHP_MODULES_TO_INSTALL="$(removeStringFromList 'msgpack' "${PHP_MODULES_TO_INSTALL}")" + if stringInList 'msgpack' "$PHP_MODULES_TO_INSTALL"; then + PHP_MODULES_TO_INSTALL="$(removeStringFromList 'msgpack' "$PHP_MODULES_TO_INSTALL")" if test -z "$PHP_MODULES_TO_INSTALL"; then PHP_MODULES_TO_INSTALL='msgpack' else @@ -141,175 +163,295 @@ sortModulesToInstall () { fi } -# Get the required APT packages for a specific PHP version and for the list of module handles +# Get the required APT/APK packages for a specific PHP version and for the list of module handles # # Arguments: # $1: the numeric PHP Major-Minor version # $@: the PHP module handles # -# Output: -# Space-separated list of APT packages -getRequiredAptPackages () { - getRequiredAptPackages_result='' - getRequiredAptPackages_phpv=${1} +# Set: +# PACKAGES_PERSISTENT +# PACKAGES_VOLATILE +# +# Return: +# 0 (true): if we to install some package +# 1 (false): if no package is required +buildRequiredPackageLists () { + buildRequiredPackageLists_persistent='' + buildRequiredPackageLists_volatile='' + buildRequiredPackageLists_distro="$(getDistro)" + buildRequiredPackageLists_phpv=$1 while :; do if test $# -lt 2; then break fi shift - case "${1}" in - amqp) - getRequiredAptPackages_result="${getRequiredAptPackages_result} librabbitmq-dev libssh-dev" + case "$1@$buildRequiredPackageLists_distro" in + amqp@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent rabbitmq-c" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS rabbitmq-c-dev" ;; - bz2) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libbz2-dev" + amqp@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent librabbitmq4" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile librabbitmq-dev libssh-dev" ;; - cmark) - getRequiredAptPackages_result="${getRequiredAptPackages_result} cmake" + apcu@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile autoconf g++ make" ;; - enchant) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libenchant-dev" + bz2@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libbz2" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile bzip2-dev" ;; - gd) - if test $getRequiredAptPackages_phpv -lt 700; then - getRequiredAptPackages_result="${getRequiredAptPackages_result} libvpx-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libfreetype6-dev" + bz2@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libbz2-dev" + ;; + cmark@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile cmake make g++ autoconf" + ;; + cmark@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile cmake" + ;; + enchant@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent enchant" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile enchant-dev" + ;; + enchant@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libenchant1c2a" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libenchant-dev" + ;; + gd@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent freetype libjpeg-turbo libpng libxpm" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetype-dev libjpeg-turbo-dev libpng-dev libxpm-dev" + if test $buildRequiredPackageLists_phpv -le 506; then + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libvpx" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libvpx-dev" else - getRequiredAptPackages_result="${getRequiredAptPackages_result} libwebp-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libfreetype6-dev" + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libwebp" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libwebp-dev" fi ;; - gmp) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libgmp-dev" + gd@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libfreetype6 libjpeg62-turbo libpng16-16 libxpm4" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libfreetype6-dev libjpeg62-turbo-dev libpng-dev libxpm-dev" + if test $buildRequiredPackageLists_phpv -le 506; then + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libvpx?" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libvpx-dev" + else + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libwebp6" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libwebp-dev" + fi ;; - imap) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libc-client-dev libkrb5-dev" + gettext@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libintl" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile gettext-dev" ;; - interbase) - getRequiredAptPackages_result="${getRequiredAptPackages_result} firebird-dev libib-util" + gmp@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent gmp" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile gmp-dev" ;; - imagick) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libmagickwand-dev" + gmp@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libgmp-dev" ;; - intl) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libicu-dev" + igbinary@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile autoconf g++ make" ;; - ldap) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libldap2-dev" + imagick@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent imagemagick" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile imagemagick-dev autoconf g++ make re2c" ;; - memcache) - getRequiredAptPackages_result="${getRequiredAptPackages_result} zlib1g-dev" + imagick@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libmagickwand-6.q16-?" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libmagickwand-dev" ;; - memcached) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libmemcached-dev zlib1g-dev" + imap@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent c-client" + if test -z "$(apk info | grep -E ^libssl)"; then + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libssl1.0" + fi + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile krb5-dev imap-dev openssl openssl-dev" ;; - mcrypt) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libmcrypt-dev" + imap@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libc-client2007e" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libc-client-dev libkrb5-dev" ;; - mssql) - getRequiredAptPackages_result="${getRequiredAptPackages_result} freetds-dev" + + interbase@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile firebird-dev libib-util" ;; - odbc) - getRequiredAptPackages_result="${getRequiredAptPackages_result} unixodbc-dev" + intl@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libicu-dev" ;; - pdo_dblib) - getRequiredAptPackages_result="${getRequiredAptPackages_result} freetds-dev" + ldap@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libldap2-dev" ;; - pdo_firebird) - getRequiredAptPackages_result="${getRequiredAptPackages_result} firebird-dev libib-util" + memcache@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile zlib1g-dev" ;; - pdo_pgsql) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libpq-dev" + memcached@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libmemcached-dev zlib1g-dev" ;; - pdo_odbc) - getRequiredAptPackages_result="${getRequiredAptPackages_result} unixodbc-dev" + mcrypt@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libmcrypt-dev" ;; - pdo_sqlsrv) - getRequiredAptPackages_result="${getRequiredAptPackages_result} unixodbc-dev" + mssql@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" ;; - pgsql) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libpq-dev" + odbc@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile unixodbc-dev" ;; - pspell) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libpspell-dev" + pdo_dblib@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" ;; - recode) - getRequiredAptPackages_result="${getRequiredAptPackages_result} librecode-dev" + pdo_firebird@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile firebird-dev libib-util" ;; - ssh2) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libssh2-1-dev" + pdo_pgsql@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libpq-dev" ;; - snmp) - getRequiredAptPackages_result="${getRequiredAptPackages_result} snmp libsnmp-dev" + pdo_odbc@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile unixodbc-dev" ;; - soap) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libxml2-dev" + pdo_sqlsrv@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile unixodbc-dev" ;; - solr) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libcurl4-gnutls-dev libxml2-dev" + pgsql@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libpq-dev" ;; - sqlsrv) - getRequiredAptPackages_result="${getRequiredAptPackages_result} unixodbc-dev" + pspell@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libpspell-dev" ;; - sybase_ct) - getRequiredAptPackages_result="${getRequiredAptPackages_result} freetds-dev" + recode@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile librecode-dev" ;; - tidy) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libtidy-dev" + ssh2@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libssh2-1-dev" ;; - uuid) - getRequiredAptPackages_result="${getRequiredAptPackages_result} uuid-dev" + snmp@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile snmp libsnmp-dev" ;; - wddx) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libxml2-dev" + soap@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxml2-dev" ;; - xmlrpc) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libxml2-dev" + solr@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libcurl4-gnutls-dev libxml2-dev" ;; - xsl) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libxslt-dev" + sqlsrv@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile unixodbc-dev" ;; - yaml) - getRequiredAptPackages_result="${getRequiredAptPackages_result} libyaml-dev" + sybase_ct@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" ;; - zip) - getRequiredAptPackages_result="${getRequiredAptPackages_result} cmake zlib1g-dev libbz2-dev libmbedtls-dev" + tidy@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libtidy-dev" + ;; + uuid@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile uuid-dev" + ;; + wddx@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxml2-dev" + ;; + xmlrpc@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxml2-dev" + ;; + xsl@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxslt-dev" + ;; + yaml@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libyaml-dev" + ;; + zip@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile cmake zlib1g-dev libbz2-dev libmbedtls-dev" ;; esac done - printf '%s' "${getRequiredAptPackages_result}" + PACKAGES_PERSISTENT='' + PACKAGES_VOLATILE='' + if test -z "$buildRequiredPackageLists_persistent$buildRequiredPackageLists_volatile"; then + return 0 + fi + case "$buildRequiredPackageLists_distro" in + alpine) + apk update + ;; + debian) + DEBIAN_FRONTEND=noninteractive apt-get update + DEBIAN_FRONTEND=noninteractive apt-get autoremove --purge -y + ;; + esac + if test -n "$buildRequiredPackageLists_persistent"; then + PACKAGES_PERSISTENT="$(expandPackagesToBeInstalled $buildRequiredPackageLists_persistent)" + fi + if test -n "$buildRequiredPackageLists_volatile"; then + resetIFS + for buildRequiredPackageLists_package in $(expandPackagesToBeInstalled $buildRequiredPackageLists_volatile); do + if ! stringInList "$buildRequiredPackageLists_package" "$PACKAGES_PERSISTENT"; then + PACKAGES_VOLATILE="$PACKAGES_VOLATILE $buildRequiredPackageLists_package" + fi + done + PACKAGES_VOLATILE="${PACKAGES_VOLATILE# }" + fi } -# Get the newly installed APT packages that will be no more needed after the installation of PHP extensions +# Get the full list of APT/APK packages that will be installed, given the required packages # # Arguments: -# $1: the list of APT packages that will be installed +# $1: the list of required APT/APK packages # # Output: -# Space-separated list of APT packages to be removed -getAptPackagesToRemove () { - getAptPackagesToRemove_inNewPackages='' - getAptPackagesToRemove_result='' - IFS=' +# Space-separated list of every APT/APK packages that will be installed +expandPackagesToBeInstalled () { + expandPackagesToBeInstalled_result='' + case "$(getDistro)" in + alpine) + IFS=' ' - for getAptPackagesToRemove_aptLine in $(DEBIAN_FRONTEND=noninteractive apt-get install -sy $@); do - if test -z "${getAptPackagesToRemove_inNewPackages}"; then - if test "${getAptPackagesToRemove_aptLine}" = 'The following NEW packages will be installed:'; then - getAptPackagesToRemove_inNewPackages='y' - resetIFS - fi - elif test "${getAptPackagesToRemove_aptLine}" = "${getAptPackagesToRemove_aptLine# }"; then - getAptPackagesToRemove_inNewPackages='' - else - for getAptPackagesToRemove_newPackage in ${getAptPackagesToRemove_aptLine}; do - case "${getAptPackagesToRemove_newPackage}" in - *-dev|cmake|cmake-data) - getAptPackagesToRemove_result="${getAptPackagesToRemove_result} ${getAptPackagesToRemove_newPackage}" - ;; - esac + for expandPackagesToBeInstalled_line in $(apk add --simulate $@); do + if test -n "$(printf '%s' "$expandPackagesToBeInstalled_line" | grep -E '^\([0-9]*/[0-9]*) Installing ')"; then + expandPackagesToBeInstalled_result="$expandPackagesToBeInstalled_result $(printf '%s' "$expandPackagesToBeInstalled_line" | cut -d ' ' -f 3)" + fi done - fi - done - resetIFS - printf '%s' "${getAptPackagesToRemove_result}" + resetIFS + ;; + debian) + expandPackagesToBeInstalled_inNewPackages=0 + IFS=' +' + for expandPackagesToBeInstalled_line in $(DEBIAN_FRONTEND=noninteractive apt-get install -sy $@); do + if test $expandPackagesToBeInstalled_inNewPackages -eq 0; then + if test "$expandPackagesToBeInstalled_line" = 'The following NEW packages will be installed:'; then + expandPackagesToBeInstalled_inNewPackages=1 + fi + elif test "$expandPackagesToBeInstalled_line" = "${expandPackagesToBeInstalled_line# }"; then + break + else + resetIFS + for expandPackagesToBeInstalled_newPackage in $expandPackagesToBeInstalled_line; do + expandPackagesToBeInstalled_result="$expandPackagesToBeInstalled_result $expandPackagesToBeInstalled_newPackage" + done + IFS=' +' + fi + done + resetIFS + ;; + esac + printf '%s' "${expandPackagesToBeInstalled_result# }" +} + +# Install the required APT/APK packages +# +# Arguments: +# $@: the list of APT/APK packages to be installed +installRequiredPackages () { + printf '### INSTALLING REQUIRED PACKAGES ###\n' + case "$(getDistro)" in + alpine) + apk add $PACKAGES_PERSISTENT $PACKAGES_VOLATILE + ;; + debian) + DEBIAN_FRONTEND=noninteractive apt-get install -y $PACKAGES_PERSISTENT $PACKAGES_VOLATILE + ;; + esac } # Install a bundled PHP module given its handle @@ -319,20 +461,20 @@ getAptPackagesToRemove () { # $2: the handle of the PHP module # # Set: -# UNNEEDED_APT_PACKAGE_LINKS +# UNNEEDED_PACKAGE_LINKS # # Output: # Nothing installBundledModule () { - printf '### INSTALLING BUNDLED MODULE %s ###\n' "${2}" - case "${2}" in + printf '### INSTALLING BUNDLED MODULE %s ###\n' "$2" + case "$2" in gd) if test $1 -le 506; then - docker-php-ext-configure gd --with-gd --with-vpx-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf + docker-php-ext-configure gd --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf --with-vpx-dir elif test $1 -le 701; then - docker-php-ext-configure gd --with-gd --with-webp-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf + docker-php-ext-configure gd --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf --with-webp-dir elif test $1 -le 703; then - docker-php-ext-configure gd --with-gd --with-webp-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir + docker-php-ext-configure gd --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir --with-webp-dir else docker-php-ext-configure gd --enable-gd --with-webp --with-jpeg --with-xpm --with-freetype fi @@ -342,7 +484,7 @@ installBundledModule () { 506) if ! test -f /usr/include/gmp.h; then ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h - UNNEEDED_APT_PACKAGE_LINKS="${UNNEEDED_APT_PACKAGE_LINKS} /usr/include/gmp.h" + UNNEEDED_PACKAGE_LINKS="$UNNEEDED_PACKAGE_LINKS /usr/include/gmp.h" fi ;; esac @@ -358,7 +500,7 @@ installBundledModule () { 506|700|701|702|703|704) if ! test -f /usr/lib/libsybdb.so; then ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so - UNNEEDED_APT_PACKAGE_LINKS="${UNNEEDED_APT_PACKAGE_LINKS} /usr/lib/libsybdb.so" + UNNEEDED_PACKAGE_LINKS="$UNNEEDED_PACKAGE_LINKS /usr/lib/libsybdb.so" fi ;; esac @@ -395,7 +537,7 @@ installBundledModule () { fi ;; esac - docker-php-ext-install -j$(nproc) "${2}" + docker-php-ext-install -j$(nproc) "$2" } # Fetch a tar.gz file, extract it and returns the path of the extracted folder. @@ -408,24 +550,24 @@ installBundledModule () { getPackageSource () { mkdir -p /tmp/src getPackageSource_tempFile=$(mktemp -p /tmp/src) - curl -L -s -S -o "${getPackageSource_tempFile}" "$1" + curl -L -s -S -o "$getPackageSource_tempFile" "$1" getPackageSource_tempDir=$(mktemp -p /tmp/src -d) - cd "${getPackageSource_tempDir}" - tar -xzf "${getPackageSource_tempFile}" + cd "$getPackageSource_tempDir" + tar -xzf "$getPackageSource_tempFile" cd - >/dev/null - unlink "${getPackageSource_tempFile}" + unlink "$getPackageSource_tempFile" getPackageSource_outDir='' - for getPackageSource_i in $(ls "${getPackageSource_tempDir}"); do - if test -n "${getPackageSource_outDir}" || test -f "${getPackageSource_tempDir}/${getPackageSource_i}"; then + for getPackageSource_i in $(ls "$getPackageSource_tempDir"); do + if test -n "$getPackageSource_outDir" || test -f "$getPackageSource_tempDir/$getPackageSource_i"; then getPackageSource_outDir='' break fi - getPackageSource_outDir="${getPackageSource_tempDir}/${getPackageSource_i}" + getPackageSource_outDir="$getPackageSource_tempDir/$getPackageSource_i" done - if test -n "${getPackageSource_outDir}"; then - printf '%s' "${getPackageSource_outDir}" + if test -n "$getPackageSource_outDir"; then + printf '%s' "$getPackageSource_outDir" else - printf '%s' "${getPackageSource_tempDir}" + printf '%s' "$getPackageSource_tempDir" fi } @@ -437,14 +579,14 @@ getPackageSource () { # $3: the options of the configure command # $4: the value of CFLAGS installModuleFromSource () { - printf '### INSTALLING MODULE %s FROM SOURCE CODE ###\n' "${1}" - installModuleFromSource_dir="$(getPackageSource "${2}")" - cd "${installModuleFromSource_dir}" + printf '### INSTALLING MODULE %s FROM SOURCE CODE ###\n' "$1" + installModuleFromSource_dir="$(getPackageSource "$2")" + cd "$installModuleFromSource_dir" phpize - ./configure ${3} CFLAGS="${4:-}" + ./configure $3 CFLAGS="${4:-}" make -j$(nproc) install cd -- - docker-php-ext-enable "${1}" + docker-php-ext-enable "$1" } # Install a PECL PHP module given its handle @@ -453,18 +595,18 @@ installModuleFromSource () { # $1: the numeric PHP Major-Minor version # $2: the handle of the PHP module installPECLModule () { - printf '### INSTALLING PECL MODULE %s ###\n' "${2}" - installPECLModule_actual="${2}" + printf '### INSTALLING PECL MODULE %s ###\n' "$2" + installPECLModule_actual="$2" installPECLModule_stdin='\n' - case "${2}" in + case "$2" in apcu) if test $1 -le 506; then - installPECLModule_actual="${2}-4.0.11" + installPECLModule_actual="$2-4.0.11" fi ;; memcached) if test $1 -lt 700; then - installPECLModule_actual="${2}-2.2.0" + installPECLModule_actual="$2-2.2.0" # --with-libmemcached-dir (default: no) Set the path to libmemcached install prefix else installPECLModule_stdin='' @@ -490,47 +632,47 @@ installPECLModule () { ;; msgpack) if test $1 -le 506; then - installPECLModule_actual="${2}-0.5.7" + installPECLModule_actual="$2-0.5.7" fi ;; parallel) if test $1 -le 701; then - installPECLModule_actual="${2}-0.8.3" + installPECLModule_actual="$2-0.8.3" fi ;; pcov) if test $1 -lt 701; then - installPECLModule_actual="${2}-0.9.0" + installPECLModule_actual="$2-0.9.0" fi ;; pdo_sqlsrv | sqlsrv) # https://docs.microsoft.com/it-it/sql/connect/php/system-requirements-for-the-php-sql-driver?view=sql-server-2017 if test $1 -le 700; then - installPECLModule_actual="${2}-5.3.0" + installPECLModule_actual="$2-5.3.0" elif test $1 -ge 704; then - installPECLModule_actual="${2}-5.7.0preview" + installPECLModule_actual="$2-5.7.0preview" fi ;; pthreads) if test $1 -lt 700; then - installPECLModule_actual="${2}-2.0.10" + installPECLModule_actual="$2-2.0.10" fi ;; redis) if test $1 -le 506; then - installPECLModule_actual="${2}-4.3.0" + installPECLModule_actual="$2-4.3.0" fi # enable-redis-igbinary? enable-redis-lzf? php --ri igbinary >/dev/null 2>/dev/null && installPECLModule_stdin='yes\nyes\n' || installPECLModule_stdin='no\nyes\n' ;; solr) if test $1 -le 506; then - installPECLModule_actual="${2}-2.4.0" + installPECLModule_actual="$2-2.4.0" fi ;; ssh2) if test $1 -le 506; then - installPECLModule_actual="${2}-0.13" + installPECLModule_actual="$2-0.13" else # see https://bugs.php.net/bug.php?id=78560 installPECLModule_actual='https://pecl.php.net/get/ssh2' @@ -538,35 +680,35 @@ installPECLModule () { ;; xdebug) if test $1 -lt 501; then - installPECLModule_actual="${2}-2.0.5" + installPECLModule_actual="$2-2.0.5" elif test $1 -lt 504; then - installPECLModule_actual="${2}-2.2.7" + installPECLModule_actual="$2-2.2.7" elif test $1 -lt 505; then - installPECLModule_actual="${2}-2.4.1" + installPECLModule_actual="$2-2.4.1" elif test $1 -lt 700; then - installPECLModule_actual="${2}-2.5.5" + installPECLModule_actual="$2-2.5.5" elif test $1 -ge 704; then - installPECLModule_actual="${2}-2.8.0beta2" + installPECLModule_actual="$2-2.8.0beta2" fi ;; uopz) if test $1 -lt 700; then - installPECLModule_actual="${2}-2.0.7" + installPECLModule_actual="$2-2.0.7" elif test $1 -lt 701; then - installPECLModule_actual="${2}-5.0.2" + installPECLModule_actual="$2-5.0.2" fi ;; yaml) if test $1 -lt 700; then - installPECLModule_actual="${2}-1.3.1" + installPECLModule_actual="$2-1.3.1" fi ;; esac - if test "${2}" != "${installPECLModule_actual}"; then - printf ' (installing version %s)\n' "${installPECLModule_actual}" + if test "$2" != "$installPECLModule_actual"; then + printf ' (installing version %s)\n' "$installPECLModule_actual" fi - printf "${installPECLModule_stdin}" | pecl install "${installPECLModule_actual}" - docker-php-ext-enable "${2}" + printf "$installPECLModule_stdin" | pecl install "$installPECLModule_actual" + docker-php-ext-enable "$2" } # Check if a string is in a list of space-separated string @@ -579,8 +721,8 @@ installPECLModule () { # 0 (true): if the string is in the list # 1 (false): if the string is not in the list stringInList () { - for stringInList_listItem in ${2}; do - if test "${1}" = "${stringInList_listItem}"; then + for stringInList_listItem in $2; do + if test "$1" = "$stringInList_listItem"; then return 0 fi done @@ -597,8 +739,8 @@ stringInList () { # The list without the word removeStringFromList () { removeStringFromList_result='' - for removeStringFromList_listItem in ${2}; do - if test "${1}" != "${removeStringFromList_listItem}"; then + for removeStringFromList_listItem in $2; do + if test "$1" != "$removeStringFromList_listItem"; then if test -z "$removeStringFromList_result"; then removeStringFromList_result="$removeStringFromList_listItem" else @@ -606,84 +748,96 @@ removeStringFromList () { fi fi done - printf '%s' "${removeStringFromList_result}" + printf '%s' "$removeStringFromList_result" +} + +# Cleanup everything at the end of the execution +cleanup () { + cleanup_distro="$(getDistro)" + if test -n "$UNNEEDED_PACKAGE_LINKS"; then + printf '### REMOVING UNNEEDED PACKAGE LINKS ###\n' + for cleanup_link in $UNNEEDED_PACKAGE_LINKS; do + if test -L "$cleanup_link"; then + rm -f "$cleanup_link" + fi + done + fi + if test -n "$PACKAGES_VOLATILE"; then + printf '### REMOVING UNNEEDED PACKAGES ###\n' + case "$cleanup_distro" in + alpine) + apk del --purge $PACKAGES_VOLATILE + ;; + debian) + DEBIAN_FRONTEND=noninteractive apt-get remove --purge -y $PACKAGES_VOLATILE + ;; + esac + fi + case "$cleanup_distro" in + alpine) + rm -rf /var/cache/apk/* + ;; + debian) + rm -rf /var/lib/apt/lists/* + ;; + esac + docker-php-source delete + rm -rf /tmp/pear + rm -rf /tmp/src } resetIFS PHP_MAJMIN_VERSION=$(getPHPMajorMinor) -case "${PHP_MAJMIN_VERSION}" in +case "$PHP_MAJMIN_VERSION" in 506|700|701|702|703|704) ;; *) printf "### ERROR: Unsupported PHP version: %s.%s ###\n" $(( PHP_MAJMIN_VERSION / 100 )) $(( PHP_MAJMIN_VERSION % 100 )) esac -UNNEEDED_APT_PACKAGES='' -UNNEEDED_APT_PACKAGE_LINKS='' -getModulesToInstall "$@" -sortModulesToInstall +UNNEEDED_PACKAGE_LINKS='' +processCommandArguments "$@" -if test -n "${PHP_MODULES_TO_INSTALL}"; then - REQUIRED_APT_PACKAGES=$(getRequiredAptPackages ${PHP_MAJMIN_VERSION} ${PHP_MODULES_TO_INSTALL}) - if test -n "${REQUIRED_APT_PACKAGES}"; then - printf '### INSTALLING REQUIRED APT PACKAGES ###\n' - DEBIAN_FRONTEND=noninteractive apt-get update -y - if test -n "${DO_APT_REMOVE}"; then - UNNEEDED_APT_PACKAGES=$(getAptPackagesToRemove ${REQUIRED_APT_PACKAGES}) - fi - DEBIAN_FRONTEND=noninteractive apt-get install -y ${REQUIRED_APT_PACKAGES} - fi - docker-php-source extract - BUNDLED_MODULES="$(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | xargs -n1 dirname | xargs -n1 basename | xargs)" - for PHP_MODULE_TO_INSTALL in ${PHP_MODULES_TO_INSTALL}; do - if stringInList "${PHP_MODULE_TO_INSTALL}" "${BUNDLED_MODULES}"; then - installBundledModule ${PHP_MAJMIN_VERSION} "${PHP_MODULE_TO_INSTALL}" - else - MODULE_SOURCE='' - MODULE_SOURCE_CONFIGOPTIONS='' - MODULE_SOURCE_CFLAGS='' - case "${PHP_MODULE_TO_INSTALL}" in - cmark) - MODULE_SOURCE=https://github.com/krakjoe/cmark/archive/v1.0.0.tar.gz - cd "$(getPackageSource https://github.com/commonmark/cmark/archive/0.28.3.tar.gz)" - make install - cd - - MODULE_SOURCE_CONFIGOPTIONS=--with-cmark - ;; - igbinary) - if test ${PHP_MAJMIN_VERSION} -lt 700; then - MODULE_SOURCE="https://github.com/igbinary/igbinary/archive/2.0.8.tar.gz" - else - MODULE_SOURCE="https://github.com/igbinary/igbinary/archive/3.0.1.tar.gz" - fi - MODULE_SOURCE_CONFIGOPTIONS=--enable-igbinary - MODULE_SOURCE_CFLAGS='-O2 -g' - ;; - esac - if test -n "${MODULE_SOURCE}"; then - installModuleFromSource "${PHP_MODULE_TO_INSTALL}" "${MODULE_SOURCE}" "${MODULE_SOURCE_CONFIGOPTIONS}" "${MODULE_SOURCE_CFLAGS}" - else - installPECLModule ${PHP_MAJMIN_VERSION} "${PHP_MODULE_TO_INSTALL}" - fi - fi - done - if test -n "${DO_APT_REMOVE}"; then - printf '### REMOVING NO LONGER REQUIRED PACKAGES ###\n' - DEBIAN_FRONTEND=noninteractive apt autoremove -y - fi - if test -n "${UNNEEDED_APT_PACKAGES}"; then - printf '### REMOVING UNNEEDED APT PACKAGES ###\n' - if test -n "${UNNEEDED_APT_PACKAGE_LINKS}"; then - for unneededAptPackageLink in ${UNNEEDED_APT_PACKAGE_LINKS}; do - if test -L "${unneededAptPackageLink}"; then - rm -f "${unneededAptPackageLink}" - fi - done - fi - DEBIAN_FRONTEND=noninteractive apt-get remove --purge -y ${UNNEEDED_APT_PACKAGES} - fi +if test -z "$PHP_MODULES_TO_INSTALL"; then + exit 0 fi -docker-php-source delete -rm -rf /tmp/pear -rm -rf /var/lib/apt/lists/* -rm -rf /tmp/src +sortModulesToInstall + +if buildRequiredPackageLists $PHP_MAJMIN_VERSION $PHP_MODULES_TO_INSTALL; then + installRequiredPackages +fi +docker-php-source extract +BUNDLED_MODULES="$(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | xargs -n1 dirname | xargs -n1 basename | xargs)" +for PHP_MODULE_TO_INSTALL in $PHP_MODULES_TO_INSTALL; do + if stringInList "$PHP_MODULE_TO_INSTALL" "$BUNDLED_MODULES"; then + installBundledModule $PHP_MAJMIN_VERSION "$PHP_MODULE_TO_INSTALL" + else + MODULE_SOURCE='' + MODULE_SOURCE_CONFIGOPTIONS='' + MODULE_SOURCE_CFLAGS='' + case "$PHP_MODULE_TO_INSTALL" in + cmark) + MODULE_SOURCE=https://github.com/krakjoe/cmark/archive/v1.0.0.tar.gz + cd "$(getPackageSource https://github.com/commonmark/cmark/archive/0.28.3.tar.gz)" + make install + cd - + MODULE_SOURCE_CONFIGOPTIONS=--with-cmark + ;; + igbinary) + if test $PHP_MAJMIN_VERSION -lt 700; then + MODULE_SOURCE="https://github.com/igbinary/igbinary/archive/2.0.8.tar.gz" + else + MODULE_SOURCE="https://github.com/igbinary/igbinary/archive/3.0.1.tar.gz" + fi + MODULE_SOURCE_CONFIGOPTIONS=--enable-igbinary + MODULE_SOURCE_CFLAGS='-O2 -g' + ;; + esac + if test -n "$MODULE_SOURCE"; then + installModuleFromSource "$PHP_MODULE_TO_INSTALL" "$MODULE_SOURCE" "$MODULE_SOURCE_CONFIGOPTIONS" "$MODULE_SOURCE_CFLAGS" + else + installPECLModule $PHP_MAJMIN_VERSION "$PHP_MODULE_TO_INSTALL" + fi + fi +done +cleanup diff --git a/scripts/travisci-test-extensions b/scripts/travisci-test-extensions index bf48a99..ec76f36 100755 --- a/scripts/travisci-test-extensions +++ b/scripts/travisci-test-extensions @@ -69,7 +69,7 @@ testExtension () { testExtension_Image="$(getDockerImageName "${1}" "${2}")" printf ' - Docker image: %s\n' "${testExtension_Image}" testExtension_out=`mktemp` - if $(docker run --rm --volume "${TRAVIS_BUILD_DIR}:/app" --workdir /app "${testExtension_Image}" sh -c "./install-php-extensions --cleanup '${1}' && php ./scripts/check-installed-extension.php '${1}'" >"${testExtension_out}" 2>&1); then + if $(docker run --rm --volume "${TRAVIS_BUILD_DIR}:/app" --workdir /app "${testExtension_Image}" sh -c "./install-php-extensions '${1}' && php ./scripts/check-installed-extension.php '${1}'" >"${testExtension_out}" 2>&1); then rm -rf "${testExtension_out}" printf ' - Passed\n' return 0 From ef8f9f622f6c49f9a5674ed3a26e97e2c9f1a2fb Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Dec 2019 11:40:13 +0100 Subject: [PATCH 03/12] Continue implementing Alpine support Test: interbase --- install-php-extensions | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/install-php-extensions b/install-php-extensions index 4dec79a..9b163df 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -196,7 +196,7 @@ buildRequiredPackageLists () { buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile librabbitmq-dev libssh-dev" ;; apcu@alpine) - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile autoconf g++ make" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" ;; bz2@alpine) buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libbz2" @@ -206,7 +206,7 @@ buildRequiredPackageLists () { buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libbz2-dev" ;; cmark@alpine) - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile cmake make g++ autoconf" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" ;; cmark@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile cmake" @@ -253,11 +253,11 @@ buildRequiredPackageLists () { buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libgmp-dev" ;; igbinary@alpine) - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile autoconf g++ make" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" ;; imagick@alpine) buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent imagemagick" - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile imagemagick-dev autoconf g++ make re2c" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS imagemagick-dev" ;; imagick@debian) buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libmagickwand-6.q16-?" @@ -274,8 +274,11 @@ buildRequiredPackageLists () { buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libc-client2007e" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libc-client-dev libkrb5-dev" ;; - + interbase@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS icu-dev ncurses-dev" + ;; interbase@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libfbclient2" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile firebird-dev libib-util" ;; intl@debian) @@ -492,6 +495,25 @@ installBundledModule () { imap) PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl ;; + interbase) + case "$(getDistro)" in + alpine) + if ! test -d /tmp/src/firebird; then + mv "$(getPackageSource https://github.com/FirebirdSQL/firebird/releases/download/R2_5_9/Firebird-2.5.9.27139-0.tar.bz2)" /tmp/src/firebird + cd /tmp/src/firebird + #Patch rwlock.h (this has been fixed in later release of firebird 3.x) + sed -i '194s/.*/#if 0/' src/common/classes/rwlock.h + set +x + ./configure --with-system-icu + make btyacc_binary gpre_boot libfbstatic libfbclient + cp gen/firebird/lib/libfbclient.so /usr/lib/ + ln -s /usr/lib/libfbclient.so /usr/lib/libfbclient.so.2 + cd - + fi + CFLAGS='-I/tmp/src/firebird/src/jrd -I/tmp/src/firebird/src/include -I/tmp/src/firebird/src/include/gen' docker-php-ext-configure $2 + ;; + esac + ;; ldap) docker-php-ext-configure ldap --with-libdir=lib/$(gcc -dumpmachine) ;; @@ -553,7 +575,7 @@ getPackageSource () { curl -L -s -S -o "$getPackageSource_tempFile" "$1" getPackageSource_tempDir=$(mktemp -p /tmp/src -d) cd "$getPackageSource_tempDir" - tar -xzf "$getPackageSource_tempFile" + tar -xzf "$getPackageSource_tempFile" 2>/dev/null || tar -xf "$getPackageSource_tempFile" cd - >/dev/null unlink "$getPackageSource_tempFile" getPackageSource_outDir='' From 3202a0f19373d15f4d4f10cb5c086ab6e1bdcfd9 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Dec 2019 12:29:48 +0100 Subject: [PATCH 04/12] Continue implementing Alpine support Test: intl, ldap, mcrypt, memcache, memcached, msgpack, mysql, mysqli --- install-php-extensions | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/install-php-extensions b/install-php-extensions index 9b163df..22b106f 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -281,20 +281,44 @@ buildRequiredPackageLists () { buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libfbclient2" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile firebird-dev libib-util" ;; + intl@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent icu-libs" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile icu-dev" + ;; intl@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libicu-dev" ;; + ldap@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libldap" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile openldap-dev" + ;; ldap@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libldap2-dev" ;; + mcrypt@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libmcrypt" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libmcrypt-dev" + ;; + mcrypt@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libmcrypt4" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libmcrypt-dev" + ;; + memcache@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS zlib-dev" + ;; memcache@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile zlib1g-dev" ;; + memcached@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libmemcached-libs" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS libmemcached-dev zlib-dev" + ;; memcached@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libmemcachedutil2" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libmemcached-dev zlib1g-dev" ;; - mcrypt@debian) - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libmcrypt-dev" + msgpack@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" ;; mssql@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" @@ -505,7 +529,7 @@ installBundledModule () { sed -i '194s/.*/#if 0/' src/common/classes/rwlock.h set +x ./configure --with-system-icu - make btyacc_binary gpre_boot libfbstatic libfbclient + make -j$(nproc) btyacc_binary gpre_boot libfbstatic libfbclient cp gen/firebird/lib/libfbclient.so /usr/lib/ ln -s /usr/lib/libfbclient.so /usr/lib/libfbclient.so.2 cd - @@ -550,7 +574,7 @@ installBundledModule () { mkdir "$libZipSrc/build" cd "$libZipSrc/build" cmake .. - make install + make -j$(nproc) install cd - if test $1 -le 703; then docker-php-ext-configure zip --with-libzip From 5c41352402a6e230dee58bee2f66fb3e2592b444 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Dec 2019 12:57:53 +0100 Subject: [PATCH 05/12] Continue implementing Alpine support Test: interbase, mcrypt, mssql, -STOP- --- README.md | 8 ++++++++ data/supported-extensions | 1 + install-php-extensions | 10 +++++++--- scripts/travisci-test-extensions | 12 ++++++++++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 764491a..2d04c1a 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,14 @@ Some extension has special requirements: Test: gd, zip ``` + If your pull request contains multiple commits, we'll check the "Test:" message of every commit. + If you want to stop parsing next commits, add `-STOP-` in the "Test:" line, for example: + ``` + Improve the GD and ZIP extensions + + Test: gd, zip, -STOP- + ``` + ## Do you want to really say thank you? diff --git a/data/supported-extensions b/data/supported-extensions index 301f230..8d24e12 100644 --- a/data/supported-extensions +++ b/data/supported-extensions @@ -20,6 +20,7 @@ mcrypt 5.6 7.0 7.1 7.2 7.3 7.4 memcache 5.6 memcached 5.6 7.0 7.1 7.2 7.3 7.4 msgpack 5.6 7.0 7.1 7.2 7.3 7.4 +mssql 5.6 mysql 5.6 mysqli 5.6 7.0 7.1 7.2 7.3 7.4 odbc 5.6 7.0 7.1 7.2 7.3 7.4 diff --git a/install-php-extensions b/install-php-extensions index 22b106f..eac0799 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -296,7 +296,7 @@ buildRequiredPackageLists () { buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libldap2-dev" ;; mcrypt@alpine) - buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libmcrypt" + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent $PHPIZE_DEPS libmcrypt" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libmcrypt-dev" ;; mcrypt@debian) @@ -320,7 +320,12 @@ buildRequiredPackageLists () { msgpack@alpine) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" ;; + mssql@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent freetds" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" + ;; mssql@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libsybdb5" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" ;; odbc@debian) @@ -527,9 +532,8 @@ installBundledModule () { cd /tmp/src/firebird #Patch rwlock.h (this has been fixed in later release of firebird 3.x) sed -i '194s/.*/#if 0/' src/common/classes/rwlock.h - set +x ./configure --with-system-icu - make -j$(nproc) btyacc_binary gpre_boot libfbstatic libfbclient + make -s btyacc_binary gpre_boot libfbstatic libfbclient cp gen/firebird/lib/libfbclient.so /usr/lib/ ln -s /usr/lib/libfbclient.so /usr/lib/libfbclient.so.2 cd - diff --git a/scripts/travisci-test-extensions b/scripts/travisci-test-extensions index ec76f36..38fc6ce 100755 --- a/scripts/travisci-test-extensions +++ b/scripts/travisci-test-extensions @@ -156,6 +156,9 @@ getAllPHPVersionsFor () { # Arguments: # $1: the commit hash # +# Set: +# STOP_NEXT_COMMITS to 1 if we should skip next commits +# # Return: # 0 (true): if test passes # 1 (false): if test fails @@ -186,7 +189,9 @@ testExtensionsFromMessage () { if test -n "$TESTLIST"; then IFS=' ,;' for COMMIT_LINE_EXT in $TESTLIST; do - if test -z "$TEST_EXTENSIONS"; then + if test $COMMIT_LINE_EXT = '-STOP-'; then + STOP_NEXT_COMMITS=1 + elif test -z "$TEST_EXTENSIONS"; then TEST_EXTENSIONS=$COMMIT_LINE_EXT; else if ! stringInList "$COMMIT_LINE_EXT" "$TEST_EXTENSIONS"; then @@ -210,7 +215,7 @@ testExtensionsFromMessage () { return $testExtensionsFromMessage_result } - +STOP_NEXT_COMMITS=0 TESTS_RESULTS=0 ADDED_EXTENSION_LINE= FOUND_ATAT= @@ -239,6 +244,9 @@ for COMMIT_HASH in $(git -C "${TRAVIS_BUILD_DIR}" log --pretty='format:%H' "${TR if ! testExtensionsFromMessage "$COMMIT_HASH"; then TESTS_RESULTS=1 fi + if test $STOP_NEXT_COMMITS -eq 1; then + break + fi done if test ${TESTS_RESULTS} -ne 0; then From 46ac6f95240bd5700f3580de2f44115dee11a73b Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Dec 2019 13:57:45 +0100 Subject: [PATCH 06/12] Continue implementing Alpine support Test: odbc, opcache, parallel, pcntl, pcov, -STOP- --- install-php-extensions | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/install-php-extensions b/install-php-extensions index eac0799..0c04ff1 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -328,9 +328,20 @@ buildRequiredPackageLists () { buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libsybdb5" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" ;; + odbc@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent unixodbc" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS unixodbc-dev" + ;; odbc@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libodbc1" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile unixodbc-dev" ;; + parallel@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" + ;; + pcov@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" + ;; pdo_dblib@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" ;; @@ -533,6 +544,7 @@ installBundledModule () { #Patch rwlock.h (this has been fixed in later release of firebird 3.x) sed -i '194s/.*/#if 0/' src/common/classes/rwlock.h ./configure --with-system-icu + # -j option can't be used: make targets must be compiled sequentially make -s btyacc_binary gpre_boot libfbstatic libfbclient cp gen/firebird/lib/libfbclient.so /usr/lib/ ln -s /usr/lib/libfbclient.so /usr/lib/libfbclient.so.2 From a1d379386069a562ab0557893d207d04cc7835ac Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Dec 2019 14:23:15 +0100 Subject: [PATCH 07/12] Continue implementing Alpine support Test: pdo_dblib, pdo_firebird, pdo_mysql, pdo_odbc, pdo_pgsql, pdo_sqlsrv, -STOP- --- install-php-extensions | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/install-php-extensions b/install-php-extensions index 0c04ff1..745bc4a 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -342,19 +342,43 @@ buildRequiredPackageLists () { pcov@alpine) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" ;; - pdo_dblib@debian) + pdo_dblib@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent freetds" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" ;; + pdo_dblib@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libsybdb5" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" + ;; + pdo_firebird@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS icu-dev ncurses-dev" + ;; pdo_firebird@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libfbclient2" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile firebird-dev libib-util" ;; - pdo_pgsql@debian) - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libpq-dev" + pdo_odbc@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent unixodbc" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS unixodbc-dev" ;; pdo_odbc@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libodbc1" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile unixodbc-dev" ;; + pdo_pgsql@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent postgresql-libs" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile postgresql-dev" + ;; + pdo_pgsql@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libpq5" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libpq-dev" + ;; + pdo_sqlsrv@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libstdc++ unixodbc" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS unixodbc-dev" + ;; pdo_sqlsrv@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libodbc1 odbcinst" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile unixodbc-dev" ;; pgsql@debian) @@ -535,7 +559,7 @@ installBundledModule () { imap) PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl ;; - interbase) + interbase|pdo_firebird) case "$(getDistro)" in alpine) if ! test -d /tmp/src/firebird; then From 6af10df812292f0eb6092260d691ba15274b099a Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Dec 2019 15:04:19 +0100 Subject: [PATCH 08/12] Continue implementing Alpine support Test: pgsql, pspell, pthreads, recode, redis, shmop, -STOP- --- install-php-extensions | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/install-php-extensions b/install-php-extensions index 745bc4a..2e18a8e 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -381,15 +381,36 @@ buildRequiredPackageLists () { buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libodbc1 odbcinst" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile unixodbc-dev" ;; + pgsql@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent postgresql-libs" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile postgresql-dev" + ;; pgsql@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libpq5" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libpq-dev" ;; + pspell@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent aspell-libs" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile aspell-dev" + ;; pspell@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libaspell15" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libpspell-dev" ;; + pthreads@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" + ;; + recode@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent recode" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile recode-dev" + ;; recode@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent librecode0" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile librecode-dev" ;; + redis@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" + ;; ssh2@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libssh2-1-dev" ;; From 483e3162f35c885a2378621f73d71c308883d9af Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Dec 2019 15:38:27 +0100 Subject: [PATCH 09/12] Continue implementing Alpine support Test: snmp, soap, sockets, solr, sqlsrv, ssh2, -STOP- --- install-php-extensions | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/install-php-extensions b/install-php-extensions index 2e18a8e..c90729b 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -411,21 +411,43 @@ buildRequiredPackageLists () { redis@alpine) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" ;; - ssh2@debian) - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libssh2-1-dev" + snmp@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent net-snmp-libs" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile net-snmp-dev" ;; snmp@debian) - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile snmp libsnmp-dev" + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent snmp" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libsnmp-dev" + ;; + soap@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxml2-dev" ;; soap@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxml2-dev" ;; + solr@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS curl-dev libxml2-dev" + ;; solr@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libcurl3-gnutls" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libcurl4-gnutls-dev libxml2-dev" ;; + sqlsrv@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libstdc++ unixodbc" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS unixodbc-dev" + ;; sqlsrv@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent unixodbc" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile unixodbc-dev" ;; + ssh2@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent $PHPIZE_DEPS libssh2" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS libssh2-dev" + ;; + ssh2@debian) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libssh2-1-dev" + ;; sybase_ct@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" ;; @@ -627,6 +649,13 @@ installBundledModule () { pdo_odbc) docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr ;; + snmp) + case "$(getDistro)" in + alpine) + mkdir -p -m 0755 /var/lib/net-snmp/mib_indexes + ;; + esac + ;; sybase_ct) docker-php-ext-configure sybase_ct --with-sybase-ct=/usr ;; From de6acd466764b8b9000574bba6bc6a1bc0dd6e03 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Dec 2019 15:58:47 +0100 Subject: [PATCH 10/12] Continue implementing Alpine support Test: sybase_ct, sysvmsg, sysvsem, sysvshm, tidy, timezonedb, -STOP- --- install-php-extensions | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/install-php-extensions b/install-php-extensions index c90729b..310d82f 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -448,12 +448,25 @@ buildRequiredPackageLists () { ssh2@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libssh2-1-dev" ;; - sybase_ct@debian) + sybase_ct@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent freetds" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" ;; + sybase_ct@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libct4" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile freetds-dev" + ;; + tidy@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent tidyhtml-libs" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile tidyhtml-dev" + ;; tidy@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libtidy5" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libtidy-dev" ;; + timezonedb@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" + ;; uuid@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile uuid-dev" ;; @@ -659,6 +672,16 @@ installBundledModule () { sybase_ct) docker-php-ext-configure sybase_ct --with-sybase-ct=/usr ;; + tidy) + case "$(getDistro)" in + alpine) + if ! test -f /usr/include/buffio.h; then + ln -s /usr/include/tidybuffio.h /usr/include/buffio.h + UNNEEDED_PACKAGE_LINKS="$UNNEEDED_PACKAGE_LINKS /usr/include/buffio.h" + fi + ;; + esac + ;; zip) libZipSrc="$(getPackageSource https://libzip.org/download/libzip-1.5.2.tar.gz)" mkdir "$libZipSrc/build" From b3a13c1563e53800f5064b75bd9d55241e17db3d Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Dec 2019 17:11:55 +0100 Subject: [PATCH 11/12] Continue implementing Alpine support Test: cmark, tidy, uopz, uuid, wddx, xdebug, xmlrpc, xsl, yaml, zip, -STOP- --- install-php-extensions | 62 +++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/install-php-extensions b/install-php-extensions index 310d82f..5b8e11c 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -206,7 +206,7 @@ buildRequiredPackageLists () { buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libbz2-dev" ;; cmark@alpine) - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS cmake" ;; cmark@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile cmake" @@ -461,29 +461,60 @@ buildRequiredPackageLists () { buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile tidyhtml-dev" ;; tidy@debian) - buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libtidy5" + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libtidy5*" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libtidy-dev" ;; timezonedb@alpine) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" ;; + uopz@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" + ;; + uuid@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libuuid" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS util-linux-dev" + ;; uuid@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile uuid-dev" ;; + wddx@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxml2-dev" + ;; wddx@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxml2-dev" ;; + xdebug@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS" + ;; + xmlrpc@alpine) + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxml2-dev" + ;; xmlrpc@debian) buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxml2-dev" ;; - xsl@debian) + xsl@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libxslt" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxslt-dev" ;; + xsl@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libxslt1.1" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxslt-dev" + ;; + yaml@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent $PHPIZE_DEPS yaml" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS yaml-dev" + ;; yaml@debian) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libyaml-0-2" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libyaml-dev" ;; + zip@alpine) + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libzip" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $PHPIZE_DEPS cmake gnutls-dev libzip-dev openssl-dev zlib-dev" + ;; zip@debian) - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile cmake zlib1g-dev libbz2-dev libmbedtls-dev" + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libzip4 libmbedtls1?" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile cmake gnutls-dev libssl-dev libzip-dev libbz2-dev libmbedtls-dev zlib1g-dev" ;; esac done @@ -683,12 +714,6 @@ installBundledModule () { esac ;; zip) - libZipSrc="$(getPackageSource https://libzip.org/download/libzip-1.5.2.tar.gz)" - mkdir "$libZipSrc/build" - cd "$libZipSrc/build" - cmake .. - make -j$(nproc) install - cd - if test $1 -le 703; then docker-php-ext-configure zip --with-libzip else @@ -837,17 +862,22 @@ installPECLModule () { installPECLModule_actual='https://pecl.php.net/get/ssh2' fi ;; + uuid) + if test $1 -le 506; then + installPECLModule_actual="$2-1.0.5" + fi + ;; xdebug) - if test $1 -lt 501; then + if test $1 -le 500; then installPECLModule_actual="$2-2.0.5" - elif test $1 -lt 504; then + elif test $1 -le 503; then installPECLModule_actual="$2-2.2.7" - elif test $1 -lt 505; then + elif test $1 -le 504; then installPECLModule_actual="$2-2.4.1" - elif test $1 -lt 700; then + elif test $1 -le 506; then installPECLModule_actual="$2-2.5.5" - elif test $1 -ge 704; then - installPECLModule_actual="$2-2.8.0beta2" + elif test $1 -le 700; then + installPECLModule_actual="$2-2.6.1" fi ;; uopz) From 5db4a3005e4bd67108f73e167c5231c99ae83121 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Dec 2019 17:34:32 +0100 Subject: [PATCH 12/12] Continue implementing Alpine support Test: xsl, yaml, -STOP- --- install-php-extensions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-php-extensions b/install-php-extensions index 5b8e11c..d440d44 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -494,7 +494,7 @@ buildRequiredPackageLists () { ;; xsl@alpine) buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libxslt" - buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxslt-dev" + buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxslt-dev libgcrypt-dev" ;; xsl@debian) buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libxslt1.1"