Merge pull request #178 from mlocati/list-preinstalled-modules-once
List preinstalled modules just oncepull/181/head
commit
ed743db530
|
@ -42,12 +42,38 @@ setPHPMajorMinor() {
|
||||||
PHP_MAJMIN_VERSION=$(php-config --version | awk -F. '{print $1*100+$2}')
|
PHP_MAJMIN_VERSION=$(php-config --version | awk -F. '{print $1*100+$2}')
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the normalized list of already installed PHP modules
|
# Normalize the name of a PHP extension
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# $1: the name of the module to be normalized
|
||||||
#
|
#
|
||||||
# Output:
|
# Output:
|
||||||
# Space-separated list of module handles
|
# The normalized module name
|
||||||
getPHPInstalledModules() {
|
normalizePHPModuleName() {
|
||||||
getPHPInstalledModules_result=''
|
normalizePHPModuleName_name="$1"
|
||||||
|
case "$normalizePHPModuleName_name" in
|
||||||
|
*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*)
|
||||||
|
normalizePHPModuleName_name="$(LC_CTYPE=C printf '%s' "$normalizePHPModuleName_name" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case "$normalizePHPModuleName_name" in
|
||||||
|
pecl_http)
|
||||||
|
normalizePHPModuleName_name='http'
|
||||||
|
;;
|
||||||
|
zend\ opcache)
|
||||||
|
normalizePHPModuleName_name='opcache'
|
||||||
|
;;
|
||||||
|
*\ *)
|
||||||
|
printf '### WARNING Unrecognized module name: %s ###\n' "$1" >&2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
printf '%s' "$normalizePHPModuleName_name"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set these variables:
|
||||||
|
# - PHP_PREINSTALLED_MODULES the normalized list of PHP modules installed before running this script
|
||||||
|
setPHPPreinstalledModules() {
|
||||||
|
PHP_PREINSTALLED_MODULES=''
|
||||||
IFS='
|
IFS='
|
||||||
'
|
'
|
||||||
for getPHPInstalledModules_module in $(php -m); do
|
for getPHPInstalledModules_module in $(php -m); do
|
||||||
|
@ -57,27 +83,16 @@ getPHPInstalledModules() {
|
||||||
\[Zend\ Modules\])
|
\[Zend\ Modules\])
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
Core | PDO | PDO_* | Phar | Reflection | SimpleXML | SPL | SQLite | Xdebug)
|
|
||||||
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
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
getPHPInstalledModules_moduleNormalized="$getPHPInstalledModules_module"
|
getPHPInstalledModules_moduleNormalized="$(normalizePHPModuleName "$getPHPInstalledModules_module")"
|
||||||
|
if ! stringInList "$getPHPInstalledModules_moduleNormalized" "$PHP_PREINSTALLED_MODULES"; then
|
||||||
|
PHP_PREINSTALLED_MODULES="$PHP_PREINSTALLED_MODULES $getPHPInstalledModules_moduleNormalized"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if test -n "$getPHPInstalledModules_moduleNormalized"; then
|
|
||||||
if ! stringInList "$getPHPInstalledModules_moduleNormalized" "$getPHPInstalledModules_result"; then
|
|
||||||
getPHPInstalledModules_result="$getPHPInstalledModules_result $getPHPInstalledModules_moduleNormalized"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
resetIFS
|
resetIFS
|
||||||
printf '%s' "${getPHPInstalledModules_result# }"
|
PHP_PREINSTALLED_MODULES="${PHP_PREINSTALLED_MODULES# }"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the handles of the modules to be installed
|
# Get the handles of the modules to be installed
|
||||||
|
@ -91,7 +106,6 @@ getPHPInstalledModules() {
|
||||||
# Output:
|
# Output:
|
||||||
# Nothing
|
# Nothing
|
||||||
processCommandArguments() {
|
processCommandArguments() {
|
||||||
processCommandArguments_alreadyInstalled="$(getPHPInstalledModules)"
|
|
||||||
processCommandArguments_endArgs=0
|
processCommandArguments_endArgs=0
|
||||||
PHP_MODULES_TO_INSTALL=''
|
PHP_MODULES_TO_INSTALL=''
|
||||||
while :; do
|
while :; do
|
||||||
|
@ -116,17 +130,10 @@ processCommandArguments() {
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
if test $processCommandArguments_skip -eq 0; then
|
if test $processCommandArguments_skip -eq 0; then
|
||||||
case "$1" in
|
processCommandArguments_name="$(normalizePHPModuleName "$1")"
|
||||||
pecl_http)
|
|
||||||
processCommandArguments_name='http'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
processCommandArguments_name=$1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if stringInList "$processCommandArguments_name" "$PHP_MODULES_TO_INSTALL"; then
|
if stringInList "$processCommandArguments_name" "$PHP_MODULES_TO_INSTALL"; then
|
||||||
printf '### WARNING Duplicated module name specified: %s ###\n' "$processCommandArguments_name" >&2
|
printf '### WARNING Duplicated module name specified: %s ###\n' "$processCommandArguments_name" >&2
|
||||||
elif stringInList "$processCommandArguments_name" "$processCommandArguments_alreadyInstalled"; then
|
elif stringInList "$processCommandArguments_name" "$PHP_PREINSTALLED_MODULES"; then
|
||||||
printf '### WARNING Module already installed: %s ###\n' "$processCommandArguments_name" >&2
|
printf '### WARNING Module already installed: %s ###\n' "$processCommandArguments_name" >&2
|
||||||
else
|
else
|
||||||
PHP_MODULES_TO_INSTALL="$PHP_MODULES_TO_INSTALL $processCommandArguments_name"
|
PHP_MODULES_TO_INSTALL="$PHP_MODULES_TO_INSTALL $processCommandArguments_name"
|
||||||
|
@ -152,8 +159,7 @@ checkRequiredModule() {
|
||||||
if ! stringInList "$1" "$PHP_MODULES_TO_INSTALL"; then
|
if ! stringInList "$1" "$PHP_MODULES_TO_INSTALL"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
checkRequiredModule_alreadyInstalled="$(getPHPInstalledModules)"
|
if stringInList "$2" "$PHP_PREINSTALLED_MODULES"; then
|
||||||
if stringInList "$2" "$checkRequiredModule_alreadyInstalled"; then
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
PHP_MODULES_TO_INSTALL="$(removeStringFromList "$1" "$PHP_MODULES_TO_INSTALL")"
|
PHP_MODULES_TO_INSTALL="$(removeStringFromList "$1" "$PHP_MODULES_TO_INSTALL")"
|
||||||
|
@ -1431,7 +1437,7 @@ installPickle() {
|
||||||
fi
|
fi
|
||||||
curl -L -f https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar -o /tmp/pickle
|
curl -L -f https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar -o /tmp/pickle
|
||||||
chmod +x /tmp/pickle
|
chmod +x /tmp/pickle
|
||||||
if ! stringInList 'zip' "$(getPHPInstalledModules)"; then
|
if ! stringInList 'zip' "$PHP_PREINSTALLED_MODULES"; then
|
||||||
PHP_MODULES_TO_INSTALL="zip $(removeStringFromList 'zip' "$PHP_MODULES_TO_INSTALL")"
|
PHP_MODULES_TO_INSTALL="zip $(removeStringFromList 'zip' "$PHP_MODULES_TO_INSTALL")"
|
||||||
fi
|
fi
|
||||||
PECL_COMMAND="/tmp/pickle install --defaults"
|
PECL_COMMAND="/tmp/pickle install --defaults"
|
||||||
|
@ -1528,6 +1534,7 @@ mkdir -p /tmp/src
|
||||||
IPE_ERRFLAG_FILE="$(mktemp -p /tmp/src)"
|
IPE_ERRFLAG_FILE="$(mktemp -p /tmp/src)"
|
||||||
setDistro
|
setDistro
|
||||||
setPHPMajorMinor
|
setPHPMajorMinor
|
||||||
|
setPHPPreinstalledModules
|
||||||
case "$PHP_MAJMIN_VERSION" in
|
case "$PHP_MAJMIN_VERSION" in
|
||||||
505 | 506 | 700 | 701 | 702 | 703 | 704 | 800) ;;
|
505 | 506 | 700 | 701 | 702 | 703 | 704 | 800) ;;
|
||||||
*)
|
*)
|
||||||
|
|
Loading…
Reference in New Issue