Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix installing enchant on PHP < 8 and Alpine 3.12+/Debian 11+ #1002

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions install-php-extensions
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,11 @@ buildRequiredPackageLists() {
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile enchant2-dev"
else
# The system provides libenchant2, supported since PHP 8.0: we need to build libenchant1 on our own
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent glib aspell-libs libhunspell"
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile glib-dev aspell-dev hunspell-dev"
if ! isLibenchant1Installed; then
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent glib aspell-libs libhunspell"
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile glib-dev aspell-dev hunspell-dev"
COMPILE_LIBS="$COMPILE_LIBS libenchant1"
fi
fi
else
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent enchant"
Expand All @@ -801,9 +804,12 @@ buildRequiredPackageLists() {
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libenchant-2-2"
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libenchant-2-dev"
else
# The system provides libenchant2, supported since PHP 8.0: we need to build libenchant1 on our own
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent aspell-en libhunspell-1.7-0"
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libglib2.0-dev libaspell-dev libhunspell-dev"
if ! isLibenchant1Installed; then
# The system provides libenchant2, supported since PHP 8.0: we need to build libenchant1 on our own
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent aspell-en libhunspell-1.7-0"
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libglib2.0-dev libaspell-dev libhunspell-dev"
COMPILE_LIBS="$COMPILE_LIBS libenchant1"
fi
fi
else
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libenchant1c2a"
Expand Down Expand Up @@ -2442,6 +2448,23 @@ installLibXCrypt() {
cd - >/dev/null
}

isLibenchant1Installed() {
if test -f /usr/lib/libenchant.so || test -f /usr/local/lib/libenchant.so; then
return 0
fi
return 1
}

installLibenchant1() {
printf 'Installing libenchant1\n'
installLibenchant1_src="$(getPackageSource https://github.com/rrthomas/enchant/releases/download/enchant-1-6-1/enchant-1.6.1.tar.gz)"
cd -- "$installLibenchant1_src"
./configure
make -j$(getProcessorCount)
make install
cd - >/dev/null
}

# Install Composer
installComposer() {
installComposer_version="$(getWantedPHPModuleVersion @composer)"
Expand Down Expand Up @@ -2640,6 +2663,9 @@ compileLibs() {
if stringInList libxcrypt "$COMPILE_LIBS"; then
installLibXCrypt
fi
if stringInList libenchant1 "$COMPILE_LIBS"; then
installLibenchant1
fi
}

# Install a bundled PHP module given its handle
Expand Down Expand Up @@ -2681,32 +2707,6 @@ EOF
fi
docker-php-ext-configure dba --with-db4
;;
enchant)
installBundledModule_tmp=0
if test $PHP_MAJMIN_VERSION -lt 800; then
case "$DISTRO" in
alpine)
if test $DISTRO_MAJMIN_VERSION -ge 312; then
installBundledModule_tmp=1
fi
;;
debian)
if test $DISTRO_VERSION_NUMBER -ge 11; then
installBundledModule_tmp=1
fi
;;
esac
fi
if test $installBundledModule_tmp -eq 1 && ! test -f /usr/lib/libenchant.so && ! test -f /usr/local/lib/libenchant.so; then
# We need to install libenchant1 from source
installBundledModule_src="$(getPackageSource https://github.com/AbiWord/enchant/releases/download/enchant-1-6-1/enchant-1.6.1.tar.gz)"
cd -- "$installBundledModule_src"
./configure
make -j$(getProcessorCount)
make install
cd - >/dev/null
fi
;;
ftp)
if test $PHP_MAJMIN_VERSION -ge 804; then
docker-php-ext-configure ftp --with-ftp-ssl=/usr
Expand Down