Changeset 1552 in ProjectBuilder


Ignore:
Timestamp:
May 21, 2012, 2:57:56 AM (12 years ago)
Author:
Bruno Cornec
Message:
  • pb: log when we start and finish the build, that's an important state. Add missing setting of all_ok to false that kept us from properly stopping on errors. Fix typos in comments. Greatly simplify pb_get_distros function by using split and join. Also remove whitespace since multi-line conf file support will cause that to be added.
  • Filter.pm: use new pb_pbos_to_keylist function to generate the list of basenames we want, and use a loop rather than lots of separate statements. Simplifies and makes more powerful this function. Also now guaranteed to maintain consistency with key lookups in the hash maps.
Location:
devel/pb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1551 r1552  
    119119
    120120Name of the Virtual Machines (VM), Virtual Environments (VE) or Remote Machines (RM)
    121 you want to build on (coma separated).
     121you want to build on (comma separated).
    122122All if none precised (or use the env variable PBV).
    123123
     
    13741374sub pb_build2pkg {
    13751375
     1376    pb_log(0,"INFO: ------ Starting to build package ------\n");
    13761377    # Get the running distro to build on
    13771378    my $pbos = pb_distro_get_context();
     
    17541755    print KEEP "$made\n";
    17551756    close(KEEP);
     1757    pb_log(0,"INFO: ------ Finished building package ------\n");
    17561758}
    17571759
     
    26582660    $pm->run_on_finish(sub { my ($pid, $code, $id, $signal, $dump) = @_;
    26592661                            unless ($code == 0 && $signal == 0 && $dump == 0) {
     2662                                $all_ok = 0;
    26602663                                pb_log(0,"ERROR: pid $pid failed\n");
    26612664                            }
     
    40804083}
    40814084
    4082 sub pb_add_coma {
     4085sub pb_add_comma {
    40834086
    40844087my $str = shift;
     
    41034106# This function works for both patches and additional sources
    41044107foreach my $p (sort(<$sdir/*>)) {
    4105     $ptr->{$key} = pb_add_coma($ptr->{$key},"file://$p") if (($p =~ /\.all$/) || ($p =~ /\.$pbos->{'os'}$/) || ($p =~ /\.$pbos->{'type'}$/) || ($p =~ /\.$pbos->{'family'}$/) || ($p =~ /\.$pbos->{'name'}$/) || ($p =~ /\.$pbos->{'name'}-$pbos->{'version'}$/) ||($p =~ /\.$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}$/));
     4108    $ptr->{$key} = pb_add_comma($ptr->{$key},"file://$p") if (($p =~ /\.all$/) || ($p =~ /\.$pbos->{'os'}$/) || ($p =~ /\.$pbos->{'type'}$/) || ($p =~ /\.$pbos->{'family'}$/) || ($p =~ /\.$pbos->{'name'}$/) || ($p =~ /\.$pbos->{'name'}-$pbos->{'version'}$/) ||($p =~ /\.$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}$/));
    41064109}
    41074110
     
    41164119    while (<PATCH>) {
    41174120        chomp();
    4118         $ptr->{$key} = pb_add_coma($ptr->{$key},"$_");
     4121        $ptr->{$key} = pb_add_comma($ptr->{$key},"$_");
    41194122    }
    41204123    close(PATCH);
     
    42844287}
    42854288
    4286 # return list of all distributins supported, coma separated
     4289# return list of all distributins supported, comma separated
    42874290sub pb_get_distros {
    42884291
     
    42904293my $pbtarget = shift;
    42914294
    4292 my $tmpl = "$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'},";
     4295my $dists = ("$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}");
    42934296
    42944297# Get list of distributions for which we need to generate build files if no target
    42954298if (not defined $pbtarget) {
    42964299    my @pt = pb_conf_get_if("vmlist","velist","rmlist");
    4297     if (defined $pt[0]->{$ENV{'PBPROJ'}}) {
    4298         $tmpl .= $pt[0]->{$ENV{'PBPROJ'}};
    4299     }
    4300     if (defined $pt[1]->{$ENV{'PBPROJ'}}) {
    4301         # The 2 lists need to be grouped with a ',' separating them
    4302         if ($tmpl ne "") {
    4303             $tmpl .= ",";
    4304         }
    4305         $tmpl .= $pt[1]->{$ENV{'PBPROJ'}}
    4306     }
    4307     if (defined $pt[2]->{$ENV{'PBPROJ'}}) {
    4308         # The lists needs to be grouped with a ',' separating them
    4309         if ($tmpl ne "") {
    4310             $tmpl .= ",";
    4311         }
    4312     $tmpl .= $pt[2]->{$ENV{'PBPROJ'}}
    4313     }
    4314 }
    4315 return($tmpl);
     4300    foreach my $pt (@pt) {
     4301        push(@dists, split(/,/, $pt->{$ENV{PBPROJ}})) if defined $pt->{$ENV{PBPROJ}};
     4302    }
     4303    # remove any whitespace
     4304    grep(s/\s+//go, @dists);
     4305}
     4306return(join(",",@dists));
    43164307}   
    43174308
  • devel/pb/lib/ProjectBuilder/Filter.pm

    r1549 r1552  
    6464
    6565my @ffiles;
    66 my ($ffile00, $ffile0, $ffile1, $ffile2, $ffile3, $ffile4, $ffile5);
    67 my ($mfile00, $mfile0, $mfile1, $mfile2, $mfile3, $mfile4, $mfile5);
    6866my $pbpkg = shift || die "No package specified";
    6967my $pbos = shift;
     
    7270
    7371pb_log(2,"Entering pb_get_filters - pbpkg: $pbpkg - pbos: ".Dumper($pbos)."\n");
    74 # Global filter files first, then package specificities
    75 if (-d "$ENV{'PBROOTDIR'}/pbfilter") {
    76     $mfile00 = "$ENV{'PBROOTDIR'}/pbfilter/all.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/all.pbf");
    77     if (defined $pbos) {
    78         $mfile0 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'os'}.pbf" if ((defined $pbos->{'os'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'os'}.pbf"));
    79         $mfile1 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'type'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'type'}.pbf"));
    80         $mfile2 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'family'}.pbf" if ((defined $pbos->{'family'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'family'}.pbf"));
    81         $mfile3 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}.pbf" if ((defined $pbos->{'name'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}.pbf"));
    82         $mfile4 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf" if ((defined $pbos->{'name'}) && (defined $pbos->{'version'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf"));
    83         $mfile5 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.pbf" if ((defined $pbos->{'name'}) && (defined $pbos->{'version'}) && (defined $pbos->{'arch'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.pbf"));
    84     }
    85 
    86     push @ffiles,$mfile00 if (defined $mfile00);
    87     push @ffiles,$mfile0 if (defined $mfile0);
    88     push @ffiles,$mfile1 if (defined $mfile1);
    89     push @ffiles,$mfile2 if (defined $mfile2);
    90     push @ffiles,$mfile3 if (defined $mfile3);
    91     push @ffiles,$mfile4 if (defined $mfile4);
    92     push @ffiles,$mfile5 if (defined $mfile5);
    93 }
    94 
    95 if (-d "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter") {
    96     $ffile00 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/all.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/all.pbf");
    97     if (defined $pbos) {
    98         $ffile0 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'os'}.pbf" if ((defined $pbos->{'os'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'os'}.pbf"));
    99         $ffile1 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'type'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'type'}.pbf"));
    100         $ffile2 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'family'}.pbf" if ((defined $pbos->{'family'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'family'}.pbf"));
    101         $ffile3 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}.pbf" if ((defined $pbos->{'name'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}.pbf"));
    102         $ffile4 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf" if ((defined $pbos->{'name'}) && (defined $pbos->{'version'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf"));
    103         $ffile5 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.pbf" if ((defined $pbos->{'name'}) && (defined $pbos->{'version'}) && (defined $pbos->{'arch'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.pbf"));
    104     }
    105     push @ffiles,$ffile00 if (defined $ffile00);
    106     push @ffiles,$ffile0 if (defined $ffile0);
    107     push @ffiles,$ffile1 if (defined $ffile1);
    108     push @ffiles,$ffile2 if (defined $ffile2);
    109     push @ffiles,$ffile3 if (defined $ffile3);
    110     push @ffiles,$ffile4 if (defined $ffile4);
    111     push @ffiles,$ffile5 if (defined $ffile5);
    112 }
     72
     73# Global filter files first, then package specific
     74my @file_basenames = ('all');
     75@file_basenames = reverse pb_pbos_to_keylist($pbos, 'all') if (defined $pbos);
     76# Build list of all filter files
     77foreach my $dir ("$ENV{PBROOTDIR}/pbfilter", "$ENV{PBROOTDIR}/$pbpkg/pbfilter") {
     78    foreach my $file_basename (@file_basenames) {
     79        my $path = "$dir/${file_basename}.pbf";
     80        push(@ffiles, $path) if -f $path;
     81    }
     82}
     83
    11384if (@ffiles) {
    11485    pb_log(2,"DEBUG ffiles: ".Dumper(\@ffiles)."\n");
Note: See TracChangeset for help on using the changeset viewer.