Changeset 1130


Ignore:
Timestamp:
Dec 22, 2010, 4:01:42 AM (9 years ago)
Author:
Bruno Cornec
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.
Location:
devel/pb
Files:
3 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
  • devel/pb/lib/ProjectBuilder/Env.pm

    r1113 r1130  
    555555filter PBDATE = \$pb->{'date'}
    556556
    557 # PBPATCHSRC is replaced by the patches names if value is yes
     557# PBPATCHSRC is replaced by the patches names if value is yes. Patches are located under the pbpatch dir of the pkg.
    558558#filter PBPATCHSRC = yes
    559559
    560560# PBPATCHCMD is replaced by the patches commands if value is yes
    561561#filter PBPATCHCMD = yes
     562
     563# PBMULTISRC is replaced by the sources names if value is yes. Sources are located under the pbsrc dir of the pkg.
     564#filter PBMULTISRC = yes
    562565
    563566# PBTAG is replaced by the tag (\$pb->{'tag'} in code)
  • devel/pb/lib/ProjectBuilder/Filter.pm

    r1044 r1130  
    177177            }
    178178            $tmp = "";
     179        } elsif (($s =~ /^PBMULTISRC$/) && ($line =~ /^PBMULTISRC$/)) {
     180            pb_log(3,"DEBUG filtering PBMULTISRC\n");
     181            my $i = 1;
     182            foreach my $p (split(/,/,$pb->{'sources'}->{$pb->{'tuple'}})) {
     183                print DEST "Source$i:         ".basename($p)."\n";
     184                $i++;
     185            }
     186            $tmp = "";
    179187        } elsif (($s =~ /^PBPATCHCMD$/) && ($line =~ /^PBPATCHCMD$/)) {
    180188            pb_log(3,"DEBUG filtering PBPATCHCMD\n");
Note: See TracChangeset for help on using the changeset viewer.