Revert "Bug 7167 follow-up setting DBrevision, before pushing"
[srvgit] / installer / install.pl
index ae478b6..01360e6 100755 (executable)
@@ -59,7 +59,7 @@ if ( $step && $step == 1 ) {
     $template->param( language => 1 );
     $template->param( 'checkmodule' => 1 ); # we start with the assumption that there are no problems and set this to 0 if there are
 
-    unless ( $] >= 5.008008 ) {    # Bug 4505
+    unless ( $] >= 5.010000 ) {    # Bug 7375
         $template->param( problems => 1, perlversion => 1, checkmodule => 0 );
     }
 
@@ -185,7 +185,7 @@ elsif ( $step && $step == 3 ) {
         # we have finished, just redirect to mainpage.
         #
         print $query->redirect("/cgi-bin/koha/mainpage.pl");
-        exit 1;
+        exit;
     }
     elsif ( $op && $op eq 'finish' ) {
         $installer->set_version_syspref();
@@ -312,25 +312,29 @@ elsif ( $step && $step == 3 ) {
         # Not 1st install, the only sub-step : update database
         #
         #Do updatedatabase And report
-        my $cmd = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl";
-        my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = IPC::Cmd::run(command => $cmd, verbose => 0);
-
-        if (@$stdout_buf) {
-            $template->param(update_report => [ map { { line => $_ } } split(/\n/, join('', @$stdout_buf)) ] );
-            $template->param(has_update_succeeds => 1);
-        }
-        if (@$stderr_buf) {
-            $template->param(update_errors => [ map { { line => $_ } } split(/\n/, join('', @$stderr_buf)) ] );
-            $template->param(has_update_errors => 1);
-            warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n";
-            foreach my $line (@$stderr_buf) {warn "$line\n";}
+        if ( ! defined $ENV{PERL5LIB} ) {
+            my $find = "C4/Context.pm";
+            my $path = $INC{$find};
+            $path =~ s/\Q$find\E//;
+            $ENV{PERL5LIB} = "$path:$path/installer";
+            warn "# plack? inserted PERL5LIB $ENV{PERL5LIB}\n";
         }
 
+        my $koha39 = "3.0900028";
+        my $cmd;
+        # Old updatedatabase method
+        my $current_version = C4::Context->preference('Version');
+        if ( $current_version < $koha39 ) {
+            $cmd = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl";
+            my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = IPC::Cmd::run(command => $cmd, verbose => 0);
+            print_std( "updatedatabase.pl", $stdout_buf, $stderr_buf );
+            $current_version= $koha39;
+        }
         $template->param( $op => 1 );
     }
     else {
         #
-        # check wether it's a 1st install or an update
+        # check whether it's a 1st install or an update
         #
         #Check if there are enough tables.
         # Paul has cleaned up tables so reduced the count
@@ -397,4 +401,20 @@ else {
         }
     }
 }
+
+sub print_std {
+    my ( $script, $stdout_buf, $stderr_buf ) = @_;
+    if (@$stdout_buf) {
+        $template->param(update_report => [ map { { line => $_ } } split(/\n/, join('', @$stdout_buf)) ] );
+        $template->param(has_update_succeeds => 1);
+    }
+    if (@$stderr_buf) {
+        $template->param(update_errors => [ map { { line => $_ } } split(/\n/, join('', @$stderr_buf)) ] );
+        $template->param(has_update_errors => 1);
+        warn "The following errors were returned while attempting to run the $script script:\n";
+        foreach my $line (@$stderr_buf) {warn "$line\n";}
+    }
+}
+
+
 output_html_with_http_headers $query, $cookie, $template->output;