From a41a08e66a01784574e97513681db3b4c2c3342a Mon Sep 17 00:00:00 2001 From: Matteo Scaramuccia Date: Thu, 25 Jan 2018 23:05:17 +0100 Subject: [PATCH] Install solr extension from source Using 2.4.0 release + custom patch (from macports project) seems to be the only working combination right now. Read the comments in the code and the links there. Resolves solr issue in #16, waiting for the upstream as described in #19 --- root/tmp/setup/php-extensions.sh | 15 +++++++-- root/tmp/setup/solr-extension.sh | 53 ++++++++++++++++++++++++++++++++ tests/fixtures/test.php | 2 +- 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100755 root/tmp/setup/solr-extension.sh diff --git a/root/tmp/setup/php-extensions.sh b/root/tmp/setup/php-extensions.sh index d04058e..263b94f 100755 --- a/root/tmp/setup/php-extensions.sh +++ b/root/tmp/setup/php-extensions.sh @@ -58,8 +58,6 @@ docker-php-ext-install -j$(nproc) gd docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ docker-php-ext-install -j$(nproc) ldap -# Note solr is missing. Ref: https://github.com/moodlehq/moodle-php-apache/issues/19 - # Memcached, MongoDB, Redis, APCu, igbinary. pecl install memcached mongodb redis apcu igbinary docker-php-ext-enable memcached redis apcu igbinary @@ -70,6 +68,19 @@ docker-php-ext-install zip echo 'apc.enable_cli = On' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini +# Install custom solr extension. Last release (2.4.0) is not working at all +# with php72 and php73 and upstream has not either! Solution: +# - current master (as of 21th May 2019): +# https://github.com/php/pecl-search_engine-solr/commit/98a8bf540bcb4e9b2e1378cce2f3a9bf6cd772b8 +# - this patch, applied already upstream: +# https://github.com/php/pecl-search_engine-solr/commit/744e32915d5989101267ed2c84a407c582dc6f31 +# So, following the experience with Macports, and https://bugs.php.net/bug.php?id=75631 +# we are going to try 2.4.0 release + macports patch. Old, but working right now. +# References: +# - https://github.com/moodlehq/moodle-php-apache/issues/16 (part of the php72 image discussion) +# - https://github.com/moodlehq/moodle-php-apache/issues/19 (awaiting for a better solution) +/tmp/setup/solr-extension.sh + # Install Microsoft dependencies for sqlsrv. # (kept apart for clarity, still need to be run here # before some build packages are deleted) diff --git a/root/tmp/setup/solr-extension.sh b/root/tmp/setup/solr-extension.sh new file mode 100755 index 0000000..e4f857d --- /dev/null +++ b/root/tmp/setup/solr-extension.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +set -e + +# Install 2.4.0 release version + macports patch. Only combination working right now. +# See #16 and #19 for more information. +hash=6e9e097c981e810d452657f23bf1945b7955f3cf +patch=https://raw.githubusercontent.com/macports/macports-ports/master/php/php-solr/files/php72.patch + +# Download our 'tagged' source code from git. +echo "Downloading solr extension source archive (${hash})" +curl --location \ + https://github.com/php/pecl-search_engine-solr/archive/${hash}.tar.gz \ + -o /tmp/pecl-search_engine-solr-${hash}.tar.gz + +# Download patch +if [ -n $patch ]; then + curl --location \ + $patch \ + -o /tmp/solr.patch +fi + +# Extract the compressed archive. +cd /tmp +tar -xvzf pecl-search_engine-solr-${hash}.tar.gz +cd pecl-search_engine-solr-${hash} + +# Apply the patch +if [ -n $patch ]; then + patch -p0 < ../solr.patch +fi + +# Compile the extension as required by a manual PECL installation. +echo "Compile solr extension" +phpize +./configure +make + +# Finally, install it. +echo "Install solr extension" +make install + +# Remove all the sources. +echo "Cleanup temporary folder and files" +rm /tmp/pecl-search_engine-solr-${hash} -rf +rm /tmp/pecl-search_engine-solr-${hash}.tar.gz -f +rm /tmp/solr.patch -f + +# Enable it. +docker-php-ext-enable solr + +# Done with this hack. +# Please, follow https://github.com/moodlehq/moodle-php-apache/issues/19. diff --git a/tests/fixtures/test.php b/tests/fixtures/test.php index b836dcf..dbff555 100644 --- a/tests/fixtures/test.php +++ b/tests/fixtures/test.php @@ -11,7 +11,7 @@ 'oci8', 'pgsql', 'redis', -// 'solr', Ref: https://github.com/moodlehq/moodle-php-apache/issues/19 + 'solr', 'soap', 'sqlsrv', 'xsl',