setup-php/src/scripts/ext/intl.sh

24 lines
956 B
Bash
Raw Normal View History

2020-09-02 21:48:37 +07:00
# Function to install ICU
install_icu() {
icu=$1
if [ "$(php -i | grep "ICU version =>" | sed -e "s|.*=> s*||")" != "$icu" ]; then
2020-11-11 03:53:45 +07:00
get -q -n /tmp/icu.tar.zst "https://dl.bintray.com/shivammathur/icu4c/icu4c-$icu.tar.zst"
2020-09-02 21:48:37 +07:00
sudo tar -I zstd -xf /tmp/icu.tar.zst -C /usr/local
sudo cp -r /usr/local/icu/lib/* /usr/lib/x86_64-linux-gnu/
fi
}
# Function to add ext-intl with the given version of ICU
add_intl() {
icu=$(echo "$1" | cut -d'-' -f 2)
2020-11-11 03:53:45 +07:00
supported_version=$(get -s -n "" https://api.bintray.com/packages/shivammathur/icu4c/icu4c | grep -Po "$icu" | head -n 1)
2020-09-02 21:48:37 +07:00
if [ "$icu" != "$supported_version" ]; then
add_log "${cross:?}" "intl" "ICU $icu is not supported"
else
install_icu "$icu" >/dev/null 2>&1
2020-11-11 03:53:45 +07:00
get -q -n "${ext_dir:?}/intl.so" "https://dl.bintray.com/shivammathur/icu4c/php${version:?}-intl-$icu.so"
2020-09-02 21:48:37 +07:00
enable_extension intl extension
add_extension_log intl "Installed and enabled with ICU $icu"
fi
}