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:
Michele Locati 2019-12-23 14:00:33 +01:00 committed by GitHub
commit 191b940b93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 127 deletions

View File

@ -180,10 +180,6 @@ sortModulesToInstall() {
# Set: # Set:
# PACKAGES_PERSISTENT # PACKAGES_PERSISTENT
# PACKAGES_VOLATILE # PACKAGES_VOLATILE
#
# Return:
# 0 (true): if we to install some package
# 1 (false): if no package is required
buildRequiredPackageLists() { buildRequiredPackageLists() {
buildRequiredPackageLists_persistent='' buildRequiredPackageLists_persistent=''
buildRequiredPackageLists_volatile='' buildRequiredPackageLists_volatile=''
@ -202,7 +198,7 @@ buildRequiredPackageLists() {
fi fi
;; ;;
debian@9) debian@9)
buildRequiredPackageLists_libssldev='libssl-dev' buildRequiredPackageLists_libssldev='libssl1.0-dev'
;; ;;
debian@*) debian@*)
buildRequiredPackageLists_libssldev='libssl([0-9]+(\.[0-9]+)*)?-dev$' buildRequiredPackageLists_libssldev='libssl([0-9]+(\.[0-9]+)*)?-dev$'
@ -555,7 +551,7 @@ buildRequiredPackageLists() {
PACKAGES_PERSISTENT='' PACKAGES_PERSISTENT=''
PACKAGES_VOLATILE='' PACKAGES_VOLATILE=''
if test -z "$buildRequiredPackageLists_persistent$buildRequiredPackageLists_volatile"; then if test -z "$buildRequiredPackageLists_persistent$buildRequiredPackageLists_volatile"; then
return 0 return
fi fi
case "$buildRequiredPackageLists_distro" in case "$buildRequiredPackageLists_distro" in
alpine) alpine)
@ -568,15 +564,13 @@ buildRequiredPackageLists() {
esac esac
if test -n "$buildRequiredPackageLists_persistent"; then if test -n "$buildRequiredPackageLists_persistent"; then
PACKAGES_PERSISTENT="$(expandPackagesToBeInstalled $buildRequiredPackageLists_persistent)" PACKAGES_PERSISTENT="$(expandPackagesToBeInstalled $buildRequiredPackageLists_persistent)"
if test -s "$IPE_ERRFILE"; then if test -s "$IPE_ERRFLAG_FILE"; then
cat "$IPE_ERRFILE" >&2
exit 1 exit 1
fi fi
fi fi
if test -n "$buildRequiredPackageLists_volatile"; then if test -n "$buildRequiredPackageLists_volatile"; then
buildRequiredPackageLists_packages="$(expandPackagesToBeInstalled $buildRequiredPackageLists_volatile)" buildRequiredPackageLists_packages="$(expandPackagesToBeInstalled $buildRequiredPackageLists_volatile)"
if test -s "$IPE_ERRFILE"; then if test -s "$IPE_ERRFLAG_FILE"; then
cat "$IPE_ERRFILE" >&2
exit 1 exit 1
fi fi
resetIFS resetIFS
@ -602,9 +596,10 @@ expandPackagesToBeInstalled() {
alpine) alpine)
expandPackagesToBeInstalled_log="$(apk add --simulate $@ 2>&1 || printf '\nERROR: apk failed\n')" expandPackagesToBeInstalled_log="$(apk add --simulate $@ 2>&1 || printf '\nERROR: apk failed\n')"
if test -n "$(printf '%s' "$expandPackagesToBeInstalled_log" | grep -E '^ERROR:')"; then if test -n "$(printf '%s' "$expandPackagesToBeInstalled_log" | grep -E '^ERROR:')"; then
printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >"$IPE_ERRFILE" printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >&2
printf '%s ' "$@" >>"$IPE_ERRFILE" printf '%s ' "$@" >&2
printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >>"$IPE_ERRFILE" printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >&2
echo 'y' >"$IPE_ERRFLAG_FILE"
exit 1 exit 1
fi fi
IFS=' IFS='
@ -619,9 +614,10 @@ expandPackagesToBeInstalled() {
debian) debian)
expandPackagesToBeInstalled_log="$(DEBIAN_FRONTEND=noninteractive apt-get install -sy $@ 2>&1 || printf '\nE: apt-get failed\n')" 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 if test -n "$(printf '%s' "$expandPackagesToBeInstalled_log" | grep -E '^E:')"; then
printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >"$IPE_ERRFILE" printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >&2
printf '%s ' "$@" >"$IPE_ERRFILE" printf '%s ' "$@" >&2
printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >"$IPE_ERRFILE" printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >&2
echo 'y' >"$IPE_ERRFLAG_FILE"
exit 1 exit 1
fi fi
expandPackagesToBeInstalled_inNewPackages=0 expandPackagesToBeInstalled_inNewPackages=0
@ -1142,7 +1138,7 @@ cleanup() {
resetIFS resetIFS
mkdir -p /tmp/src mkdir -p /tmp/src
IPE_ERRFILE="$(mktemp -p /tmp/src)" IPE_ERRFLAG_FILE="$(mktemp -p /tmp/src)"
PHP_MAJMIN_VERSION=$(getPHPMajorMinor) PHP_MAJMIN_VERSION=$(getPHPMajorMinor)
case "$PHP_MAJMIN_VERSION" in case "$PHP_MAJMIN_VERSION" in
506 | 700 | 701 | 702 | 703 | 704) ;; 506 | 700 | 701 | 702 | 703 | 704) ;;
@ -1159,7 +1155,8 @@ fi
sortModulesToInstall 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 installRequiredPackages
fi fi
docker-php-source extract docker-php-source extract

