Update Catalog Stats report: / Remove lccn/loc filter, which seems to conflate marc21...
[koha.git] / Makefile.PL
index 7f04cb7..29dc039 100644 (file)
@@ -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
@@ -552,6 +553,7 @@ WriteMakefile(
 'Getopt::Long' => 2.35,
 'Getopt::Std' => 1.05,
 'HTML::Template::Pro' => 0.69,
+'HTML::Scrubber' => 0.08,
 'HTTP::Cookies' => 1.39,
 'HTTP::Request::Common' => 1.26,
 'Image::Magick' => 6.2,
@@ -947,6 +949,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
@@ -1078,7 +1095,11 @@ doing it in a database that you don't want to lose.
 Please specify the name of the test database to be
 used by Koha);
       
-    $config{'TEST_DB_NAME'} = _get_value('TEST_DB_NAME', $msg, $defaults->{'TEST_DB_NAME'}, $valid_values, $install_log_values);
+      $config{'TEST_DB_NAME'} = _get_value('TEST_DB_NAME', $msg, $defaults->{'TEST_DB_NAME'}, $valid_values, $install_log_values);
+      while ( $config{'TEST_DB_NAME'} eq $config{'DB_NAME'} ) {
+          $msg = q(Please do not use the same database for testing as you do for production. You run the severe risk of data loss.);
+          $config{'TEST_DB_NAME'} = _get_value('TEST_DB_NAME', $msg, $defaults->{'TEST_DB_NAME'}, $valid_values, $install_log_values);
+      }
 
       $msg = q(
 Please specify the user that owns the database to be
@@ -1327,6 +1348,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...