From 51b16e983bae596eb50b41e5cda880bc3c620e92 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 3 Aug 2022 18:41:24 +0200 Subject: [PATCH] Support installing custom languages for pspell (#621) --- README.md | 1 + install-php-extensions | 15 +++++++++++++-- scripts/ci-test-extensions | 2 +- scripts/tests/pspell | 31 +++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100755 scripts/tests/pspell diff --git a/README.md b/README.md index fa66cf0..f608fed 100644 --- a/README.md +++ b/README.md @@ -372,6 +372,7 @@ Here's the list of all the supported environment variables: | gd | `IPE_GD_WITHOUTAVIF=1` | Since PHP 8.1, gd supports the AVIF format. Enabling it requires compiling libaom/libdav1d/libyuv/libavif, which is time-consuming. You can disable AVIF support by setting this environment variable | | oci8 & pdo_oci | `IPE_INSTANTCLIENT_BASIC=1` | The oci8 and pdo_oci PHP extensions require [Oracle Instant Client](https://www.oracle.com/database/technologies/instant-client.html). In order to save disk space, we install the Basic Lite version: if you want to install the Basic (non-lite) version simply set this environment variable | | http, intl, mongodb | `IPE_ICU_EN_ONLY=1` | Some extensions require the ICU library, use this flag to install a smaller, but English-only, ICU library on Alpine 3.16 and later | +| pspell | `IPE_ASPELL_LANGUAGES='...'` | Configure the languages to be made available (for example: `IPE_ASPELL_LANGUAGES='en fr'`). If omitted, we'll assume `en` | ## Special requirements diff --git a/install-php-extensions b/install-php-extensions index dba795c..1cf7ae1 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -570,6 +570,17 @@ sortModulesToInstall() { fi } +# Expand the IPE_ASPELL_LANGUAGES environment variable into apk/apt package names +expandASpellDictionaries() { + expandASpellDictionaries_languages="${IPE_ASPELL_LANGUAGES:-en}" + expandASpellDictionaries_result='' + resetIFS + for expandASpellDictionaries_language in $expandASpellDictionaries_languages; do + expandASpellDictionaries_result="$expandASpellDictionaries_result aspell-$expandASpellDictionaries_language" + done + printf '%s' "${expandASpellDictionaries_result# }" +} + # Get the required APT/APK packages for a specific PHP version and for the list of module handles # # Arguments: @@ -1054,11 +1065,11 @@ buildRequiredPackageLists() { buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libstdc++" ;; pspell@alpine) - buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent aspell-libs" + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent aspell-libs $(expandASpellDictionaries)" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile aspell-dev" ;; pspell@debian) - buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libaspell15" + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libaspell15 $(expandASpellDictionaries)" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libpspell-dev" ;; rdkafka@alpine) diff --git a/scripts/ci-test-extensions b/scripts/ci-test-extensions index 448c401..4a3bb32 100755 --- a/scripts/ci-test-extensions +++ b/scripts/ci-test-extensions @@ -328,7 +328,7 @@ testExtensionFor() { printf ' - Docker image: %s\n' "$testExtensionFor_Image" testExtensionFor_out="$(mktemp)" testExtensionFor_start=$(date +%s) - if $(docker run --rm --volume "$CI_BUILD_DIR:/app" --env CI=true --env IPE_FIX_CACERTS=1 --workdir /app "$testExtensionFor_Image" sh -c "./install-php-extensions $1 && php ./scripts/check-installed-extension.php $1" >"$testExtensionFor_out" 2>&1); then + if $(docker run --rm --volume "$CI_BUILD_DIR:/app" --env CI=true --env IPE_FIX_CACERTS=1 --env IPE_ASPELL_LANGUAGES='en fr' --workdir /app "$testExtensionFor_Image" sh -c "./install-php-extensions $1 && php ./scripts/check-installed-extension.php $1" >"$testExtensionFor_out" 2>&1); then testExtensionFor_end=$(date +%s) testExtensionFor_delta=$(expr $testExtensionFor_end - $testExtensionFor_start) rm -rf "$testExtensionFor_out" diff --git a/scripts/tests/pspell b/scripts/tests/pspell new file mode 100755 index 0000000..5a50b46 --- /dev/null +++ b/scripts/tests/pspell @@ -0,0 +1,31 @@ +#!/usr/bin/env php +