Changeset 1137 in ProjectBuilder


Ignore:
Timestamp:
Jan 7, 2011, 12:37:04 AM (13 years ago)
Author:
Bruno Cornec
Message:
  • build2pkg is now using Parallel::ForkManager to generate packages in parallel
  • pb_system fixed to support parallel calls
Location:
devel
Files:
3 edited

Legend:

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

    r1128 r1137  
    146146pb_log(0,"$cmt... ") if ((! defined $verbose) || ($verbose ne "quiet"));
    147147pb_log(1,"Executing $cmd\n");
    148 unlink("$ENV{'PBTMP'}/system.log") if (-f "$ENV{'PBTMP'}/system.log");
    149 $redir = "2>> $ENV{'PBTMP'}/system.log 1>> $ENV{'PBTMP'}/system.log" if ((! defined $verbose) || ($verbose ne "noredir"));
     148unlink("$ENV{'PBTMP'}/system.$$.log") if (-f "$ENV{'PBTMP'}/system.$$.log");
     149$redir = "2>> $ENV{'PBTMP'}/system.$$.log 1>> $ENV{'PBTMP'}/system.$$.log" if ((! defined $verbose) || ($verbose ne "noredir"));
    150150system("$cmd $redir");
    151151my $res = $?;
     
    158158if ($res == -1) {
    159159    pb_log(0,"failed to execute ($cmd): $!\n") if ((! defined $verbose) || ($verbose ne "quiet"));
    160     pb_display_file("$ENV{'PBTMP'}/system.log") if ((-f "$ENV{'PBTMP'}/system.log") and ((! defined $verbose) || ($verbose ne "quiet")));
     160    pb_display_file("$ENV{'PBTMP'}/system.$$.log") if ((-f "$ENV{'PBTMP'}/system.$$.log") and ((! defined $verbose) || ($verbose ne "quiet")));
    161161} elsif ($res & 127) {
    162162    pb_log(0, "child ($cmd) died with signal ".($? & 127).", ".($? & 128) ? 'with' : 'without'." coredump\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")));
     163    pb_display_file("$ENV{'PBTMP'}/system.$$.log") if ((-f "$ENV{'PBTMP'}/system.$$.log") and ((! defined $verbose) || ($verbose ne "quiet")));
    164164} elsif ($res == 0) {
    165165    pb_log(0,"OK\n") if ((! defined $verbose) || ($verbose ne "quiet"));
    166     pb_display_file("$ENV{'PBTMP'}/system.log") if ((defined $verbose) and (-f "$ENV{'PBTMP'}/system.log") and ($verbose ne "quiet"));
     166    pb_display_file("$ENV{'PBTMP'}/system.$$.log") if ((defined $verbose) and (-f "$ENV{'PBTMP'}/system.$$.log") and ($verbose ne "quiet"));
    167167} else {
    168168    pb_log(0, "child ($cmd) exited with value ".($? >> 8)."\n") if ((! defined $verbose) || ($verbose ne "quiet"));
    169     pb_display_file("$ENV{'PBTMP'}/system.log") if ((-f "$ENV{'PBTMP'}/system.log") and ((! defined $verbose) || ($verbose ne "quiet")));
     169    pb_display_file("$ENV{'PBTMP'}/system.$$.log") if ((-f "$ENV{'PBTMP'}/system.$$.log") and ((! defined $verbose) || ($verbose ne "quiet")));
    170170}
    171171return($res);
     
    312312=item B<pb_set_content>
    313313
    314 This function put the content of a file into the file passed in parameter.
     314This function put the content of a variable passed as second parameter into the file passed as first parameter.
    315315
    316316=cut
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r1132 r1137  
    302302return if ((not defined $deps) || ($deps =~ /^\s*$/));
    303303if ($deps !~ /^[    ]*$/) {
     304    # This may not be // proof. We should test for availability of repo and sleep if not
    304305    pb_system("$dupd $deps","Installing dependencies ($deps)");
    305306    }
  • devel/pb/bin/pb

    r1134 r1137  
    10391039    pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $arch))."\n");
    10401040
     1041    # If needed we may add repository to the build env
     1042    pb_distro_setuprepo($ddir,$dver,$arch,$dtype,$dfam,$dos);
     1043
    10411044    # Get list of packages to build
    10421045    my $ptr = pb_get_pkg();
     
    10491052    chdir "$ENV{'PBBUILDDIR'}";
    10501053    my $made = ""; # pkgs made during build
     1054    my $pm = new Parallel::ForkManager($pbparallel) if (defined $pbparallel);
     1055
     1056    # We need to communicate info back from the children if parallel so prepare a dir for that
     1057    my $tmpd = "$ENV{'PBTMP'}/build.$$";
     1058    pb_mkdir_p($tmpd) if (defined $pbparallel);
     1059
    10511060    foreach my $pbpkg (@pkgs) {
     1061        $pm->start and next if (defined $pbparallel);
     1062
    10521063        my $vertag = $pkg->{$pbpkg};
    10531064        # get the version of the current package - maybe different
     
    10851096            }
    10861097
    1087             # If needed we may add repository to the build env
    1088             pb_distro_setuprepo($ddir,$dver,$arch,$dtype,$dfam,$dos);
    10891098            foreach my $f (@specfile) {
    10901099                if ($f =~ /\.spec$/) {
     1100                    # This could cause an issue in // mode
    10911101                    pb_distro_installdeps($f,$dtype,$pbins);
    10921102                    pb_system("rpmbuild $specialdef --define \"packager $ENV{'PBPACKAGER'}\" --define \"_topdir $ENV{'PBBUILDDIR'}\" -ba $f","Building package with $f under $ENV{'PBBUILDDIR'}","verbose");
     
    10951105            }
    10961106            # Get the name of the generated packages
    1097             open(LOG,"$ENV{'PBTMP'}/system.log") || die "Unable to open $ENV{'PBTMP'}/system.log";
     1107            open(LOG,"$ENV{'PBTMP'}/system.$$.log") || die "Unable to open $ENV{'PBTMP'}/system.$$.log";
    10981108            while (<LOG>) {
    10991109                chomp($_);
     
    11141124            chmod 0755,"debian/rules";
    11151125
    1116             pb_distro_setuprepo($ddir,$dver,$arch,$dtype,$dfam,$dos);
    11171126            pb_distro_installdeps("debian/control",$dtype,$pbins);
    11181127            pb_system("dpkg-buildpackage -us -uc -rfakeroot","Building package","verbose");
    11191128            # Get the name of the generated packages
    1120             open(LOG,"$ENV{'PBTMP'}/system.log") || die "Unable to open $ENV{'PBTMP'}/system.log";
     1129            open(LOG,"$ENV{'PBTMP'}/system.$$.log") || die "Unable to open $ENV{'PBTMP'}/system.$$.log";
    11211130            while (<LOG>) {
    11221131                chomp();
     
    12341243            die "Unknown dtype format $dtype";
    12351244        }
    1236     }
     1245        if (defined $pbparallel) {
     1246            # Communicate results back to parent
     1247            pb_set_content("$tmpd/$$",$made);
     1248            $pm->finish;
     1249        }
     1250    }
     1251    if (defined $pbparallel) {
     1252        # In the parent, we need to get the result from the children
     1253        $pm->wait_all_children;
     1254        foreach my $f (<$tmpd/*>) {
     1255            $made .= " ".pb_get_content($f);
     1256        }
     1257        pb_rm_rf($tmpd);
     1258    }
     1259
    12371260    # Find the appropriate check cmd/opts
    12381261    my ($oschkcmd,$oschkopt) = pb_conf_get_if("oschkcmd","oschkopt");
     
    29612984<p>
    29622985EOF
    2963     open(LOG,"$ENV{'PBTMP'}/system.log") || die "Unable to read $ENV{'PBTMP'}/system.log: $!";
     2986    open(LOG,"$ENV{'PBTMP'}/system.$$.log") || die "Unable to read $ENV{'PBTMP'}/system.$$.log: $!";
    29642987    my $col = 2;
    29652988    my $i = 1;
Note: See TracChangeset for help on using the changeset viewer.