Changeset 1505


Ignore:
Timestamp:
May 9, 2012, 2:20:04 AM (7 years ago)
Author:
bruno
Message:
  • Base.pm: use Carp and Cwd so we can give better error messages. Use new Global::pb_stop_on_error variable to decide whether we should abort on an error. (Eric Anderson from 9c3c696597c49b385df409311b1385d7a394db5a)
  • Distribution.pm: Remove useless redundant check of deps not maching whitespace, improve message since it is likely to call sudo. Skip dependencies that are all whitespace since that leads to errors when running dpkg -L <whitespace> (Eric Anderson from 9c3c696597c49b385df409311b1385d7a394db5a)
Location:
devel/pb-modules/lib/ProjectBuilder
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Base.pm

    r1504 r1505  
    1414use strict;
    1515use lib qw (lib);
     16use Carp 'cluck';
     17use Cwd;
    1618use File::Path;
    1719use File::Temp qw(tempdir);
     
    159161    return($res)
    160162    }
    161 if ($res == -1) {
    162     pb_log(0,"failed to execute ($cmd): $!\n") if ((! defined $verbose) || ($verbose ne "quiet"));
    163     pb_display_file("$ENV{'PBTMP'}/system.$$.log") if ((-f "$ENV{'PBTMP'}/system.$$.log") and ((! defined $verbose) || ($verbose ne "quiet")));
    164 } elsif ($res & 127) {
    165     pb_log(0, "child ($cmd) died with signal ".($? & 127).", ".($? & 128) ? 'with' : 'without'." coredump\n") if ((! defined $verbose) || ($verbose ne "quiet"));
    166     pb_display_file("$ENV{'PBTMP'}/system.$$.log") if ((-f "$ENV{'PBTMP'}/system.$$.log") and ((! defined $verbose) || ($verbose ne "quiet")));
    167 } elsif ($res == 0) {
     163
     164my $cwd = getcwd;
     165my $error = undef;
     166$error = "failed to execute ($cmd) in $cwd: $!\n" if ($res == -1);
     167$error = "child ($cmd) died with signal ".($res & 127).", ".($res & 128) ? 'with' : 'without'." coredump\n" if ($res & 127);
     168$error = "child ($cmd) cwd=$cwd exited with value ".($res >> 8)."\n" if ($res != 0);
     169
     170if (defined $error) {
     171    pb_log(0, $error) if ((! defined $verbose) || ($verbose ne "quiet")) || $Global::pb_stop_on_error;
     172    pb_display_file("$ENV{'PBTMP'}/system.$$.log") if ((-f "$ENV{'PBTMP'}/system.$$.log") and ((! defined $verbose) || ($verbose ne "quiet") || $Global::pb_stop_on_error));
     173    if ($Global::pb_stop_on_error) {
     174        cluck "error running command ($cmd) with cwd=$cwd";
     175        exit(1);
     176    }
     177} else {
    168178    pb_log(0,"OK\n") if ((! defined $verbose) || ($verbose ne "quiet"));
    169     pb_display_file("$ENV{'PBTMP'}/system.$$.log") if ((defined $verbose) and (-f "$ENV{'PBTMP'}/system.$$.log") and ($verbose ne "quiet"));
    170 } else {
    171     pb_log(0, "child ($cmd) exited with value ".($? >> 8)."\n") if ((! defined $verbose) || ($verbose ne "quiet"));
    172     pb_display_file("$ENV{'PBTMP'}/system.$$.log") if ((-f "$ENV{'PBTMP'}/system.$$.log") and ((! defined $verbose) || ($verbose ne "quiet")));
    173 }
     179    pb_display_file("$ENV{'PBTMP'}/system.$$.log") if ((-f "$ENV{'PBTMP'}/system.$$.log") and (defined $verbose) and ($verbose ne "quiet"));
     180}
     181
    174182return($res);
    175183}
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r1402 r1505  
    305305
    306306# Get dependencies in the build file if not forced
    307 $deps = pb_distro_getdeps($f, $pbos) if (not defined $deps);
     307$deps = pb_distro_getdeps($f,$pbos) if (not defined $deps);
    308308pb_log(2,"deps: $deps\n");
    309309return if ((not defined $deps) || ($deps =~ /^\s*$/));
    310 if ($deps !~ /^[    ]*$/) {
    311     # This may not be // proof. We should test for availability of repo and sleep if not
    312     pb_system("$pbos->{'install'} $deps","Installing dependencies ($deps)");
    313     }
     310
     311# This may not be // proof. We should test for availability of repo and sleep if not
     312my $cmd = "$pbos->{'install'} $deps";
     313pb_system($cmd,"Installing dependencies ($cmd)");
    314314}
    315315
     
    394394my $deps2 = "";
    395395# Avoid to install what is already there
    396 foreach my $p (split(/ /,$deps)) {
     396foreach my $p (split(/\s+/,$deps)) {
     397    next if $p =~ /^\s*$/o;
    397398    if ($pbos->{'type'} eq  "rpm") {
    398399        my $res = pb_system("rpm -q --whatprovides --quiet $p","","quiet");
Note: See TracChangeset for help on using the changeset viewer.