Allow specifying extensions not supported in certain distros

pull/128/head
Michele Locati 2020-03-03 12:07:51 +01:00
parent 47409e2d23
commit 657657c864
No known key found for this signature in database
GPG Key ID: 98B7CE2E7234E28B
3 changed files with 62 additions and 18 deletions

View File

@ -6,7 +6,8 @@ This repository contains a script that can be used to easily install a PHP exten
The script will install all the required APT/APK packages; at the end of the script execution, the no-more needed packages will be removed so that the image will be much smaller.
Supported docker images are all the Alpine/Debian versions, except for PHP 5.5 where we only support Debian 8 (jessie) (that is, `php:5.5`, `php:5.5-apache`, `php:5.5-cli`, `php:5.5-fpm`, `php:5.5-zts`)
Supported docker images are all the Alpine/Debian versions, except for PHP 5.5 where we only support Debian 8 (jessie) (that is, `php:5.5`, `php:5.5-apache`, `php:5.5-cli`, `php:5.5-fpm`, `php:5.5-zts`).
See also the notes in the [Special requirements](#special-requirements) section.
## Usage

View File

@ -76,6 +76,29 @@ extractExtensionsFromData() {
EXTENSIONS_TO_BE_TESTED="${EXTENSIONS_TO_BE_TESTED# }"
}
# Remove from the EXTENSIONS_TO_BE_TESTED variable the extensions that are
# not supported in the distro specified in the data/special-requirements file
# Update: EXTENSIONS_TO_BE_TESTED
filterUnsupportedExensionsForDistro() {
if test -z "$EXTENSIONS_TO_BE_TESTED"; then
return
fi
filterUnsupportedExensionsForDistro_reqs="$CI_BUILD_DIR/data/special-requirements"
if ! test -f "$filterUnsupportedExensionsForDistro_reqs"; then
return
fi
filterUnsupportedExensionsForDistro_filtered=''
for filterUnsupportedExensionsForDistro_extension in "$EXTENSIONS_TO_BE_TESTED"; do
if stringInList "!$DOCKER_DISTRO" "$(cat "$filterUnsupportedExensionsForDistro_reqs" | grep -E "^$filterUnsupportedExensionsForDistro_extension[ \t]")"; then
printf 'Note: extension "%s" is not supported for distro "%s"\n' "$filterUnsupportedExensionsForDistro_extension" "$DOCKER_DISTRO"
else
filterUnsupportedExensionsForDistro_filtered="$filterUnsupportedExensionsForDistro_filtered $filterUnsupportedExensionsForDistro_extension"
fi
done
EXTENSIONS_TO_BE_TESTED="${filterUnsupportedExensionsForDistro_filtered# }"
}
# Get the docker image ID for a PHP extension and a PHP version
#
# Arguments:
@ -262,6 +285,8 @@ if test -z "${DOCKER_DISTRO:-}"; then
exit 1
fi
. "$CI_BUILD_DIR/scripts/common"
case "${1:-}" in
from-commits)
if test -z "${2:-}"; then
@ -289,13 +314,13 @@ case "${1:-}" in
;;
esac
filterUnsupportedExensionsForDistro
if test -z "$EXTENSIONS_TO_BE_TESTED"; then
echo 'No extensions to be tested.'
exit 0
fi
. "$CI_BUILD_DIR/scripts/common"
printf '### EXTENSIONS TO BE TESTED: %s\n' "$EXTENSIONS_TO_BE_TESTED"
SOME_TEST_FAILED=0
IFS='

View File

@ -143,25 +143,43 @@ generateExtensionsTable() {
# Output:
# the markdown table
generateSpecialRequirementsTable() {
generateSpecialRequirementsTable_started=''
generateSpecialRequirementsTable_started=0
IFS='
'
for generateSpecialRequirementsTable_line in $(cat -- "$1" | sort); do
if test -z "$generateSpecialRequirementsTable_started"; then
printf '| Extension | Requirements |\n'
printf '|:---:|:---:|\n'
generateSpecialRequirementsTable_started='y'
fi
resetIFS
generateSpecialRequirementsTable_requirement="$(echo "$generateSpecialRequirementsTable_line" | sed -E 's/^\s*\w+\s+//')"
case "$generateSpecialRequirementsTable_requirement" in
zts)
generateSpecialRequirementsTable_requirement='Requires images with PHP compiled with thread-safety enabled (`zts`).'
;;
esac
printf '| %s | %s |\n' \
"$(echo "$generateSpecialRequirementsTable_line" | awk '{print $1;}')" \
"$generateSpecialRequirementsTable_requirement"
generateSpecialRequirementsTable_index=0
for generateSpecialRequirementsTable_chunk in $generateSpecialRequirementsTable_line; do
if test $generateSpecialRequirementsTable_index -eq 0; then
generateSpecialRequirementsTable_extension="$generateSpecialRequirementsTable_chunk"
else
if test $generateSpecialRequirementsTable_index -eq 1; then
generateSpecialRequirementsTable_requirements=''
elif test $generateSpecialRequirementsTable_index -eq 2; then
generateSpecialRequirementsTable_requirements="$(printf -- '&bull; %s<br />&bull; ' "$generateSpecialRequirementsTable_requirements")"
else
generateSpecialRequirementsTable_requirements="$(printf '%s<br />&bull; ' "$generateSpecialRequirementsTable_requirements")"
fi
case "$generateSpecialRequirementsTable_chunk" in
zts)
generateSpecialRequirementsTable_chunk='Requires images with PHP compiled with thread-safety enabled (`zts`).'
;;
!*)
generateSpecialRequirementsTable_chunk="$(printf 'Not available in `%s` docker images' "${generateSpecialRequirementsTable_chunk#!}")"
;;
esac
generateSpecialRequirementsTable_requirements="$(printf '%s%s' "$generateSpecialRequirementsTable_requirements" "$generateSpecialRequirementsTable_chunk")"
fi
generateSpecialRequirementsTable_index=$((generateSpecialRequirementsTable_index + 1))
done
if test $generateSpecialRequirementsTable_index -gt 1; then
if test $generateSpecialRequirementsTable_started -eq 0; then
printf '| Extension | Requirements |\n'
printf '|---|---|\n'
generateSpecialRequirementsTable_started=1
fi
printf '| %s | %s |\n' "$generateSpecialRequirementsTable_extension" "$generateSpecialRequirementsTable_requirements"
fi
done
}