[Koha-patches] [PATCH] kohabug 1776 - try to locate Zebra during install
Galen Charlton
galen.charlton at liblime.com
Tue Apr 22 17:22:24 CEST 2008
If running Zebra, try to locate zebrasrv and zebraidx
so that koha-zebra-ctl.sh can point to a functioning
zebrasrv.
---
Makefile.PL | 42 ++++++++++++++++++++++++++++++++++++++++++
misc/bin/koha-zebra-ctl.sh | 2 +-
misc/koha-install-log | 1 +
rewrite-config.PL | 1 +
4 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 7f04cb7..bae8dbc 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -411,6 +411,7 @@ my %config_defaults = (
'PAZPAR2_HOST' => 'localhost',
'PAZPAR2_PORT' => '11002',
'RUN_DATABASE_TESTS' => 'no',
+ 'PATH_TO_ZEBRA' => '',
);
# set some default configuratio options based on OS
@@ -947,6 +948,21 @@ Install the Zebra configuration files?);
$config{'INSTALL_ZEBRA'} = _get_value('INSTALL_ZEBRA', $msg, $defaults->{'INSTALL_ZEBRA'}, $valid_values, $install_log_values);
if ($config{'INSTALL_ZEBRA'} eq 'yes') {
+
+ if (defined(my $zebra_path = find_zebra())) {
+ $config{'PATH_TO_ZEBRA'} = $zebra_path;
+ print qq(
+Found 'zebrasrv' and 'zebraidx' in $zebra_path.
+);
+ } else {
+ print q(
+Unable to find the Zebra programs 'zebrasrv' and 'zebraidx'
+in your PATH or in some of the usual places. If you haven't
+installed Zebra yet, please do so and run Makefile.PL again.
+
+);
+ }
+
$msg = q(
Since you've chosen to use Zebra with Koha,
you must specify the primary MARC format of the
@@ -1327,6 +1343,32 @@ sub display_configuration {
print "'dmake -x MAXLINELENGTH=300000'\n\n";
}
+=head2 find_zebra
+
+Attempt to find Zebra - check user's PATH and
+a few other directories for zebrasrv and zebraidx.
+
+FIXME: doesn't handle Win32
+
+=cut
+
+sub find_zebra {
+ my @search_dirs = map {
+ my $abs = File::Spec->rel2abs($_);
+ my ($toss, $directories);
+ ($toss, $directories, $toss) = File::Spec->splitpath($abs, 1);
+ $directories;
+ } split /:/, $ENV{PATH};
+ push @search_dirs, qw(/usr/local/bin /opt/local/bin /usr/bin);
+ my @zebrasrv_dirs = grep { -x File::Spec->catpath('', $_, 'zebrasrv') } @search_dirs;
+ return unless @zebrasrv_dirs;
+ # verify that directory that contains zebrasrv also contains zebraidx
+ foreach my $dir (@zebrasrv_dirs) {
+ return $dir if -x File::Spec->catpath('', $dir, 'zebraidx');
+ }
+ return;
+}
+
package MY;
# This will have to be reworked in order to accommodate Win32...
diff --git a/misc/bin/koha-zebra-ctl.sh b/misc/bin/koha-zebra-ctl.sh
index 823084d..5b248d1 100755
--- a/misc/bin/koha-zebra-ctl.sh
+++ b/misc/bin/koha-zebra-ctl.sh
@@ -11,7 +11,7 @@ KOHA_CONF=__KOHA_CONF_DIR__/koha-conf.xml
RUNDIR=__ZEBRA_RUN_DIR__
LOCKDIR=__ZEBRA_LOCK_DIR__
# you may need to change this depending on where zebrasrv is installed
-ZEBRASRV=/usr/bin/zebrasrv
+ZEBRASRV=__PATH_TO_ZEBRA__/zebrasrv
test -f $ZEBRASRV || exit 0
diff --git a/misc/koha-install-log b/misc/koha-install-log
index 579e14c..1da5f33 100644
--- a/misc/koha-install-log
+++ b/misc/koha-install-log
@@ -56,3 +56,4 @@ INSTALL_SRU=__INSTALL_SRU__
INSTALL_PAZPAR2=__INSTALL_PAZPAR2__
AUTH_INDEX_MODE=__AUTH_INDEX_MODE__
RUN_DATABASE_TESTS=__RUN_DATABASE_TESTS__
+PATH_TO_ZEBRA=__PATH_TO_ZEBRA__
diff --git a/rewrite-config.PL b/rewrite-config.PL
index ec19ade..69b070a 100644
--- a/rewrite-config.PL
+++ b/rewrite-config.PL
@@ -126,6 +126,7 @@ $prefix = $ENV{'INSTALL_BASE'} || "/usr";
"__PAZPAR2_TOGGLE_XML_POST__" => '-->',
"__AUTH_INDEX_MODE__" => 'grs1',
"__RUN_DATABASE_TESTS__" => 'no',
+ "__PATH_TO_ZEBRA__" => "",
);
# Override configuration from the environment
--
1.5.5.rc0.16.g02b00
More information about the Koha-patches
mailing list