View | Details | Raw Unified | Return to bug 15562
Collapse All | Expand All

(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 362-367 our $PERL_DEPS = { Link Here
362
        'required' => '1',
362
        'required' => '1',
363
        'min_ver'  => '0.46'
363
        'min_ver'  => '0.46'
364
    },
364
    },
365
    'Capture::Tiny' => {
366
        'usage'    => 'Core',
367
        'required' => '1',
368
        'min_ver'  => '0.08'
369
    },
365
    'HTTP::Cookies' => {
370
    'HTTP::Cookies' => {
366
        'usage'    => 'Core',
371
        'usage'    => 'Core',
367
        'required' => '1',
372
        'required' => '1',
(-)a/installer/install.pl (-27 / +28 lines)
Lines 24-29 use diagnostics; Link Here
24
use C4::InstallAuth;
24
use C4::InstallAuth;
25
use CGI qw ( -utf8 );
25
use CGI qw ( -utf8 );
26
use POSIX qw(strftime);
26
use POSIX qw(strftime);
27
use Capture::Tiny qw(capture);
27
28
28
use C4::Context;
29
use C4::Context;
29
use C4::Output;
30
use C4::Output;
Lines 388-427 elsif ( $step && $step == 3 ) { Link Here
388
            chk_log( $logdir, "updatedatabase-error_$filename_suffix" )
389
            chk_log( $logdir, "updatedatabase-error_$filename_suffix" )
389
        );
390
        );
390
391
391
        my $cmd = C4::Context->config("intranetdir")
392
        my $script = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl";
392
          . "/installer/data/$info{dbms}/updatedatabase.pl >> $logfilepath 2>> $logfilepath_errors";
393
        my ($stdout, $stderr, $exit) = capture { do( $script ) };
394
        warn "Cannot execute $script: ".($@ || $!) if $@ || $!;
393
395
394
        system($cmd );
396
        if ($stdout) {
395
397
            if ( open( my $fh, ">>", $logfilepath ) ) {
396
        my $fh;
398
                print $fh $stdout;
397
        open( $fh, "<", $logfilepath )
399
                close $fh;
398
          or die "Cannot open log file $logfilepath: $!";
400
            }
399
        my @report = <$fh>;
401
            else {
400
        close $fh;
402
                warn "Cannot open log file $logfilepath: $!";
401
        if (@report) {
403
            }
402
            $template->param( update_report =>
404
            $template->param( update_report => [ map { line => $_ }, split( /\n/, $stdout ) ] );
403
                  [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ]
404
            );
405
            $template->param( has_update_succeeds => 1 );
405
            $template->param( has_update_succeeds => 1 );
406
        }
406
        }
407
        else {
407
        else {
408
            eval { `rm $logfilepath` };
408
#           eval { `rm $logfilepath` };
409
        }
409
        }
410
        open( $fh, "<", $logfilepath_errors )
410
411
          or die "Cannot open log file $logfilepath_errors: $!";
411
        if ($stderr) {
412
        @report = <$fh>;
412
            if ( open( my $fh, ">>", $logfilepath_errors ) ) {
413
        close $fh;
413
                print $fh $stderr;
414
        if (@report) {
414
                close $fh;
415
            $template->param( update_errors =>
415
            }
416
                  [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ]
416
            else {
417
            );
417
                warn "Cannot open log file $logfilepath_errors: $!";
418
            }
419
            my @errors = split( /\n/, $stderr );
420
            $template->param( update_errors => [ map { line => $_ }, @errors ] );
418
            $template->param( has_update_errors => 1 );
421
            $template->param( has_update_errors => 1 );
419
            warn
422
            warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n";
420
"The following errors were returned while attempting to run the updatedatabase.pl script:\n";
423
            warn $_ foreach @errors;
421
            foreach my $line (@report) { warn "$line\n"; }
422
        }
424
        }
423
        else {
425
        else {
424
            eval { `rm $logfilepath_errors` };
426
#           eval { `rm $logfilepath_errors` };
425
        }
427
        }
426
        $template->param( $op => 1 );
428
        $template->param( $op => 1 );
427
    }
429
    }
428
- 

Return to bug 15562