mirror of
https://github.com/danog/docker-php-extension-installer.git
synced 2024-12-03 09:57:52 +01:00
Merge pull request #86 from mlocati/fix-buildRequiredPackageLists-output-handling
Simplify handling of docker images, fix handling of buildRequiredPackageLists output
This commit is contained in:
commit
191b940b93
@ -180,10 +180,6 @@ sortModulesToInstall() {
|
||||
# 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=''
|
||||
@ -202,7 +198,7 @@ buildRequiredPackageLists() {
|
||||
fi
|
||||
;;
|
||||
debian@9)
|
||||
buildRequiredPackageLists_libssldev='libssl-dev'
|
||||
buildRequiredPackageLists_libssldev='libssl1.0-dev'
|
||||
;;
|
||||
debian@*)
|
||||
buildRequiredPackageLists_libssldev='libssl([0-9]+(\.[0-9]+)*)?-dev$'
|
||||
@ -555,7 +551,7 @@ buildRequiredPackageLists() {
|
||||
PACKAGES_PERSISTENT=''
|
||||
PACKAGES_VOLATILE=''
|
||||
if test -z "$buildRequiredPackageLists_persistent$buildRequiredPackageLists_volatile"; then
|
||||
return 0
|
||||
return
|
||||
fi
|
||||
case "$buildRequiredPackageLists_distro" in
|
||||
alpine)
|
||||
@ -568,15 +564,13 @@ buildRequiredPackageLists() {
|
||||
esac
|
||||
if test -n "$buildRequiredPackageLists_persistent"; then
|
||||
PACKAGES_PERSISTENT="$(expandPackagesToBeInstalled $buildRequiredPackageLists_persistent)"
|
||||
if test -s "$IPE_ERRFILE"; then
|
||||
cat "$IPE_ERRFILE" >&2
|
||||
if test -s "$IPE_ERRFLAG_FILE"; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if test -n "$buildRequiredPackageLists_volatile"; then
|
||||
buildRequiredPackageLists_packages="$(expandPackagesToBeInstalled $buildRequiredPackageLists_volatile)"
|
||||
if test -s "$IPE_ERRFILE"; then
|
||||
cat "$IPE_ERRFILE" >&2
|
||||
if test -s "$IPE_ERRFLAG_FILE"; then
|
||||
exit 1
|
||||
fi
|
||||
resetIFS
|
||||
@ -602,9 +596,10 @@ expandPackagesToBeInstalled() {
|
||||
alpine)
|
||||
expandPackagesToBeInstalled_log="$(apk add --simulate $@ 2>&1 || printf '\nERROR: apk failed\n')"
|
||||
if test -n "$(printf '%s' "$expandPackagesToBeInstalled_log" | grep -E '^ERROR:')"; then
|
||||
printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >"$IPE_ERRFILE"
|
||||
printf '%s ' "$@" >>"$IPE_ERRFILE"
|
||||
printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >>"$IPE_ERRFILE"
|
||||
printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >&2
|
||||
printf '%s ' "$@" >&2
|
||||
printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >&2
|
||||
echo 'y' >"$IPE_ERRFLAG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
IFS='
|
||||
@ -619,9 +614,10 @@ expandPackagesToBeInstalled() {
|
||||
debian)
|
||||
expandPackagesToBeInstalled_log="$(DEBIAN_FRONTEND=noninteractive apt-get install -sy $@ 2>&1 || printf '\nE: apt-get failed\n')"
|
||||
if test -n "$(printf '%s' "$expandPackagesToBeInstalled_log" | grep -E '^E:')"; then
|
||||
printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >"$IPE_ERRFILE"
|
||||
printf '%s ' "$@" >"$IPE_ERRFILE"
|
||||
printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >"$IPE_ERRFILE"
|
||||
printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >&2
|
||||
printf '%s ' "$@" >&2
|
||||
printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >&2
|
||||
echo 'y' >"$IPE_ERRFLAG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
expandPackagesToBeInstalled_inNewPackages=0
|
||||
@ -1142,7 +1138,7 @@ cleanup() {
|
||||
|
||||
resetIFS
|
||||
mkdir -p /tmp/src
|
||||
IPE_ERRFILE="$(mktemp -p /tmp/src)"
|
||||
IPE_ERRFLAG_FILE="$(mktemp -p /tmp/src)"
|
||||
PHP_MAJMIN_VERSION=$(getPHPMajorMinor)
|
||||
case "$PHP_MAJMIN_VERSION" in
|
||||
506 | 700 | 701 | 702 | 703 | 704) ;;
|
||||
@ -1159,7 +1155,8 @@ fi
|
||||
|
||||
sortModulesToInstall
|
||||
|
||||
if buildRequiredPackageLists $PHP_MAJMIN_VERSION $PHP_MODULES_TO_INSTALL; then
|
||||
buildRequiredPackageLists $PHP_MAJMIN_VERSION $PHP_MODULES_TO_INSTALL
|
||||
if test -n "$PACKAGES_PERSISTENT$PACKAGES_VOLATILE"; then
|
||||
installRequiredPackages
|
||||
fi
|
||||
docker-php-source extract
|
||||
|
@ -28,123 +28,29 @@ getDockerImageName() {
|
||||
getDockerImageName_version="$2"
|
||||
;;
|
||||
esac
|
||||
getDockerImageName_suffix='-cli'
|
||||
getDockerImageName_suffix='cli'
|
||||
getDockerImageName_reqs="$TRAVIS_BUILD_DIR/data/special-requirements"
|
||||
if test -f "$getDockerImageName_reqs"; then
|
||||
IFS=' '
|
||||
for getDockerImageName_testExtension in $1; do
|
||||
if test -n "$(cat "$getDockerImageName_reqs" | grep -E "^$getDockerImageName_testExtension[ \t]+zts[ \t]*$")"; then
|
||||
getDockerImageName_suffix="-zts"
|
||||
getDockerImageName_suffix='zts'
|
||||
fi
|
||||
done
|
||||
fi
|
||||
getDockerImageName_distro="-$DOCKER_DISTRO"
|
||||
case "$DOCKER_DISTRO" in
|
||||
alpine3.4)
|
||||
# available for PHP from version 5.6 to version 7.1
|
||||
case "$2" in
|
||||
5.* | 7.0 | 7.1) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
alpine3.6)
|
||||
# available for PHP 7.2
|
||||
case "$2" in
|
||||
7.2) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
alpine3.7)
|
||||
# available for PHP from version 5.6 to version 7.2
|
||||
# default Alpine one for PHP 7.0
|
||||
case "$2" in
|
||||
7.0)
|
||||
#getDockerImageName_distro='-alpine'
|
||||
;;
|
||||
5.* | 7.1 | 7.2) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
alpine3.8)
|
||||
# available for PHP from version 5.6 to version 7.3 (except PHP 7.0)
|
||||
# default Alpine one for PHP 5.6
|
||||
case "$2" in
|
||||
5.6)
|
||||
#getDockerImageName_distro='-alpine'
|
||||
;;
|
||||
5.* | 7.1 | 7.2 | 7.3) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
alpine3.9)
|
||||
# available for PHP from version 7.1 to version 7.3
|
||||
case "$2" in
|
||||
7.1 | 7.2 | 7.3) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
alpine3.10)
|
||||
# available for PHP from version 7.1
|
||||
# default Alpine one for PHP 7.1 -> 7.4
|
||||
case "$2" in
|
||||
7.1 | 7.2 | 7.3 | 7.4)
|
||||
#getDockerImageName_distro='-alpine'
|
||||
;;
|
||||
5.* | 7.0)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
jessie) # Debian 8
|
||||
# available for PHP up to version 7.1
|
||||
case "$2" in
|
||||
5.* | 7.0 | 7.1) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
stretch) # Debian 9
|
||||
# available for PHP up to version 7.3
|
||||
# default one for PHP 5.6 -> 7.0
|
||||
case "$2" in
|
||||
5.* | 7.0)
|
||||
#getDockerImageName_distro=''
|
||||
;;
|
||||
7.1 | 7.2 | 7.3) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
buster) # Debian 10
|
||||
# available for PHP from version 7.1
|
||||
# default one for PHP 7.1 -> 7.4
|
||||
case "$2" in
|
||||
7.1 | 7.2 | 7.3 | 7.4)
|
||||
#getDockerImageName_distro=''
|
||||
;;
|
||||
5.* | 7.0)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
printf 'Unrecognized value of DOCKER_DISTRO environment variable (%s)\n' "$DOCKER_DISTRO" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
printf 'php:%s%s%s' "$getDockerImageName_version" "$getDockerImageName_suffix" "$getDockerImageName_distro"
|
||||
getDockerImageName_imageName="$(printf 'php:%s-%s-%s' "$getDockerImageName_version" "$getDockerImageName_suffix" "$DOCKER_DISTRO")"
|
||||
if test -z "$(docker images -q "$getDockerImageName_imageName" 2>/dev/null)"; then
|
||||
getDockerImageName_log="$(docker pull "$getDockerImageName_imageName" 2>&1 || true)"
|
||||
if test -z "$(docker images -q "$getDockerImageName_imageName" 2>/dev/null)"; then
|
||||
if test "${getDockerImageName_log#*manifest unknown}" != "$getDockerImageName_log" || test "${getDockerImageName_log#*manifest for * not found}" != "$getDockerImageName_log"; then
|
||||
true
|
||||
return
|
||||
fi
|
||||
printf '%s\n' "$getDockerImageName_log" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
printf '%s' "$getDockerImageName_imageName"
|
||||
}
|
||||
|
||||
# Test an extension
|
||||
@ -163,6 +69,9 @@ testExtension() {
|
||||
return 1
|
||||
fi
|
||||
testExtension_Image="$(getDockerImageName "$1" "$2")"
|
||||
if test $? -ne 0; then
|
||||
exit 1
|
||||
fi
|
||||
if test -z "$testExtension_Image"; then
|
||||
printf ' - Docker image not available\n'
|
||||
return 0
|
||||
|
Loading…
Reference in New Issue
Block a user