Ukranian and Russian sql updates courtesy of Сергій Дубик
[koha.git] / Makefile.PL
index 9ed08fe..63bc820 100644 (file)
@@ -197,7 +197,14 @@ things the translation toolkit and RSS feed tools.
 
 =item SCRIPT_DIR
 
-Directory for command-line scripts and daemons.
+Directory for command-line scripts and daemons to
+be set up all for installation modes.
+
+=item SCRIPT_NONDEV_DIR
+
+Directory for command-line scripts that should
+be installed in the same directory as the
+SCRIPT_DIR target except 'dev' installs.
 
 =item MAN_DIR
 
@@ -243,6 +250,7 @@ my $target_map = {
   './changelanguage.pl'         => 'INTRANET_CGI_DIR',
   './check_sysprefs.pl'         => 'NONE',
   './circ'                      => 'INTRANET_CGI_DIR',
+  './offline_circ'             => 'INTRANET_CGI_DIR',
   './edithelp.pl'               => 'INTRANET_CGI_DIR',
   './etc'                       => { target => 'KOHA_CONF_DIR', trimdir => -1 },
   './etc/zebradb'               => { target => 'ZEBRA_CONF_DIR', trimdir => -1 },
@@ -259,7 +267,7 @@ my $target_map = {
   './Makefile.PL'               => 'NONE',
   './MANIFEST.SKIP'             => 'NONE',
   './members'                   => 'INTRANET_CGI_DIR',
-  './misc'                      => { target => 'SCRIPT_DIR', trimdir => -1 }, 
+  './misc'                      => { target => 'SCRIPT_NONDEV_DIR', trimdir => -1 }, 
   './misc/bin'                  => { target => 'SCRIPT_DIR', trimdir => -1 }, 
   './misc/release_notes'        => { target => 'DOC_DIR', trimdir => 2 },
   './misc/translator'           => { target => 'MISC_DIR', trimdir => 2 }, 
@@ -272,7 +280,6 @@ my $target_map = {
   './reviews'                   => 'INTRANET_CGI_DIR',
   './rewrite-config.PL'         => 'NONE',
   './reviews'                   => 'INTRANET_CGI_DIR',
-  './rss'                       => 'MISC_DIR', 
   './serials'                   => 'INTRANET_CGI_DIR',
   './skel'                      => 'NONE',
   './skel/var/log/koha'         => { target => 'LOG_DIR', trimdir => -1 },
@@ -291,6 +298,7 @@ my $target_map = {
   './suggestion'                => 'INTRANET_CGI_DIR',
   './svc'                       => 'INTRANET_CGI_DIR',
   './t'                         => 'NONE',
+  './tags'                      => 'INTRANET_CGI_DIR',
   './tmp'                       => 'NONE', # FIXME need to determine whether 
                                            # Koha generates any persistent temp files
                                            # that should go in /var/tmp/koha
@@ -403,9 +411,11 @@ my %config_defaults = (
   'MERGE_SERVER_PORT' => '11001',
   'PAZPAR2_HOST' => 'localhost',
   'PAZPAR2_PORT' => '11002',
+  'RUN_DATABASE_TESTS' => 'no',
+  'PATH_TO_ZEBRA' => '',
 );
 
-# set some default configuratio options based on OS
+# set some default configuration options based on OS
 # more conditions need to be added for other OS's
 # this should probably also incorporate usage of Win32::GetOSName() and/or Win32::GetOSVersion()
 # to allow for more granular decisions based on which Win32 platform
@@ -438,6 +448,7 @@ my %valid_config_values = (
   'AUTH_INDEX_MODE' => { 'grs1' => 1, 'dom' => 1 },
   'ZEBRA_MARC_FORMAT' => { 'marc21' => 1, 'unimarc' => 1 }, # FIXME should generate from contents of distributation
   'ZEBRA_LANGUAGE'    => { 'en' => 1, 'fr' => 1 }, # FIXME should generate from contents of distribution
+  'RUN_DATABASE_TESTS' => { 'yes' => 1, 'no' => 1 },
 );
 
 # get settings from command-line
@@ -480,13 +491,11 @@ if ($config{'INSTALL_ZEBRA'} eq "yes") {
         'blib/ZEBRA_CONF_DIR/retrieval-info-auth-grs1.xml',
         'blib/ZEBRA_CONF_DIR/retrieval-info-auth-dom.xml',
     );
-    if ($config{'INSTALL_MODE'} ne 'dev') {
-        push @{ $pl_files->{'rewrite-config.PL'} }, (
-            'blib/SCRIPT_DIR/koha-zebra-ctl.sh',
-            'blib/SCRIPT_DIR/koha-pazpar2-ctl.sh',
-            'blib/SCRIPT_DIR/koha-zebraqueue-ctl.sh',
-        );
-    }
+    push @{ $pl_files->{'rewrite-config.PL'} }, (
+        'blib/SCRIPT_DIR/koha-zebra-ctl.sh',
+        'blib/SCRIPT_DIR/koha-pazpar2-ctl.sh',
+        'blib/SCRIPT_DIR/koha-zebraqueue-ctl.sh',
+    );
     if ($config{'INSTALL_PAZPAR2'} eq 'yes') {
         push @{ $pl_files->{'rewrite-config.PL'} }, (
             'blib/PAZPAR2_CONF_DIR/koha-biblios.xml',
@@ -501,96 +510,115 @@ if ($config{'INSTALL_ZEBRA'} eq "yes") {
 if ($config{'INSTALL_MODE'} ne "dev") {
     push @{ $pl_files->{'rewrite-config.PL'} }, (
         'blib/PERL_MODULE_DIR/C4/Context.pm',
-        'blib/SCRIPT_DIR/kohalib.pl'
+        'blib/SCRIPT_NONDEV_DIR/kohalib.pl'
     );
 }
 
+my %test_suite_override_dirs = (
+    KOHA_CONF_DIR  => ['etc'],
+    ZEBRA_CONF_DIR => ['etc', 'zebradb'],
+    LOG_DIR        => ['var', 'log'],
+    SCRIPT_DIR     => ['bin'],
+    ZEBRA_LOCK_DIR => ['var', 'lock', 'zebradb'],
+    ZEBRA_DATA_DIR => ['var', 'lib', 'zebradb'],
+    ZEBRA_RUN_DIR  => ['var', 'run', 'zebradb'],
+);
 WriteMakefile(
-    NAME => 'koha',
-    #VERSION => strftime('2.9.%Y%m%d%H',gmtime),
-    VERSION_FROM => 'kohaversion.pl',
-    ABSTRACT => 'Award-winning integrated library system (ILS) and Web OPAC',
-    AUTHOR => 'Koha Developers <koha-devel@nongnu.org>',
-    NO_META => 1,
-    PREREQ_PM => {
-# awaiting package maintainer's use of $VERSION
-#'Algorithm::CheckDigits' => 0.48,
-#'Algorithm::CheckDigits::M43_001' => 0.48,
-'Biblio::EndnoteStyle' => 0.05,
-'CGI' => 3.15,
-'CGI::Carp' => 1.29,
-'CGI::Session' => '4.10',
-'Class::Factory::Util' => 1.6,
-'Class::Accessor' => 0.30,
-'DBD::mysql' => 4.004,
-'DBI' => 1.53,
-'Data::ICal' => 0.13,
-'Data::Dumper' => 2.121,
-'Date::Calc' => 5.4,
-'Date::ICal' => 1.72,
-'Date::Manip' => 5.44,
-'Digest::MD5' => 2.36,
-'File::Temp' => 0.16,
-'GD::Barcode::UPCE' => 1.1,
-'Getopt::Long' => 2.35,
-'Getopt::Std' => 1.05,
-'HTML::Template::Pro' => 0.69,
-'HTTP::Cookies' => 1.39,
-'HTTP::Request::Common' => 1.26,
-'Image::Magick' => 6.2,
-'LWP::Simple' => 1.41,
-'LWP::UserAgent' => 2.033,
-'Lingua::Stem' => 0.82,
-'List::Util' => 1.18,
-'List::MoreUtils' => 0.21,
-'Locale::Language' => 2.07,
-'MARC::Charset' => 0.98,
-'MARC::Crosswalk::DublinCore' => 0.02,
-'MARC::File::XML' => 0.88,
-'MARC::Record' => 2.00,
-'MIME::Base64' => 3.07,
-'MIME::QuotedPrint' => 3.07,
-'Mail::Sendmail' => 0.79,
-'Net::LDAP' => 0.33,
-'Net::LDAP::Filter' => 0.14,
-'Net::Z3950::ZOOM' => 1.16,
-'PDF::API2' => 2.000,
-'PDF::API2::Page' => 2.000,
-'PDF::API2::Util' => 2.000,
-'PDF::Reuse' => 0.33,
-'PDF::Reuse::Barcode' => 0.05,
-'POE' => 0.9999,
-'POSIX' => 1.09,
-'Schedule::At' => 1.06,
-'Term::ANSIColor' => 1.10,
-'Test' => 1.25,
-'Test::Harness' => 2.56,
-'Test::More' => 0.62,
-'Text::CSV' => 0.01,
-'Text::CSV_XS' => 0.32,
-'Text::Iconv' => 1.7,
-'Text::Wrap' => 2005.082401,
-'Time::HiRes' => 1.86,
-'Time::localtime' => 1.02,
-'Unicode::Normalize' => 0.32,
-'XML::Dumper' => 0.81,
-'XML::LibXML' => 1.59,
-'XML::LibXSLT' => 1.59,
-'XML::SAX::ParserFactory' => 1.01,
-'XML::Simple' => 2.14,
-'XML::RSS' => 1.31,
-'YAML::Syck' => 0.71,
-        },
-
-       # File tree mapping
-       PM => $file_map,
-
-    # Man pages generated from POD
-    INSTALLMAN1DIR => File::Spec->catdir($target_directories->{'MAN_DIR'}, 'man1'),
-    INSTALLMAN3DIR => File::Spec->catdir($target_directories->{'MAN_DIR'}, 'man3'),
-
-    PL_FILES => $pl_files,
-
+              NAME         => 'koha',
+              VERSION     => '3.00.03',
+              #VERSION_FROM => 'kohaversion.pl',
+              ABSTRACT     => 'Award-winning integrated library system (ILS) and Web OPAC',
+              AUTHOR       => 'Koha Developers <koha-devel@lists.koha.org>',
+              NO_META      => 1,
+              PREREQ_PM => {
+                            'Algorithm::CheckDigits'           => 0.50,
+                            'Biblio::EndnoteStyle'             => 0.05,
+                            'CGI'                              => 3.15,
+                            'CGI::Carp'                        => 1.29,
+                            'CGI::Session'                     => 4.20,
+                            'CGI::Session::Serialize::yaml'    => 4.20,
+                            'Class::Factory::Util'             => 1.6,
+                            'Class::Accessor'                  => 0.30,
+                            'DBD::mysql'                       => 4.004,
+                            'DBI'                              => 1.53,
+                            'Data::Dumper'                     => 2.121,
+                            'Data::ICal'                       => 0.13,
+                            'Date::Calc'                       => 5.4,
+                            'Date::ICal'                       => 1.72,
+                            'Date::Manip'                      => 5.44,
+                            'Digest::MD5'                      => 2.36,
+                            'Digest::SHA'                      => 5.43,
+                            'Email::Date'                      => 1.103,
+                            'File::Temp'                       => 0.16,
+                            'GD'                               => 2.39,    #optional
+                            'GD::Barcode::UPCE'                => 1.1,
+                            'Getopt::Long'                     => 2.35,
+                            'Getopt::Std'                      => 1.05,
+                            'HTML::Template::Pro'              => 0.69,
+                            'HTML::Scrubber'                   => 0.08,
+                            'HTTP::Cookies'                    => 1.39,
+                            'HTTP::OAI'                        => 3.20,
+                            'HTTP::Request::Common'            => 1.26,
+                            'IPC::Cmd'                         => 0.46,
+                            'JSON'                             => 2.07, # Needed by admin/item_circulation_alerts.pl
+                            'LWP::Simple'                      => 1.41,
+                            'LWP::UserAgent'                   => 2.033,
+                            'Lingua::Stem'                     => 0.82,
+                            'List::Util'                       => 1.18,
+                            'List::MoreUtils'                  => 0.21,
+                            'Locale::Language'                 => 2.07,
+                            'MARC::Charset'                    => 0.98,
+                            'MARC::Crosswalk::DublinCore'      => 0.02,
+                            'MARC::File::XML'                  => 0.88,
+                            'MARC::Record'                     => 2.00,
+                            'MIME::Base64'                     => 3.07,
+                            'MIME::Lite'                       => 3.00,
+                            'MIME::QuotedPrint'                => 3.07,
+                            'Mail::Sendmail'                   => 0.79,
+                            'Net::LDAP'                        => 0.33, # optional
+                            'Net::LDAP::Filter'                => 0.14, # optional
+                            'Net::Z3950::ZOOM'                 => 1.16,
+                            'PDF::API2'                        => 2.000,
+                            'PDF::API2::Page'                  => 2.000,
+                            'PDF::API2::Util'                  => 2.000,
+                            'PDF::Reuse'                       => 0.33,
+                            'PDF::Reuse::Barcode'              => 0.05,
+                            'POE'                              => 0.9999,
+                            'POSIX'                            => 1.09,
+                            'Schedule::At'                     => 1.06,
+                            'SMS::Send'                        => 0.05, # optional
+                            'Term::ANSIColor'                  => 1.10,
+                            'Test'                             => 1.25,
+                            'Test::Harness'                    => 2.56,
+                            'Test::More'                       => 0.62,
+                            'Text::CSV'                        => 0.01,
+                            'Text::CSV_XS'                     => 0.32,
+                            'Text::Iconv'                      => 1.7,
+                            'Text::Wrap'                       => 2005.082401,
+                            'Time::HiRes'                      => 1.86,
+                            'Time::localtime'                  => 1.02,
+                            'Unicode::Normalize'               => 0.32,
+                            'URI::Escape'                      => 1.36,
+                            'XML::Dumper'                      => 0.81,
+                            'XML::LibXML'                      => 1.59,
+                            'XML::LibXSLT'                     => 1.59,
+                            'XML::SAX::ParserFactory'          => 1.01,
+                            'XML::SAX::Writer'                 => 0.44,
+                            'XML::Simple'                      => 2.14,
+                            'XML::RSS'                         => 1.31,
+                            'YAML::Syck'                       => 0.71,
+                        },
+
+              # File tree mapping
+              PM => $file_map,
+
+              # Man pages generated from POD
+             # ExtUtils::MakeMaker already manage $(DESTDIR)
+              INSTALLMAN1DIR => File::Spec->catdir(_strip_destdir($target_directories->{'MAN_DIR'}), 'man1'),
+              INSTALLMAN3DIR => File::Spec->catdir(_strip_destdir($target_directories->{'MAN_DIR'}), 'man3'),
+
+              PL_FILES => $pl_files,
 );
 
 =head1 FUNCTIONS
@@ -930,6 +958,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
@@ -1040,6 +1083,44 @@ PazPar2 port?);
         }
     }
 
+  $msg = q(
+Would you like to run the database-dependent test suite?);
+  $msg .= _add_valid_values_disp( 'RUN_DATABASE_TESTS', $valid_values );
+    $config{'RUN_DATABASE_TESTS'} = _get_value( 'RUN_DATABASE_TESTS', $msg, $defaults->{'RUN_DATABASE_TESTS'}, $valid_values, $install_log_values );
+
+  if ( $config{'RUN_DATABASE_TESTS'} eq 'yes' ) {
+      $config{'TEST_DB_TYPE'} = $config{'DB_TYPE'};
+      $config{'TEST_DB_HOST'} = $config{'DB_HOST'};
+      $msg = q(TEST DATABASE
+
+THE DATA IN THIS DATABASE WILL BE DESTROYED during the process of
+testing. Please don't do this on your production database. It is not
+reversable.
+
+YOU WILL SUFFER DATA LOSS if you run this test suite on your test
+database. You are better off not running this optional test suite than
+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);
+      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
+used by Koha);
+    $config{'TEST_DB_USER'} = _get_value('TEST_DB_USER', $msg, $defaults->{'TEST_DB_USER'}, $valid_values, $install_log_values);
+      
+      $msg = q(
+Please specify the password of the user that owns the 
+database to be used by Koha);
+      $config{'TEST_DB_PASS'} = _get_value('TEST_DB_PASS', $msg, $defaults->{'TEST_DB_PASS'}, $valid_values, $install_log_values);
+  }
+
     print "\n\n";
 
     # add version number
@@ -1140,6 +1221,7 @@ sub get_target_directories {
         $dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'pazpar2');
         $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc');
         $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
+        $dirmap{'SCRIPT_NONDEV_DIR'} = $dirmap{'SCRIPT_DIR'};
         $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
         $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
         $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
@@ -1167,7 +1249,8 @@ sub get_target_directories {
         $dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'pazpar2');
         $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc');
         $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
-        $skipdirs{'SCRIPT_DIR'} = 1;
+        $dirmap{'SCRIPT_NONDEV_DIR'} = $dirmap{'SCRIPT_DIR'};
+        $skipdirs{'SCRIPT_NONDEV_DIR'} = 1;
         $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
         $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
         $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
@@ -1188,6 +1271,7 @@ sub get_target_directories {
         $dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package, 'pazpar2');
         $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc');
         $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
+        $dirmap{'SCRIPT_NONDEV_DIR'} = $dirmap{'SCRIPT_DIR'};
         $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
         $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
         $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lock', $package, 'zebradb');
@@ -1198,10 +1282,30 @@ sub get_target_directories {
 
     _get_env_overrides(\%dirmap);
     _get_argv_overrides(\%dirmap);
+    _add_destdir(\%dirmap);
 
     return \%dirmap, \%skipdirs;
 }
 
+=head2 get_test_dir 
+
+Map a directory target to the corresponding path for
+the test suite.
+
+=cut
+
+sub get_test_dir {
+    my ($dirname) = @_;
+  
+    my @basedir = (File::Spec->rel2abs(File::Spec->curdir()), 't', 'run'); 
+    if (exists $test_suite_override_dirs{$dirname}) {
+        return File::Spec->catdir(@basedir, @{ $test_suite_override_dirs{$dirname} });
+    } else {
+        return;
+    }
+    
+}
+
 sub _get_env_overrides {
     my $dirmap = shift;
 
@@ -1227,6 +1331,20 @@ sub _get_argv_overrides {
     @ARGV = @new_argv;
 }
 
+sub _strip_destdir {
+    my $dir = shift;
+    $dir =~ s/^\$\(DESTDIR\)//;
+    return $dir;
+}
+
+sub _add_destdir {
+    my $dirmap = shift;
+
+    foreach my $key (keys %$dirmap) {
+        $dirmap->{$key} = '$(DESTDIR)'.$dirmap->{$key};
+    }
+}
+
 sub display_configuration {
     my $config = shift;
     my $dirmap = shift;
@@ -1254,6 +1372,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...
@@ -1276,7 +1420,7 @@ sub install {
     # installation and uninstallation targets.
 
 # If installation is on Win32, we need to do permissions different from *nix
-    if ( $^O =~ /darwin|linux|cygwin|freebsd/ ) { # this value needs to be verified for each platform and modified accordingly
+    if ( $^O =~ /darwin|linux|cygwin|freebsd|solaris/ ) { # this value needs to be verified for each platform and modified accordingly
            foreach my $key (sort keys %$target_directories) {
                    $install .= qq(
 KOHA_INST_$key = blib/$key
@@ -1298,9 +1442,10 @@ install :: all install_koha set_koha_ownership set_koha_permissions warn_koha_en
 
                        $install .= "\n";
                        $install .= "set_koha_ownership ::\n";
+# Do not try to change ownership if DESTDIR is set
                        if ($config{'INSTALL_MODE'} eq 'standard' and $config{'KOHA_USER'} ne "root") {
                                foreach my $key (sort keys %$target_directories) {
-                                       $install .= "\t\$(NOECHO) chown -R $config{'KOHA_USER'}:$config{'KOHA_GROUP'} \$(KOHA_DEST_$key)\n"
+                                       $install .= "\t\$(NOECHO) if test -z \"\$(DESTDIR)\"; then chown -R $config{'KOHA_USER'}:$config{'KOHA_GROUP'} \$(KOHA_DEST_$key); fi\n"
                                                unless ($config{'INSTALL_ZEBRA'} ne "yes" and $key =~ /ZEBRA/) or exists $skip_directories->{$key};
                                }
                        } else {
@@ -1426,20 +1571,44 @@ sub postamble {
         $config{'ZEBRA_PASS'} =~ s/\$/\$\$/g;
     }
 
+    my $env;
        # Hereagain, we must alter syntax per platform...
        if ( $^O eq 'MSWin32' ) {
                # NOTE: it is imperative that there be no whitespaces in ENV=value...
-               my $env = join("\n", map { "__${_}__=$target_directories->{$_}" } keys %$target_directories); 
+               $env = join("\n", map { "__${_}__=$target_directories->{$_}" } keys %$target_directories); 
                $env .= "\n\n";
                $env .= join("\n", map { "__${_}__=$config{$_}" } keys %config);
-               return "$env\n";
        }
     else {
-               my $env = join("\n", map { "export __${_}__ := $target_directories->{$_}" } keys %$target_directories); 
+               $env = join("\n", map { "export __${_}__ := $target_directories->{$_}" } keys %$target_directories); 
                $env .= "\n\n";
                $env .= join("\n", map { "export __${_}__ := $config{$_}" } keys %config);
-               return "$env\n";
        }
+    
+    if ( $config{'RUN_DATABASE_TESTS'} eq 'yes' ) {
+        if ( open( my $confhandle, '>', 't/test-config.txt' ) ) {
+            print $confhandle "# This configuration file lets the t/Makefile prepare a test koha-conf.xml file.\n";
+            print $confhandle "# It is generated by the top-level Makefile.PL.\n";
+            print $confhandle "# It is separate from the standard koha-conf.xml so that you can edit this by hand and test with different configurations.\n";
+
+            # these directories will be relocated to the 't' directory
+            foreach my $dirname ( keys %$target_directories ) {
+                my $dir = main::_strip_destdir( $target_directories->{$dirname} );
+                if ( exists $test_suite_override_dirs{$dirname} ) {
+                    $dir = main::get_test_dir($dirname);
+                }
+                print $confhandle "$dirname = $dir\n"
+            }
+            print $confhandle "\n";
+
+            print $confhandle join( "\n", map { "$_ = $config{$_}" } keys( %config ) ), "\n";
+            close( $confhandle );
+        } else {
+            warn 'unable to open conf file for database dependent tests: $!';
+        }
+          
+    }
+    return "$env\n";
 }