View File

@ -28,123 +28,29 @@ getDockerImageName() {
getDockerImageName_version="$2" getDockerImageName_version="$2"
;; ;;
esac esac
getDockerImageName_suffix='-cli' getDockerImageName_suffix='cli'
getDockerImageName_reqs="$TRAVIS_BUILD_DIR/data/special-requirements" getDockerImageName_reqs="$TRAVIS_BUILD_DIR/data/special-requirements"
if test -f "$getDockerImageName_reqs"; then if test -f "$getDockerImageName_reqs"; then
IFS=' ' IFS=' '
for getDockerImageName_testExtension in $1; do for getDockerImageName_testExtension in $1; do
if test -n "$(cat "$getDockerImageName_reqs" | grep -E "^$getDockerImageName_testExtension[ \t]+zts[ \t]*$")"; then if test -n "$(cat "$getDockerImageName_reqs" | grep -E "^$getDockerImageName_testExtension[ \t]+zts[ \t]*$")"; then
getDockerImageName_suffix="-zts" getDockerImageName_suffix='zts'
fi fi
done done
fi fi
getDockerImageName_distro="-$DOCKER_DISTRO" getDockerImageName_imageName="$(printf 'php:%s-%s-%s' "$getDockerImageName_version" "$getDockerImageName_suffix" "$DOCKER_DISTRO")"
case "$DOCKER_DISTRO" in if test -z "$(docker images -q "$getDockerImageName_imageName" 2>/dev/null)"; then
alpine3.4) getDockerImageName_log="$(docker pull "$getDockerImageName_imageName" 2>&1 || true)"
# available for PHP from version 5.6 to version 7.1 if test -z "$(docker images -q "$getDockerImageName_imageName" 2>/dev/null)"; then
case "$2" in if test "${getDockerImageName_log#*manifest unknown}" != "$getDockerImageName_log" || test "${getDockerImageName_log#*manifest for * not found}" != "$getDockerImageName_log"; then
5.* | 7.0 | 7.1) ;; true
*)
return return
;; fi
esac printf '%s\n' "$getDockerImageName_log" >&2
;; exit 1
alpine3.6) fi
# available for PHP 7.2 fi
case "$2" in printf '%s' "$getDockerImageName_imageName"
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"
} }
# Test an extension # Test an extension
@ -163,6 +69,9 @@ testExtension() {
return 1 return 1
fi fi
testExtension_Image="$(getDockerImageName "$1" "$2")" testExtension_Image="$(getDockerImageName "$1" "$2")"
if test $? -ne 0; then
exit 1
fi
if test -z "$testExtension_Image"; then if test -z "$testExtension_Image"; then
printf ' - Docker image not available\n' printf ' - Docker image not available\n'
return 0 return 0