commit
e42faf7191
|
@ -0,0 +1,10 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
tab_width = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = true
|
|
@ -18,6 +18,14 @@ test-extensions-job-template: &test-extensions-job-template
|
|||
|
||||
jobs:
|
||||
include:
|
||||
- stage: Pre-test checks
|
||||
name: Check coding style
|
||||
if: type = pull_request
|
||||
language: go
|
||||
go: '1.13'
|
||||
before_script: GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt
|
||||
script: shfmt -d -s -ln posix -i 0 -ci -kp install-php-extensions scripts/common scripts/travisci-test-extensions scripts/travisci-update-readme scripts/update-readme
|
||||
|
||||
- <<: *test-extensions-job-template
|
||||
name: Test extensions on Alpine 3.7
|
||||
env: DOCKER_DISTRO=alpine3.7
|
||||
|
|
|
@ -13,7 +13,7 @@ set -o errexit
|
|||
set -o nounset
|
||||
|
||||
# Reset the Internal Field Separator
|
||||
resetIFS () {
|
||||
resetIFS() {
|
||||
IFS='
|
||||
'
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ resetIFS () {
|
|||
#
|
||||
# Output:
|
||||
# alpine|debian
|
||||
getDistro () {
|
||||
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)"
|
||||
|
@ -35,7 +35,7 @@ getDistro () {
|
|||
# Example output:
|
||||
# alpine@3.10
|
||||
# debian@9
|
||||
getDistroVersion () {
|
||||
getDistroVersion() {
|
||||
getDistroVersion_distro="$(getDistro)"
|
||||
if test -z "$getDistroVersion_distro"; then
|
||||
return
|
||||
|
@ -54,7 +54,7 @@ getDistroVersion () {
|
|||
#
|
||||
# Output:
|
||||
# The PHP numeric Major-Minor version
|
||||
getPHPMajorMinor () {
|
||||
getPHPMajorMinor() {
|
||||
php -r '$v = explode(".", PHP_VERSION); echo $v[0] * 100 + $v[1];'
|
||||
}
|
||||
|
||||
|
@ -62,25 +62,24 @@ getPHPMajorMinor () {
|
|||
#
|
||||
# Output:
|
||||
# Space-separated list of module handles
|
||||
getPHPInstalledModules () {
|
||||
getPHPInstalledModules() {
|
||||
getPHPInstalledModules_result=''
|
||||
IFS='
|
||||
'
|
||||
for getPHPInstalledModules_module in $(php -m); do
|
||||
getPHPInstalledModules_moduleNormalized=''
|
||||
case "$getPHPInstalledModules_module" in
|
||||
\[PHP\ Modules\])
|
||||
;;
|
||||
\[PHP\ Modules\]) ;;
|
||||
\[Zend\ Modules\])
|
||||
break
|
||||
;;
|
||||
Core|PDO|PDO_*|Phar|Reflection|SimpleXML|SPL|SQLite|Xdebug)
|
||||
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*)
|
||||
*\ * | *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
|
||||
;;
|
||||
*)
|
||||
|
@ -107,7 +106,7 @@ getPHPInstalledModules () {
|
|||
#
|
||||
# Output:
|
||||
# Nothing
|
||||
processCommandArguments () {
|
||||
processCommandArguments() {
|
||||
processCommandArguments_alreadyInstalled="$(getPHPInstalledModules)"
|
||||
processCommandArguments_endArgs=0
|
||||
PHP_MODULES_TO_INSTALL=''
|
||||
|
@ -153,7 +152,7 @@ processCommandArguments () {
|
|||
#
|
||||
# Output:
|
||||
# Nothing
|
||||
sortModulesToInstall () {
|
||||
sortModulesToInstall() {
|
||||
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
|
||||
|
@ -185,7 +184,7 @@ sortModulesToInstall () {
|
|||
# Return:
|
||||
# 0 (true): if we to install some package
|
||||
# 1 (false): if no package is required
|
||||
buildRequiredPackageLists () {
|
||||
buildRequiredPackageLists() {
|
||||
buildRequiredPackageLists_persistent=''
|
||||
buildRequiredPackageLists_volatile=''
|
||||
buildRequiredPackageLists_distro="$(getDistro)"
|
||||
|
@ -580,7 +579,7 @@ buildRequiredPackageLists () {
|
|||
#
|
||||
# Output:
|
||||
# Space-separated list of every APT/APK packages that will be installed
|
||||
expandPackagesToBeInstalled () {
|
||||
expandPackagesToBeInstalled() {
|
||||
expandPackagesToBeInstalled_result=''
|
||||
case "$(getDistro)" in
|
||||
alpine)
|
||||
|
@ -637,7 +636,7 @@ expandPackagesToBeInstalled () {
|
|||
#
|
||||
# Arguments:
|
||||
# $@: the list of APT/APK packages to be installed
|
||||
installRequiredPackages () {
|
||||
installRequiredPackages() {
|
||||
printf '### INSTALLING REQUIRED PACKAGES ###\n'
|
||||
printf '# Packages to be kept after installation: %s\n' "$PACKAGES_PERSISTENT"
|
||||
printf '# Packages to be used only for installation: %s\n' "$PACKAGES_VOLATILE"
|
||||
|
@ -667,7 +666,7 @@ installRequiredPackages () {
|
|||
getInstalledPackageVersion() {
|
||||
case "$(getDistro)" in
|
||||
alpine)
|
||||
apk info "$1" | head -n1 | cut -c $(( ${#1} + 2 ))- | grep -o -E '^[0-9]+(\.[0-9]+){0,2}'
|
||||
apk info "$1" | head -n1 | cut -c $((${#1} + 2))- | grep -o -E '^[0-9]+(\.[0-9]+){0,2}'
|
||||
;;
|
||||
debian)
|
||||
dpkg-query --showformat='${Version}' --show "$1" 2>/dev/null | grep -o -E '^[0-9]+(\.[0-9]+){0,2}'
|
||||
|
@ -688,7 +687,7 @@ getInstalledPackageVersion() {
|
|||
compareVersions() {
|
||||
compareVersions_v1="$1.0.0"
|
||||
compareVersions_v2="$2.0.0"
|
||||
compareVersions_vMin="$(printf '%s\n%s' "${compareVersions_v1}" "${compareVersions_v2}" | sort -t '.' -n -k1,1 -k2,2 -k3,3 | head -n 1)"
|
||||
compareVersions_vMin="$(printf '%s\n%s' "$compareVersions_v1" "$compareVersions_v2" | sort -t '.' -n -k1,1 -k2,2 -k3,3 | head -n 1)"
|
||||
if test "$compareVersions_vMin" != "$compareVersions_v1"; then
|
||||
echo '1'
|
||||
elif test "$compareVersions_vMin" = "$compareVersions_v2"; then
|
||||
|
@ -709,7 +708,7 @@ compareVersions() {
|
|||
#
|
||||
# Output:
|
||||
# Nothing
|
||||
installBundledModule () {
|
||||
installBundledModule() {
|
||||
printf '### INSTALLING BUNDLED MODULE %s ###\n' "$2"
|
||||
case "$2" in
|
||||
gd)
|
||||
|
@ -736,7 +735,7 @@ installBundledModule () {
|
|||
imap)
|
||||
PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl
|
||||
;;
|
||||
interbase|pdo_firebird)
|
||||
interbase | pdo_firebird)
|
||||
case "$(getDistro)" in
|
||||
alpine)
|
||||
if ! test -d /tmp/src/firebird; then
|
||||
|
@ -758,9 +757,9 @@ installBundledModule () {
|
|||
ldap)
|
||||
docker-php-ext-configure ldap --with-libdir=lib/$(gcc -dumpmachine)
|
||||
;;
|
||||
mssql|pdo_dblib)
|
||||
mssql | pdo_dblib)
|
||||
case "$1" in
|
||||
506|700|701|702|703|704)
|
||||
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_PACKAGE_LINKS="$UNNEEDED_PACKAGE_LINKS /usr/lib/libsybdb.so"
|
||||
|
@ -770,7 +769,7 @@ installBundledModule () {
|
|||
;;
|
||||
odbc)
|
||||
case "$1" in
|
||||
506|700|701|702|703|704)
|
||||
506 | 700 | 701 | 702 | 703 | 704)
|
||||
docker-php-source extract
|
||||
cd /usr/src/php/ext/odbc
|
||||
phpize
|
||||
|
@ -821,7 +820,7 @@ installBundledModule () {
|
|||
#
|
||||
# Output:
|
||||
# The path of the extracted directory
|
||||
getPackageSource () {
|
||||
getPackageSource() {
|
||||
mkdir -p /tmp/src
|
||||
getPackageSource_tempFile=$(mktemp -p /tmp/src)
|
||||
curl -L -s -S -o "$getPackageSource_tempFile" "$1"
|
||||
|
@ -852,7 +851,7 @@ getPackageSource () {
|
|||
# $2: the URL of the module source code
|
||||
# $3: the options of the configure command
|
||||
# $4: the value of CFLAGS
|
||||
installModuleFromSource () {
|
||||
installModuleFromSource() {
|
||||
printf '### INSTALLING MODULE %s FROM SOURCE CODE ###\n' "$1"
|
||||
installModuleFromSource_dir="$(getPackageSource "$2")"
|
||||
cd "$installModuleFromSource_dir"
|
||||
|
@ -868,7 +867,7 @@ installModuleFromSource () {
|
|||
# Arguments:
|
||||
# $1: the numeric PHP Major-Minor version
|
||||
# $2: the handle of the PHP module
|
||||
installPECLModule () {
|
||||
installPECLModule() {
|
||||
printf '### INSTALLING PECL MODULE %s ###\n' "$2"
|
||||
installPECLModule_actual="$2"
|
||||
installPECLModule_stdin='\n'
|
||||
|
@ -1054,7 +1053,7 @@ installPECLModule () {
|
|||
# Return:
|
||||
# 0 (true): if the string is in the list
|
||||
# 1 (false): if the string is not in the list
|
||||
stringInList () {
|
||||
stringInList() {
|
||||
for stringInList_listItem in $2; do
|
||||
if test "$1" = "$stringInList_listItem"; then
|
||||
return 0
|
||||
|
@ -1071,7 +1070,7 @@ stringInList () {
|
|||
#
|
||||
# Output:
|
||||
# The list without the word
|
||||
removeStringFromList () {
|
||||
removeStringFromList() {
|
||||
removeStringFromList_result=''
|
||||
for removeStringFromList_listItem in $2; do
|
||||
if test "$1" != "$removeStringFromList_listItem"; then
|
||||
|
@ -1086,7 +1085,7 @@ removeStringFromList () {
|
|||
}
|
||||
|
||||
# Cleanup everything at the end of the execution
|
||||
cleanup () {
|
||||
cleanup() {
|
||||
cleanup_distro="$(getDistro)"
|
||||
if test -n "$UNNEEDED_PACKAGE_LINKS"; then
|
||||
printf '### REMOVING UNNEEDED PACKAGE LINKS ###\n'
|
||||
|
@ -1123,10 +1122,10 @@ cleanup () {
|
|||
resetIFS
|
||||
PHP_MAJMIN_VERSION=$(getPHPMajorMinor)
|
||||
case "$PHP_MAJMIN_VERSION" in
|
||||
506|700|701|702|703|704)
|
||||
;;
|
||||
506 | 700 | 701 | 702 | 703 | 704) ;;
|
||||
*)
|
||||
printf "### ERROR: Unsupported PHP version: %s.%s ###\n" $(( PHP_MAJMIN_VERSION / 100 )) $(( PHP_MAJMIN_VERSION % 100 ))
|
||||
printf "### ERROR: Unsupported PHP version: %s.%s ###\n" $((PHP_MAJMIN_VERSION / 100)) $((PHP_MAJMIN_VERSION % 100))
|
||||
;;
|
||||
esac
|
||||
UNNEEDED_PACKAGE_LINKS=''
|
||||
processCommandArguments "$@"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Reset the Internal Field Separator
|
||||
resetIFS () {
|
||||
resetIFS() {
|
||||
IFS='
|
||||
'
|
||||
}
|
||||
|
@ -15,12 +15,10 @@ resetIFS () {
|
|||
# Return:
|
||||
# 0 (true): if the string is in the list
|
||||
# 1 (false): if the string is not in the list
|
||||
stringInList () {
|
||||
stringInList() {
|
||||
resetIFS
|
||||
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
|
||||
|
@ -35,20 +33,17 @@ stringInList () {
|
|||
#
|
||||
# Output:
|
||||
# The space-separated list of strings that are present in both lists
|
||||
commonElements () {
|
||||
commonElements() {
|
||||
commonElements_result=''
|
||||
resetIFS
|
||||
for commonElements_inA in ${1}
|
||||
do
|
||||
if stringInList "${commonElements_inA}" "${2}"
|
||||
then
|
||||
if test -z "${commonElements_result}"
|
||||
then
|
||||
commonElements_result="${commonElements_inA}"
|
||||
for commonElements_inA in $1; do
|
||||
if stringInList "$commonElements_inA" "$2"; then
|
||||
if test -z "$commonElements_result"; then
|
||||
commonElements_result="$commonElements_inA"
|
||||
else
|
||||
commonElements_result="${commonElements_result} ${commonElements_inA}"
|
||||
commonElements_result="$commonElements_result $commonElements_inA"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "${commonElements_result}"
|
||||
echo "$commonElements_result"
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ ALREADY_TESTED_EXTENSIONS=''
|
|||
#
|
||||
# Outputs:
|
||||
# the full docker image ID
|
||||
getDockerImageName () {
|
||||
getDockerImageName() {
|
||||
case "$2" in
|
||||
*)
|
||||
getDockerImageName_version="$2"
|
||||
|
@ -43,8 +43,7 @@ getDockerImageName () {
|
|||
alpine3.4)
|
||||
# available for PHP from version 5.6 to version 7.1
|
||||
case "$2" in
|
||||
5.*|7.0|7.1)
|
||||
;;
|
||||
5.* | 7.0 | 7.1) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
|
@ -53,8 +52,7 @@ getDockerImageName () {
|
|||
alpine3.6)
|
||||
# available for PHP 7.2
|
||||
case "$2" in
|
||||
7.2)
|
||||
;;
|
||||
7.2) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
|
@ -67,8 +65,7 @@ getDockerImageName () {
|
|||
7.0)
|
||||
#getDockerImageName_distro='-alpine'
|
||||
;;
|
||||
5.*|7.1|7.2)
|
||||
;;
|
||||
5.* | 7.1 | 7.2) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
|
@ -81,8 +78,7 @@ getDockerImageName () {
|
|||
5.6)
|
||||
#getDockerImageName_distro='-alpine'
|
||||
;;
|
||||
5.*|7.1|7.2|7.3)
|
||||
;;
|
||||
5.* | 7.1 | 7.2 | 7.3) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
|
@ -91,8 +87,7 @@ getDockerImageName () {
|
|||
alpine3.9)
|
||||
# available for PHP from version 7.1 to version 7.3
|
||||
case "$2" in
|
||||
7.1|7.2|7.3)
|
||||
;;
|
||||
7.1 | 7.2 | 7.3) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
|
@ -102,10 +97,10 @@ getDockerImageName () {
|
|||
# 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)
|
||||
7.1 | 7.2 | 7.3 | 7.4)
|
||||
#getDockerImageName_distro='-alpine'
|
||||
;;
|
||||
5.*|7.0)
|
||||
5.* | 7.0)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
@ -113,8 +108,7 @@ getDockerImageName () {
|
|||
jessie) # Debian 8
|
||||
# available for PHP up to version 7.1
|
||||
case "$2" in
|
||||
5.*|7.0|7.1)
|
||||
;;
|
||||
5.* | 7.0 | 7.1) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
|
@ -124,11 +118,10 @@ getDockerImageName () {
|
|||
# available for PHP up to version 7.3
|
||||
# default one for PHP 5.6 -> 7.0
|
||||
case "$2" in
|
||||
5.*|7.0)
|
||||
5.* | 7.0)
|
||||
#getDockerImageName_distro=''
|
||||
;;
|
||||
7.1|7.2|7.3)
|
||||
;;
|
||||
7.1 | 7.2 | 7.3) ;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
|
@ -138,10 +131,10 @@ getDockerImageName () {
|
|||
# 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)
|
||||
7.1 | 7.2 | 7.3 | 7.4)
|
||||
#getDockerImageName_distro=''
|
||||
;;
|
||||
5.*|7.0)
|
||||
5.* | 7.0)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
@ -154,7 +147,6 @@ getDockerImageName () {
|
|||
printf 'php:%s%s%s' "$getDockerImageName_version" "$getDockerImageName_suffix" "$getDockerImageName_distro"
|
||||
}
|
||||
|
||||
|
||||
# Test an extension
|
||||
#
|
||||
# Arguments:
|
||||
|
@ -164,7 +156,7 @@ getDockerImageName () {
|
|||
# Return:
|
||||
# 0 (true): if test passes
|
||||
# 1 (false): if test fails
|
||||
testExtension () {
|
||||
testExtension() {
|
||||
printf 'PHP version: %s\n' "$2"
|
||||
if test -n "$(printf '%s' "$2" | sed -E 's/^[0-9]+\.[0-9]+$//')"; then
|
||||
printf ' INVALID PHP VERSION: %s\n' "$2" >&2
|
||||
|
@ -176,7 +168,7 @@ testExtension () {
|
|||
return 0
|
||||
fi
|
||||
printf ' - Docker image: %s\n' "$testExtension_Image"
|
||||
testExtension_out=`mktemp`
|
||||
testExtension_out="$(mktemp)"
|
||||
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'
|
||||
|
@ -188,7 +180,6 @@ testExtension () {
|
|||
return 1
|
||||
}
|
||||
|
||||
|
||||
# Test a new extension line
|
||||
#
|
||||
# Arguments:
|
||||
|
@ -198,7 +189,7 @@ testExtension () {
|
|||
# Return:
|
||||
# 0 (true): if test passes
|
||||
# 1 (false): if test fails
|
||||
testNewExtensionLine () {
|
||||
testNewExtensionLine() {
|
||||
testNewExtensionLine_rc=0
|
||||
if test $# -lt 2; then
|
||||
printf 'Missing PHP version list for the new extension %s\n' "${1:-}"
|
||||
|
@ -223,7 +214,6 @@ testNewExtensionLine () {
|
|||
return $testNewExtensionLine_rc
|
||||
}
|
||||
|
||||
|
||||
# Get the list of all supported PHP versions
|
||||
#
|
||||
# Arguments:
|
||||
|
@ -231,7 +221,7 @@ testNewExtensionLine () {
|
|||
#
|
||||
# Outputs:
|
||||
# the space-separated list of supported PHP versions
|
||||
getAllPHPVersionsForExtensions () {
|
||||
getAllPHPVersionsForExtensions() {
|
||||
getAllPHPVersionsForExtensions_result=''
|
||||
IFS=' '
|
||||
for getAllPHPVersionsForExtensions_extension in $1; do
|
||||
|
@ -261,7 +251,7 @@ getAllPHPVersionsForExtensions () {
|
|||
#
|
||||
# Outputs:
|
||||
# the space-separated list of supported PHP versions
|
||||
getAllPHPVersionsForExtension () {
|
||||
getAllPHPVersionsForExtension() {
|
||||
getAllPHPVersionsForExtension_result=''
|
||||
while IFS= read -r getAllPHPVersionsForExtension_line; do
|
||||
getAllPHPVersionsForExtension_ok=
|
||||
|
@ -285,11 +275,10 @@ getAllPHPVersionsForExtension () {
|
|||
fi
|
||||
fi
|
||||
done
|
||||
done < "$TRAVIS_BUILD_DIR/data/supported-extensions"
|
||||
done <"$TRAVIS_BUILD_DIR/data/supported-extensions"
|
||||
printf '%s' "$getAllPHPVersionsForExtension_result"
|
||||
}
|
||||
|
||||
|
||||
# Test extensions by reading a commit message
|
||||
#
|
||||
# Arguments:
|
||||
|
@ -301,27 +290,26 @@ getAllPHPVersionsForExtension () {
|
|||
# Return:
|
||||
# 0 (true): if test passes
|
||||
# 1 (false): if test fails
|
||||
testExtensionsFromMessage () {
|
||||
testExtensionsFromMessage() {
|
||||
testExtensionsFromMessage_result=0
|
||||
TEST_EXTENSIONS=
|
||||
FIRST_LINE=1
|
||||
testExtensionsFromMessage_message="$(git -C "$TRAVIS_BUILD_DIR" log --pretty='format:%B' -n 1 "$1")"
|
||||
IFS='
|
||||
'
|
||||
|
||||
for COMMIT_LINE in $testExtensionsFromMessage_message; do
|
||||
if test $FIRST_LINE -eq 1; then
|
||||
FIRST_LINE=0
|
||||
else
|
||||
TESTLIST=
|
||||
case "$COMMIT_LINE" in
|
||||
Test:* )
|
||||
Test:*)
|
||||
TESTLIST=${COMMIT_LINE#Test:}
|
||||
;;
|
||||
TEST:* )
|
||||
TEST:*)
|
||||
TESTLIST=${COMMIT_LINE#TEST:}
|
||||
;;
|
||||
test:* )
|
||||
test:*)
|
||||
TESTLIST=${COMMIT_LINE#test:}
|
||||
;;
|
||||
esac
|
||||
|
@ -331,7 +319,7 @@ testExtensionsFromMessage () {
|
|||
if test $COMMIT_LINE_EXT = '-STOP-'; then
|
||||
STOP_NEXT_COMMITS=1
|
||||
elif test -z "$TEST_EXTENSIONS"; then
|
||||
TEST_EXTENSIONS=$COMMIT_LINE_EXT;
|
||||
TEST_EXTENSIONS=$COMMIT_LINE_EXT
|
||||
else
|
||||
if ! stringInList "$COMMIT_LINE_EXT" "$TEST_EXTENSIONS"; then
|
||||
TEST_EXTENSIONS="$TEST_EXTENSIONS $COMMIT_LINE_EXT"
|
||||
|
@ -380,7 +368,6 @@ for DIFF_LINE in $(git -C "$TRAVIS_BUILD_DIR" diff --no-indent-heuristic --minim
|
|||
fi
|
||||
done
|
||||
|
||||
|
||||
IFS='
|
||||
'
|
||||
for COMMIT_HASH in $(git -C "$TRAVIS_BUILD_DIR" log --pretty='format:%H' "$TRAVIS_COMMIT_RANGE"); do
|
||||
|
|
|
@ -9,19 +9,15 @@ UPDATE_README_COMMIT_AUTHOR_EMAIL='michele@locati.it'
|
|||
UPDATE_README_COMMIT_MESSAGE='[skip ci] Automatically update README.md'
|
||||
WATCHED_FILES='data/special-requirements data/supported-extensions scripts/common scripts/update-readme scripts/travisci-update-readme'
|
||||
|
||||
SCRIPTS_DIR="$(CDPATH= cd -- "$(dirname -- "${0}")" && pwd)"
|
||||
. "${SCRIPTS_DIR}/common"
|
||||
|
||||
SCRIPTS_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
||||
. "$SCRIPTS_DIR/common"
|
||||
|
||||
echo 'Checking environment'
|
||||
if test -z "${TRAVIS_BUILD_DIR:-}" || test -z "${TRAVIS_BRANCH:-}" || test -z "${TRAVIS_EVENT_TYPE:-}" || test -z "${TRAVIS_REPO_SLUG:-}"
|
||||
then
|
||||
if test -z "${TRAVIS_BUILD_DIR:-}" || test -z "${TRAVIS_BRANCH:-}" || test -z "${TRAVIS_EVENT_TYPE:-}" || test -z "${TRAVIS_REPO_SLUG:-}"; then
|
||||
echo 'Not in a TravisCI environment' >&2
|
||||
exit 1
|
||||
fi
|
||||
if test -z "${GUTHUB_ACCESS_TOKEN:-}"
|
||||
then
|
||||
|
||||
if test -z "${GUTHUB_ACCESS_TOKEN:-}"; then
|
||||
echo 'GitHub access token not set' >&2
|
||||
# To create it:
|
||||
# - go to https://github.com/settings/tokens/new?scopes=repo
|
||||
|
@ -35,47 +31,43 @@ then
|
|||
# - secure: "encrypted string"
|
||||
exit 1
|
||||
fi
|
||||
if test "${TRAVIS_EVENT_TYPE}" != 'push'
|
||||
then
|
||||
if test "$TRAVIS_EVENT_TYPE" != 'push'; then
|
||||
echo 'This script should only be run in push builds' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf 'Checking-out branch %s\n' "${TRAVIS_BRANCH}"
|
||||
git checkout --force "${TRAVIS_BRANCH}"
|
||||
printf 'Checking-out branch %s\n' "$TRAVIS_BRANCH"
|
||||
git checkout --force "$TRAVIS_BRANCH"
|
||||
|
||||
LAST_AUTO_UPDATED_IN="$(git -C "${TRAVIS_BUILD_DIR}" rev-list --max-count 1 --author "<${UPDATE_README_COMMIT_AUTHOR_EMAIL}>" --grep "${UPDATE_README_COMMIT_MESSAGE}" "${TRAVIS_BRANCH}")"
|
||||
if test -z "${LAST_AUTO_UPDATED_IN}"
|
||||
then
|
||||
printf 'Rebuild of README.md enabled (no previous automatic refresh of it in branch %s)\n' "${TRAVIS_BRANCH}"
|
||||
LAST_AUTO_UPDATED_IN="$(git -C "$TRAVIS_BUILD_DIR" rev-list --max-count 1 --author "<$UPDATE_README_COMMIT_AUTHOR_EMAIL>" --grep "$UPDATE_README_COMMIT_MESSAGE" "$TRAVIS_BRANCH")"
|
||||
if test -z "$LAST_AUTO_UPDATED_IN"; then
|
||||
printf 'Rebuild of README.md enabled (no previous automatic refresh of it in branch %s)\n' "$TRAVIS_BRANCH"
|
||||
else
|
||||
MODIFIED_FILES_SINCE="$(git -C "${TRAVIS_BUILD_DIR}" diff --name-only "${LAST_AUTO_UPDATED_IN}...${TRAVIS_BRANCH}")"
|
||||
if test -z "$(commonElements "${WATCHED_FILES}" "${MODIFIED_FILES_SINCE}")"
|
||||
then
|
||||
printf 'Rebuild of README.md not needed (no relevant files changed in branch %s since commit %s)\n' "${TRAVIS_BRANCH}" "${LAST_AUTO_UPDATED_IN}"
|
||||
MODIFIED_FILES_SINCE="$(git -C "$TRAVIS_BUILD_DIR" diff --name-only "$LAST_AUTO_UPDATED_IN...$TRAVIS_BRANCH")"
|
||||
if test -z "$(commonElements "$WATCHED_FILES" "$MODIFIED_FILES_SINCE")"; then
|
||||
printf 'Rebuild of README.md not needed (no relevant files changed in branch %s since commit %s)\n' "$TRAVIS_BRANCH" "$LAST_AUTO_UPDATED_IN"
|
||||
exit 0
|
||||
fi
|
||||
printf 'Rebuild of README.md enabled (relevant files changed in branch %s since commit %s)\n' "${TRAVIS_BRANCH}" "${LAST_AUTO_UPDATED_IN}"
|
||||
printf 'Rebuild of README.md enabled (relevant files changed in branch %s since commit %s)\n' "$TRAVIS_BRANCH" "$LAST_AUTO_UPDATED_IN"
|
||||
fi
|
||||
|
||||
echo 'Updating README.md'
|
||||
"${TRAVIS_BUILD_DIR}/scripts/update-readme"
|
||||
if test -z "$(git -C "${TRAVIS_BUILD_DIR}" ls-files -m | grep -E '^README\.md$')"
|
||||
then
|
||||
"$TRAVIS_BUILD_DIR/scripts/update-readme"
|
||||
if test -z "$(git -C "$TRAVIS_BUILD_DIR" ls-files -m | grep -E '^README\.md$')"; then
|
||||
echo 'README.md has not been changed'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf 'Adding %s remote\n' "${TRAVIS_REPO_SLUG}"
|
||||
git remote add deploy "https://${GUTHUB_ACCESS_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git"
|
||||
printf 'Adding %s remote\n' "$TRAVIS_REPO_SLUG"
|
||||
git remote add deploy "https://$GUTHUB_ACCESS_TOKEN@github.com/$TRAVIS_REPO_SLUG.git"
|
||||
|
||||
echo 'Committing changes to README.md'
|
||||
git -C "${TRAVIS_BUILD_DIR}" config user.name "${UPDATE_README_COMMIT_AUTHOR_NAME}"
|
||||
git -C "${TRAVIS_BUILD_DIR}" config user.email "${UPDATE_README_COMMIT_AUTHOR_EMAIL}"
|
||||
git -C "${TRAVIS_BUILD_DIR}" add README.md
|
||||
git -C "${TRAVIS_BUILD_DIR}" commit -m "${UPDATE_README_COMMIT_MESSAGE}"
|
||||
git -C "$TRAVIS_BUILD_DIR" config user.name "$UPDATE_README_COMMIT_AUTHOR_NAME"
|
||||
git -C "$TRAVIS_BUILD_DIR" config user.email "$UPDATE_README_COMMIT_AUTHOR_EMAIL"
|
||||
git -C "$TRAVIS_BUILD_DIR" add README.md
|
||||
git -C "$TRAVIS_BUILD_DIR" commit -m "$UPDATE_README_COMMIT_MESSAGE"
|
||||
|
||||
printf 'Pushing to %s\n' "${TRAVIS_REPO_SLUG}"
|
||||
git push deploy "${TRAVIS_BRANCH}"
|
||||
printf 'Pushing to %s\n' "$TRAVIS_REPO_SLUG"
|
||||
git push deploy "$TRAVIS_BRANCH"
|
||||
|
||||
echo 'Done.'
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
set -o errexit
|
||||
set -o nounset
|
||||
|
||||
SCRIPTS_DIR="$(CDPATH= cd -- "$(dirname -- "${0}")" && pwd)"
|
||||
ROOT_DIR="$(dirname -- "${SCRIPTS_DIR}")"
|
||||
DATA_DIR="${ROOT_DIR}/data"
|
||||
|
||||
. "${SCRIPTS_DIR}/common"
|
||||
SCRIPTS_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
||||
ROOT_DIR="$(dirname -- "$SCRIPTS_DIR")"
|
||||
DATA_DIR="$ROOT_DIR/data"
|
||||
|
||||
. "$SCRIPTS_DIR/common"
|
||||
|
||||
# Get the list of PHP extensions from the data file
|
||||
#
|
||||
|
@ -17,26 +16,25 @@ DATA_DIR="${ROOT_DIR}/data"
|
|||
#
|
||||
# Output:
|
||||
# the list of PHP extensions
|
||||
getExtensionList () {
|
||||
getExtensionList() {
|
||||
getExtensionList_extensions=''
|
||||
IFS='
|
||||
'
|
||||
for getExtensionList_line in $(cat -- "${1}" | sort); do
|
||||
for getExtensionList_line in $(cat -- "$1" | sort); do
|
||||
getExtensionList_extension=''
|
||||
IFS=' '
|
||||
for getExtensionList_chunk in ${getExtensionList_line}; do
|
||||
if test -z "${getExtensionList_extensions}"; then
|
||||
getExtensionList_extensions="${getExtensionList_chunk}"
|
||||
for getExtensionList_chunk in $getExtensionList_line; do
|
||||
if test -z "$getExtensionList_extensions"; then
|
||||
getExtensionList_extensions="$getExtensionList_chunk"
|
||||
else
|
||||
getExtensionList_extensions="${getExtensionList_extensions} ${getExtensionList_chunk}"
|
||||
getExtensionList_extensions="$getExtensionList_extensions $getExtensionList_chunk"
|
||||
fi
|
||||
break
|
||||
done
|
||||
done
|
||||
printf '%s' "${getExtensionList_extensions}"
|
||||
printf '%s' "$getExtensionList_extensions"
|
||||
}
|
||||
|
||||
|
||||
# Get the list of PHP versions from the data file
|
||||
#
|
||||
# Arguments:
|
||||
|
@ -44,27 +42,26 @@ getExtensionList () {
|
|||
#
|
||||
# Output:
|
||||
# the list of PHP versions
|
||||
getVersionList () {
|
||||
getVersionList() {
|
||||
getVersionList_versions=''
|
||||
IFS='
|
||||
'
|
||||
for getVersionList_line in $(cat -- "${1}" | sort); do
|
||||
for getVersionList_line in $(cat -- "$1" | sort); do
|
||||
getVersionList_extension=''
|
||||
IFS=' '
|
||||
for getVersionList_chunk in ${getVersionList_line}; do
|
||||
if test -z "${getVersionList_extension}"; then
|
||||
getVersionList_extension="${getVersionList_chunk}"
|
||||
elif test -z "${getVersionList_versions}"; then
|
||||
getVersionList_versions="${getVersionList_chunk}"
|
||||
elif ! stringInList "${getVersionList_chunk}" "${getVersionList_versions}"; then
|
||||
getVersionList_versions="${getVersionList_versions} ${getVersionList_chunk}"
|
||||
for getVersionList_chunk in $getVersionList_line; do
|
||||
if test -z "$getVersionList_extension"; then
|
||||
getVersionList_extension="$getVersionList_chunk"
|
||||
elif test -z "$getVersionList_versions"; then
|
||||
getVersionList_versions="$getVersionList_chunk"
|
||||
elif ! stringInList "$getVersionList_chunk" "$getVersionList_versions"; then
|
||||
getVersionList_versions="$getVersionList_versions $getVersionList_chunk"
|
||||
fi
|
||||
done
|
||||
done
|
||||
sortVersionList "${getVersionList_versions}"
|
||||
sortVersionList "$getVersionList_versions"
|
||||
}
|
||||
|
||||
|
||||
# Sort the list of PHP versions
|
||||
#
|
||||
# Arguments:
|
||||
|
@ -72,21 +69,20 @@ getVersionList () {
|
|||
#
|
||||
# Output:
|
||||
# the sorted list of PHP versions
|
||||
sortVersionList () {
|
||||
sortVersionList() {
|
||||
sortVersionList_list=''
|
||||
IFS='
|
||||
'
|
||||
for sortVersionList_version in $(printf '%s' "${1}" | tr ' ' '\n' | sort -t '.' -k 1,1n -k 2,2n -k 3,3n); do
|
||||
if test -z "${sortVersionList_list}"; then
|
||||
sortVersionList_list="${sortVersionList_version}"
|
||||
for sortVersionList_version in $(printf '%s' "$1" | tr ' ' '\n' | sort -t '.' -k 1,1n -k 2,2n -k 3,3n); do
|
||||
if test -z "$sortVersionList_list"; then
|
||||
sortVersionList_list="$sortVersionList_version"
|
||||
else
|
||||
sortVersionList_list="${sortVersionList_list} ${sortVersionList_version}"
|
||||
sortVersionList_list="$sortVersionList_list $sortVersionList_version"
|
||||
fi
|
||||
done
|
||||
printf '%s' "${sortVersionList_list}"
|
||||
printf '%s' "$sortVersionList_list"
|
||||
}
|
||||
|
||||
|
||||
# Generate the markdown table with the supported PHP extensions
|
||||
#
|
||||
# Arguments:
|
||||
|
@ -94,41 +90,41 @@ sortVersionList () {
|
|||
#
|
||||
# Output:
|
||||
# the markdown table
|
||||
generateExtensionsTable () {
|
||||
generateExtensionsTable_data=$(cat "${1}")
|
||||
generateExtensionsTable_extensions="$(getExtensionList "${1}")"
|
||||
generateExtensionsTable_versions="$(getVersionList "${1}")"
|
||||
generateExtensionsTable() {
|
||||
generateExtensionsTable_data=$(cat "$1")
|
||||
generateExtensionsTable_extensions="$(getExtensionList "$1")"
|
||||
generateExtensionsTable_versions="$(getVersionList "$1")"
|
||||
generateExtensionsTable_count=0
|
||||
printf '| Extension |'
|
||||
IFS=' '
|
||||
for generateExtensionsTable_version in ${generateExtensionsTable_versions}; do
|
||||
printf ' PHP %s |' "${generateExtensionsTable_version}"
|
||||
for generateExtensionsTable_version in $generateExtensionsTable_versions; do
|
||||
printf ' PHP %s |' "$generateExtensionsTable_version"
|
||||
done
|
||||
printf '\n'
|
||||
printf '|:---:|'
|
||||
for generateExtensionsTable_version in ${generateExtensionsTable_versions}; do
|
||||
for generateExtensionsTable_version in $generateExtensionsTable_versions; do
|
||||
printf -- ':---:|'
|
||||
done
|
||||
printf '\n'
|
||||
IFS=' '
|
||||
for generateExtensionsTable_extension in ${generateExtensionsTable_extensions}; do
|
||||
for generateExtensionsTable_extension in $generateExtensionsTable_extensions; do
|
||||
generateExtensionsTable_count=$((generateExtensionsTable_count + 1))
|
||||
printf '| %s |' "${generateExtensionsTable_extension}"
|
||||
printf '| %s |' "$generateExtensionsTable_extension"
|
||||
IFS=' '
|
||||
for generateExtensionsTable_version in ${generateExtensionsTable_versions}; do
|
||||
for generateExtensionsTable_version in $generateExtensionsTable_versions; do
|
||||
printf ' '
|
||||
generateExtensionsTable_versionOk=''
|
||||
IFS='
|
||||
'
|
||||
for generateExtensionsTable_dataLine in ${generateExtensionsTable_data}; do
|
||||
if stringInList "${generateExtensionsTable_extension}" "${generateExtensionsTable_dataLine}"; then
|
||||
if stringInList "${generateExtensionsTable_version}" "${generateExtensionsTable_dataLine}"; then
|
||||
for generateExtensionsTable_dataLine in $generateExtensionsTable_data; do
|
||||
if stringInList "$generateExtensionsTable_extension" "$generateExtensionsTable_dataLine"; then
|
||||
if stringInList "$generateExtensionsTable_version" "$generateExtensionsTable_dataLine"; then
|
||||
generateExtensionsTable_versionOk='y'
|
||||
fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -n "${generateExtensionsTable_versionOk}"; then
|
||||
if test -n "$generateExtensionsTable_versionOk"; then
|
||||
printf 'V'
|
||||
fi
|
||||
printf ' |'
|
||||
|
@ -139,7 +135,6 @@ generateExtensionsTable () {
|
|||
printf '*Number of supported extensions: %s*\n' $generateExtensionsTable_count
|
||||
}
|
||||
|
||||
|
||||
# Generate the markdown table with the special requirements for the PHP extensions
|
||||
#
|
||||
# Arguments:
|
||||
|
@ -147,30 +142,29 @@ generateExtensionsTable () {
|
|||
#
|
||||
# Output:
|
||||
# the markdown table
|
||||
generateSpecialRequirementsTable () {
|
||||
generateSpecialRequirementsTable() {
|
||||
generateSpecialRequirementsTable_started=''
|
||||
IFS='
|
||||
'
|
||||
for generateSpecialRequirementsTable_line in $(cat -- "${1}" | sort); do
|
||||
if test -z "${generateSpecialRequirementsTable_started}"; then
|
||||
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
|
||||
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}"
|
||||
"$(echo "$generateSpecialRequirementsTable_line" | awk '{print $1;}')" \
|
||||
"$generateSpecialRequirementsTable_requirement"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Generate the contents of README.md
|
||||
#
|
||||
# Arguments:
|
||||
|
@ -180,20 +174,20 @@ generateSpecialRequirementsTable () {
|
|||
#
|
||||
# Output:
|
||||
# the markdown table
|
||||
generateReadme () {
|
||||
generateReadme() {
|
||||
generateReadme_ph_ExtensionsStart='<!-- START OF EXTENSIONS TABLE -->'
|
||||
generateReadme_ph_ExtensionsEnd='<!-- END OF EXTENSIONS TABLE -->'
|
||||
generateReadme_ph_SpecialStart='<!-- START OF SPECIAL REQUIREMENTS -->'
|
||||
generateReadme_ph_SpecialEnd='<!-- END OF SPECIAL REQUIREMENTS -->'
|
||||
generateReadme_skip=''
|
||||
while IFS= read -r generateReadme_line; do
|
||||
if test "${generateReadme_line}" = "${generateReadme_ph_ExtensionsEnd}" || test "${generateReadme_line}" = "${generateReadme_ph_SpecialEnd}"; then
|
||||
if test "$generateReadme_line" = "$generateReadme_ph_ExtensionsEnd" || test "$generateReadme_line" = "$generateReadme_ph_SpecialEnd"; then
|
||||
generateReadme_skip=''
|
||||
fi
|
||||
if test -z "${generateReadme_skip}"; then
|
||||
printf '%s\n' "${generateReadme_line}"
|
||||
if test -z "$generateReadme_skip"; then
|
||||
printf '%s\n' "$generateReadme_line"
|
||||
fi
|
||||
if test "${generateReadme_line}" = "${generateReadme_ph_ExtensionsStart}"; then
|
||||
if test "$generateReadme_line" = "$generateReadme_ph_ExtensionsStart"; then
|
||||
generateReadme_skip='y'
|
||||
printf '<!-- ########################################################### -->\n'
|
||||
printf '<!-- # # -->\n'
|
||||
|
@ -202,8 +196,8 @@ generateReadme () {
|
|||
printf '<!-- # EDIT THE data/supported-extensions FILE INSTEAD # -->\n'
|
||||
printf '<!-- # # -->\n'
|
||||
printf '<!-- ########################################################### -->\n'
|
||||
generateExtensionsTable "${2}"
|
||||
elif test "${generateReadme_line}" = "${generateReadme_ph_SpecialStart}"; then
|
||||
generateExtensionsTable "$2"
|
||||
elif test "$generateReadme_line" = "$generateReadme_ph_SpecialStart"; then
|
||||
generateReadme_skip='y'
|
||||
printf '<!-- ########################################################### -->\n'
|
||||
printf '<!-- # # -->\n'
|
||||
|
@ -212,11 +206,11 @@ generateReadme () {
|
|||
printf '<!-- # EDIT THE data/special-requirements FILE INSTEAD # -->\n'
|
||||
printf '<!-- # # -->\n'
|
||||
printf '<!-- ########################################################### -->\n'
|
||||
generateSpecialRequirementsTable "${3}"
|
||||
generateSpecialRequirementsTable "$3"
|
||||
fi
|
||||
done < "${1}"
|
||||
printf '%s' "${generateReadme_line}"
|
||||
done <"$1"
|
||||
printf '%s' "$generateReadme_line"
|
||||
}
|
||||
|
||||
NEW_README="$(generateReadme "${ROOT_DIR}/README.md" "${DATA_DIR}/supported-extensions" "${DATA_DIR}/special-requirements")"
|
||||
printf '%s\n' "${NEW_README}" > "${ROOT_DIR}/README.md"
|
||||
NEW_README="$(generateReadme "$ROOT_DIR/README.md" "$DATA_DIR/supported-extensions" "$DATA_DIR/special-requirements")"
|
||||
printf '%s\n' "$NEW_README" >"$ROOT_DIR/README.md"
|
||||
|
|
Loading…
Reference in New Issue