Changeset 1130 for devel/pb/bin/pb


Ignore:
Timestamp:
12/22/10 04:01:42 (2 years ago)
Author:
bruno
Message:
  • First attempt to fix both #74 and #10 by adding support for additional files under a pbsrc dir, that can be manipulated at build time.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1128 r1130  
    756756        my %build; 
    757757        my %patches; 
     758        my %sources; 
    758759        # We want to at least build for the underlying distro 
    759760        # except if a target was given, in which case we only build for it 
     
    793794        $pb{'repo'} = $ENV{'PBREPO'}; 
    794795        $pb{'patches'} = \%patches; 
     796        $pb{'sources'} = \%sources; 
    795797        pb_log(2,"DEBUG: pb: ".Dumper(%pb)."\n"); 
    796798     
     
    852854                my $ptr = pb_get_filters($pbpkg, $pb{'dtype'}, $dfam, $ddir, $dver); 
    853855     
    854                 # Prepare local patches for this distro - They are always applied first - May be a problem one day 
    855                 foreach my $p (sort(<$ENV{'PBROOTDIR'}/$pbpkg/pbpatch/*>)) { 
    856                     $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.all$/)); 
    857                     $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.all$/); 
    858                     $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.$pb{'dtype'}$/)); 
    859                     $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$pb{'dtype'}$/); 
    860                     $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.$dfam$/)); 
    861                     $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$dfam$/); 
    862                     $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir$/)); 
    863                     $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir$/); 
    864                     $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir-$dver$/)); 
    865                     $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir-$dver$/); 
    866                     $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir-$dver-$arch$/)); 
    867                     $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir-$dver-$arch$/); 
    868                 } 
    869      
    870                 # Prepare also remote patches to be included - Applied after the local ones 
    871                 foreach my $p ("all","$pb{'dtype'}","$dfam","$ddir","$ddir-$dver","$ddir-$dver-$arch") { 
    872                     my $f = "$ENV{'PBROOTDIR'}/$pbpkg/pbextpatch.$p"; 
    873                     next if (not -f $f); 
    874                     if (not open(PATCH,$f)) { 
    875                         pb_display("Unable to open existing external patch file content $f\n"); 
    876                         next; 
    877                     } 
    878                     while (<PATCH>) { 
    879                         chomp(); 
    880                         $patches{"$ddir-$dver-$arch"} .= "," if (defined $patches{"$ddir-$dver-$arch"}); 
    881                         $patches{"$ddir-$dver-$arch"} .= "$_"; 
    882                     } 
    883                     close(PATCH); 
    884                 } 
    885                 pb_log(2,"DEBUG: pb->patches: ".Dumper($pb{'patches'})."\n"); 
    886      
    887856                # Apply now all the filters on all the files concerned 
    888857                # destination dir depends on the type of file 
     
    894863                    } 
    895864                } 
     865                pb_list_sfiles("$ENV{'PBROOTDIR'}/$pbpkg/pbpatch", \%patches, $pb{'dtype'}, $dfam, $ddir, $dver, $arch, "$ENV{'PBROOTDIR'}/$pbpkg/pbextpatch"); 
     866                pb_list_sfiles("$ENV{'PBROOTDIR'}/$pbpkg/pbsrc", \%sources, $pb{'dtype'}, $dfam, $ddir, $dver, $arch, "$ENV{'PBROOTDIR'}/$pbpkg/pbextsrc"); 
     867 
    896868                $pm->finish if (defined $pbparallel); 
    897869            } 
     
    906878            pb_log(0,"No Build files found for ".join(',',sort(@notfound))."\n") if (@notfound); 
    907879            pb_log(2,"DEBUG: patches: ".Dumper(%patches)."\n"); 
     880            pb_log(2,"DEBUG: sources: ".Dumper(%sources)."\n"); 
    908881        } 
    909882 
     
    927900        if (not defined $web) { 
    928901            my %tmp; 
    929             my $warnflag = 0; 
     902            my $warnptcflag = 0; 
     903            my $warnsrcflag = 0; 
    930904            # Filter potential patches (local + remote) 
    931905            pb_log(0,"Delivering and compressing patches "); 
     
    935909                    my $pp = basename($pf); 
    936910                    if ($param eq "SandBox") { 
    937                         $warnflag = 1; 
     911                        $warnptcflag = 1; 
    938912                    } 
    939913                    pb_cms_export($pf,undef,"$dest/pbconf/$v/pbpatch"); 
     
    943917                } 
    944918            } 
     919            pb_log(0,"Delivering additional sources "); 
     920            foreach my $v (keys %sources) { 
     921                pb_mkdir_p("$dest/pbconf/$v/pbsrc"); 
     922                foreach my $pf (split(/,/,$sources{$v})) { 
     923                    my $pp = basename($pf); 
     924                    if ($param eq "SandBox") { 
     925                        $warnsrcflag = 1; 
     926                    } 
     927                    pb_cms_export($pf,undef,"$dest/pbconf/$v/pbsrc"); 
     928                    pb_filter_file_inplace($ptr,"$dest/pbconf/$v/pbsrc/$pp",\%pb); 
     929                    $tmp{$pf} = ""; 
     930                } 
     931            } 
    945932            foreach my $v (keys %tmp) { 
    946933                pb_log(0,"$v "); 
    947934            } 
    948935            pb_log(0,"\n"); 
    949             pb_log(0,"WARNING: Patches are always taken from repository not local export\n") if ($warnflag == 1); 
     936            pb_log(0,"WARNING: Patches are always taken from repository not local export\n") if ($warnptcflag == 1); 
     937            pb_log(0,"WARNING: Sources are always taken from repository not local export\n") if ($warnsrcflag == 1); 
    950938        } else { 
    951939            # Instead call News generation 
     
    32503238} 
    32513239 
    3252  
     3240sub pb_list_sfiles { 
     3241 
     3242my $sdir = shift; 
     3243my $sources = shift; 
     3244my $dtype = shift; 
     3245my $dfam = shift; 
     3246my $ddir = shift; 
     3247my $dver = shift; 
     3248my $arch = shift; 
     3249my $extdir = shift; 
     3250 
     3251# Prepare local sources for this distro - They are always applied first - May be a problem one day 
     3252# This function works for both patches and additional sources 
     3253foreach my $p (sort(<$sdir/*>)) { 
     3254    $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.all$/)); 
     3255    $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.all$/); 
     3256    $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$dtype$/)); 
     3257    $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$dtype$/); 
     3258    $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$dfam$/)); 
     3259    $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$dfam$/); 
     3260    $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir$/)); 
     3261    $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir$/); 
     3262    $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir-$dver$/)); 
     3263    $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir-$dver$/); 
     3264    $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir-$dver-$arch$/)); 
     3265    $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir-$dver-$arch$/); 
     3266} 
     3267 
     3268# Prepare also remote sources to be included - Applied after the local ones 
     3269foreach my $p ("all","$dtype","$dfam","$ddir","$ddir-$dver","$ddir-$dver-$arch") { 
     3270    my $f = "$extdir.".".$p"; 
     3271    next if (not -f $f); 
     3272    if (not open(PATCH,$f)) { 
     3273        pb_display("Unable to open existing external source file content $f\n"); 
     3274        next; 
     3275    } 
     3276    while (<PATCH>) { 
     3277        chomp(); 
     3278        $sources->{"$ddir-$dver-$arch"} .= "," if (defined $sources->{"$ddir-$dver-$arch"}); 
     3279        $sources->{"$ddir-$dver-$arch"} .= "$_"; 
     3280    } 
     3281    close(PATCH); 
     3282} 
     3283pb_log(2,"DEBUG: sources: ".Dumper($sources)."\n"); 
     3284} 
     3285     
    32533286#  
    32543287# Return the list of packages we are working on in a non CMS action 
Note: See TracChangeset for help on using the changeset viewer.