2018-04-11 15:39:10 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
|
2019-12-20 15:52:00 +00:00
|
|
|
SCRIPTS_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
|
|
|
ROOT_DIR="$(dirname -- "$SCRIPTS_DIR")"
|
|
|
|
DATA_DIR="$ROOT_DIR/data"
|
2018-04-11 15:39:10 +00:00
|
|
|
|
2019-12-20 15:52:00 +00:00
|
|
|
. "$SCRIPTS_DIR/common"
|
2018-04-11 15:39:10 +00:00
|
|
|
|
|
|
|
# Get the list of PHP extensions from the data file
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# $1: the path to the data file
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# the list of PHP extensions
|
2019-12-20 15:52:00 +00:00
|
|
|
getExtensionList() {
|
2018-04-11 15:39:10 +00:00
|
|
|
getExtensionList_extensions=''
|
|
|
|
IFS='
|
|
|
|
'
|
2019-12-20 15:52:00 +00:00
|
|
|
for getExtensionList_line in $(cat -- "$1" | sort); do
|
2018-04-11 15:39:10 +00:00
|
|
|
getExtensionList_extension=''
|
|
|
|
IFS=' '
|
2019-12-20 15:52:00 +00:00
|
|
|
for getExtensionList_chunk in $getExtensionList_line; do
|
|
|
|
if test -z "$getExtensionList_extensions"; then
|
|
|
|
getExtensionList_extensions="$getExtensionList_chunk"
|
2018-04-11 15:39:10 +00:00
|
|
|
else
|
2019-12-20 15:52:00 +00:00
|
|
|
getExtensionList_extensions="$getExtensionList_extensions $getExtensionList_chunk"
|
2018-04-11 15:39:10 +00:00
|
|
|
fi
|
|
|
|
break
|
|
|
|
done
|
|
|
|
done
|
2019-12-20 15:52:00 +00:00
|
|
|
printf '%s' "$getExtensionList_extensions"
|
2018-04-11 15:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Get the list of PHP versions from the data file
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# $1: the path to the data file
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# the list of PHP versions
|
2019-12-20 15:52:00 +00:00
|
|
|
getVersionList() {
|
2018-04-11 15:39:10 +00:00
|
|
|
getVersionList_versions=''
|
|
|
|
IFS='
|
|
|
|
'
|
2019-12-20 15:52:00 +00:00
|
|
|
for getVersionList_line in $(cat -- "$1" | sort); do
|
2018-04-11 15:39:10 +00:00
|
|
|
getVersionList_extension=''
|
|
|
|
IFS=' '
|
2019-12-20 15:52:00 +00:00
|
|
|
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"
|
2018-04-11 15:39:10 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2019-12-20 15:52:00 +00:00
|
|
|
sortVersionList "$getVersionList_versions"
|
2018-04-11 15:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Sort the list of PHP versions
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# $1: the list of PHP versions
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# the sorted list of PHP versions
|
2019-12-20 15:52:00 +00:00
|
|
|
sortVersionList() {
|
2018-04-11 15:39:10 +00:00
|
|
|
sortVersionList_list=''
|
|
|
|
IFS='
|
|
|
|
'
|
2019-12-20 15:52:00 +00:00
|
|
|
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"
|
2018-04-11 15:39:10 +00:00
|
|
|
else
|
2019-12-20 15:52:00 +00:00
|
|
|
sortVersionList_list="$sortVersionList_list $sortVersionList_version"
|
2018-04-11 15:39:10 +00:00
|
|
|
fi
|
|
|
|
done
|
2019-12-20 15:52:00 +00:00
|
|
|
printf '%s' "$sortVersionList_list"
|
2018-04-11 15:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Generate the markdown table with the supported PHP extensions
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# $1: the path to the data file
|
2020-03-03 13:25:20 +00:00
|
|
|
# $2: the path to the special requirements data file
|
2018-04-11 15:39:10 +00:00
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# the markdown table
|
2019-12-20 15:52:00 +00:00
|
|
|
generateExtensionsTable() {
|
|
|
|
generateExtensionsTable_data=$(cat "$1")
|
|
|
|
generateExtensionsTable_extensions="$(getExtensionList "$1")"
|
|
|
|
generateExtensionsTable_versions="$(getVersionList "$1")"
|
2019-12-17 09:25:57 +00:00
|
|
|
generateExtensionsTable_count=0
|
2020-03-03 13:25:20 +00:00
|
|
|
if test -f "$2"; then
|
|
|
|
generateExtensionsTable_specialReqExt=$(cat "$2" | cut -d' ' -f1)
|
|
|
|
else
|
|
|
|
generateExtensionsTable_specialReqExt=''
|
|
|
|
fi
|
2018-04-11 15:39:10 +00:00
|
|
|
printf '| Extension |'
|
|
|
|
IFS=' '
|
2019-12-20 15:52:00 +00:00
|
|
|
for generateExtensionsTable_version in $generateExtensionsTable_versions; do
|
|
|
|
printf ' PHP %s |' "$generateExtensionsTable_version"
|
2018-04-11 15:39:10 +00:00
|
|
|
done
|
|
|
|
printf '\n'
|
|
|
|
printf '|:---:|'
|
2019-12-20 15:52:00 +00:00
|
|
|
for generateExtensionsTable_version in $generateExtensionsTable_versions; do
|
2018-04-11 15:39:10 +00:00
|
|
|
printf -- ':---:|'
|
|
|
|
done
|
|
|
|
printf '\n'
|
|
|
|
IFS=' '
|
2019-12-20 15:52:00 +00:00
|
|
|
for generateExtensionsTable_extension in $generateExtensionsTable_extensions; do
|
2019-12-17 09:25:57 +00:00
|
|
|
generateExtensionsTable_count=$((generateExtensionsTable_count + 1))
|
2020-03-03 13:25:20 +00:00
|
|
|
printf '| %s' "$generateExtensionsTable_extension"
|
|
|
|
if stringInList "$generateExtensionsTable_extension" "$generateExtensionsTable_specialReqExt"; then
|
|
|
|
printf '[*](#special-requirements-for-%s)' "$generateExtensionsTable_extension"
|
|
|
|
fi
|
|
|
|
printf ' |'
|
2018-04-11 15:39:10 +00:00
|
|
|
IFS=' '
|
2019-12-20 15:52:00 +00:00
|
|
|
for generateExtensionsTable_version in $generateExtensionsTable_versions; do
|
2018-04-11 15:39:10 +00:00
|
|
|
printf ' '
|
|
|
|
generateExtensionsTable_versionOk=''
|
|
|
|
IFS='
|
|
|
|
'
|
2019-12-20 15:52:00 +00:00
|
|
|
for generateExtensionsTable_dataLine in $generateExtensionsTable_data; do
|
|
|
|
if stringInList "$generateExtensionsTable_extension" "$generateExtensionsTable_dataLine"; then
|
|
|
|
if stringInList "$generateExtensionsTable_version" "$generateExtensionsTable_dataLine"; then
|
2018-04-11 15:39:10 +00:00
|
|
|
generateExtensionsTable_versionOk='y'
|
|
|
|
fi
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2019-12-20 15:52:00 +00:00
|
|
|
if test -n "$generateExtensionsTable_versionOk"; then
|
2020-02-21 13:39:01 +00:00
|
|
|
printf '✓'
|
2018-04-11 15:39:10 +00:00
|
|
|
fi
|
|
|
|
printf ' |'
|
|
|
|
done
|
|
|
|
printf '\n'
|
|
|
|
done
|
2019-12-17 09:25:57 +00:00
|
|
|
printf '\n'
|
|
|
|
printf '*Number of supported extensions: %s*\n' $generateExtensionsTable_count
|
2018-04-11 15:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Generate the markdown table with the special requirements for the PHP extensions
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# $1: the path to the data file
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# the markdown table
|
2019-12-20 15:52:00 +00:00
|
|
|
generateSpecialRequirementsTable() {
|
2020-03-03 11:07:51 +00:00
|
|
|
generateSpecialRequirementsTable_started=0
|
2018-04-11 15:39:10 +00:00
|
|
|
IFS='
|
|
|
|
'
|
2019-12-20 15:52:00 +00:00
|
|
|
for generateSpecialRequirementsTable_line in $(cat -- "$1" | sort); do
|
2018-04-11 15:39:10 +00:00
|
|
|
resetIFS
|
2020-03-03 11:07:51 +00:00
|
|
|
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 -- '• %s<br />• ' "$generateSpecialRequirementsTable_requirements")"
|
|
|
|
else
|
|
|
|
generateSpecialRequirementsTable_requirements="$(printf '%s<br />• ' "$generateSpecialRequirementsTable_requirements")"
|
|
|
|
fi
|
|
|
|
case "$generateSpecialRequirementsTable_chunk" in
|
|
|
|
zts)
|
|
|
|
generateSpecialRequirementsTable_chunk='Requires images with PHP compiled with thread-safety enabled (`zts`).'
|
|
|
|
;;
|
2022-05-16 14:31:22 +00:00
|
|
|
!arm)
|
|
|
|
generateSpecialRequirementsTable_chunk='Not available in ARM architectures.'
|
|
|
|
;;
|
2020-03-03 11:07:51 +00:00
|
|
|
!*)
|
|
|
|
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
|
2020-03-03 13:25:20 +00:00
|
|
|
printf '| <a name="special-requirements-for-%s"></a>%s | %s |\n' "$generateSpecialRequirementsTable_extension" "$generateSpecialRequirementsTable_extension" "$generateSpecialRequirementsTable_requirements"
|
2020-03-03 11:07:51 +00:00
|
|
|
fi
|
2018-04-11 15:39:10 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generate the contents of README.md
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# $1: the path to the README file
|
|
|
|
# $2: the path to the extensions data file
|
|
|
|
# $3: the path to the special requirements data file
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# the markdown table
|
2019-12-20 15:52:00 +00:00
|
|
|
generateReadme() {
|
2018-04-11 15:39:10 +00:00
|
|
|
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=''
|
2019-12-17 09:20:11 +00:00
|
|
|
while IFS= read -r generateReadme_line; do
|
2019-12-20 15:52:00 +00:00
|
|
|
if test "$generateReadme_line" = "$generateReadme_ph_ExtensionsEnd" || test "$generateReadme_line" = "$generateReadme_ph_SpecialEnd"; then
|
2018-04-11 15:39:10 +00:00
|
|
|
generateReadme_skip=''
|
|
|
|
fi
|
2019-12-20 15:52:00 +00:00
|
|
|
if test -z "$generateReadme_skip"; then
|
|
|
|
printf '%s\n' "$generateReadme_line"
|
2018-04-11 15:39:10 +00:00
|
|
|
fi
|
2019-12-20 15:52:00 +00:00
|
|
|
if test "$generateReadme_line" = "$generateReadme_ph_ExtensionsStart"; then
|
2018-04-11 15:39:10 +00:00
|
|
|
generateReadme_skip='y'
|
|
|
|
printf '<!-- ########################################################### -->\n'
|
|
|
|
printf '<!-- # # -->\n'
|
|
|
|
printf '<!-- # DO NOT EDIT THIS TABLE: IT IS GENERATED AUTOMATICALLY # -->\n'
|
|
|
|
printf '<!-- # # -->\n'
|
|
|
|
printf '<!-- # EDIT THE data/supported-extensions FILE INSTEAD # -->\n'
|
|
|
|
printf '<!-- # # -->\n'
|
|
|
|
printf '<!-- ########################################################### -->\n'
|
2020-03-03 13:25:20 +00:00
|
|
|
generateExtensionsTable "$2" "$3"
|
2019-12-20 15:52:00 +00:00
|
|
|
elif test "$generateReadme_line" = "$generateReadme_ph_SpecialStart"; then
|
2018-04-11 15:39:10 +00:00
|
|
|
generateReadme_skip='y'
|
|
|
|
printf '<!-- ########################################################### -->\n'
|
|
|
|
printf '<!-- # # -->\n'
|
|
|
|
printf '<!-- # DO NOT EDIT THIS TABLE: IT IS GENERATED AUTOMATICALLY # -->\n'
|
|
|
|
printf '<!-- # # -->\n'
|
|
|
|
printf '<!-- # EDIT THE data/special-requirements FILE INSTEAD # -->\n'
|
|
|
|
printf '<!-- # # -->\n'
|
|
|
|
printf '<!-- ########################################################### -->\n'
|
2019-12-20 15:52:00 +00:00
|
|
|
generateSpecialRequirementsTable "$3"
|
2018-04-11 15:39:10 +00:00
|
|
|
fi
|
2019-12-20 15:52:00 +00:00
|
|
|
done <"$1"
|
|
|
|
printf '%s' "$generateReadme_line"
|
2018-04-11 15:39:10 +00:00
|
|
|
}
|
|
|
|
|
2019-12-20 15:52:00 +00:00
|
|
|
NEW_README="$(generateReadme "$ROOT_DIR/README.md" "$DATA_DIR/supported-extensions" "$DATA_DIR/special-requirements")"
|
|
|
|
printf '%s\n' "$NEW_README" >"$ROOT_DIR/README.md"
|