Changeset 500 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
Aug 3, 2008, 1:20:30 PM (16 years ago)
Author:
Bruno Cornec
Message:
  • Working patch support added to pb (tested with buffer)
  • Filtering functions now handle also pointer on hashes (such as the new pb hash)
  • Filtering functions support new macro for patch support (PBPATCHSRC and PBPATCHCMD)
  • Env.pm now generates correct templates for patch support and uses the new pb hash
  • pb_cms_export extended to support file:// URI, and also supports an undef second param (no local export available)
  • In pb, hashes now include also the arch (for better patch support)
  • pb supports local CMS based patches, as well as external references (not tested yet)
  • New pb_get_arch function provided
  • New parameters for pb_system (mayfail and quiet)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r499 r500  
    521521        my @pt;
    522522        my $tmpl = "";
    523         my @patches = ();
     523        my %patches;
    524524
    525525        @pt = pb_conf_get_if("vmlist","velist");
     
    547547        $pb{'proj'} = $ENV{'PBPROJ'};
    548548        $pb{'repo'} = $ENV{'PBREPO'};
     549        $pb{'patches'} = \%patches;
     550        pb_log(2,"DEBUG: pb: ".Dumper(%pb)."\n");
    549551
    550552        foreach my $d (split(/,/,$tmpl)) {
     
    563565            my %bfiles = ();
    564566            my %pkgfiles = ();
    565             $build{"$ddir-$dver"} = "yes";
     567            $build{"$ddir-$dver-$arch"} = "yes";
    566568
    567569            if (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pb{'dtype'}") {
     
    573575            } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ddir-$dver") {
    574576                pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ddir-$dver",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
     577            } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ddir-$dver-$arch") {
     578                pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ddir-$dver-$arch",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
    575579            } else {
    576                 $build{"$ddir-$dver"} = "no";
     580                $build{"$ddir-$dver-$arch"} = "no";
    577581                next;
    578582            }
     
    582586            my $ptr = pb_get_filters($pbpkg, $pb{'dtype'}, $dfam, $ddir, $dver);
    583587
    584             # Prepare patches for this distro
     588            # Prepare local patches for this distro - They are always applied first - May be a problem one day
    585589            foreach my $p (sort(<$ENV{'PBROOTDIR'}/$pbpkg/pbpatch/*>)) {
    586                 push @patches,$p if ($p =~ /\.all$/);
    587                 push @patches,$p if ($p =~ /\.$pb{'dtype'}$/);
    588                 push @patches,$p if ($p =~ /\.$dfam$/);
    589                 push @patches,$p if ($p =~ /\.$ddir$/);
    590                 push @patches,$p if ($p =~ /\.$ddir-$dver$/);
    591             }
    592             $pb{'patches'} = \@patches;
     590                $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.all$/));
     591                $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.all$/);
     592                $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.$pb{'dtype'}$/));
     593                $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$pb{'dtype'}$/);
     594                $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.$dfam$/));
     595                $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$dfam$/);
     596                $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir$/));
     597                $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir$/);
     598                $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir-$dver$/));
     599                $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir-$dver$/);
     600                $patches{"$ddir-$dver-$arch"} .= "," if ((defined $patches{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir-$dver-$arch$/));
     601                $patches{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir-$dver-$arch$/);
     602            }
     603
     604            # Prepare also remote patches to be included - Applied after the local ones
     605            foreach my $p ("all","$pb{'dtype'}","$dfam","$ddir","$ddir-$dver","$ddir-$dver-$arch") {
     606                my $f = "$ENV{'PBROOTDIR'}/$pbpkg/pbextpatch.$p";
     607                next if (not -f $f);
     608                if (not open(PATCH,$f)) {
     609                    pb_display("Unable to open existing external patch file content $f\n");
     610                    next;
     611                }
     612                while (<PATCH>) {
     613                    chomp();
     614                    $patches{"$ddir-$dver-$arch"} .= "," if (defined $patches{"$ddir-$dver-$arch"});
     615                    $patches{"$ddir-$dver-$arch"} .= "$_";
     616                }
     617                close(PATCH);
     618            }
     619            pb_log(2,"DEBUG: pb->patches: ".Dumper($pb{'patches'})."\n");
    593620
    594621            # Apply now all the filters on all the files concerned
    595622            # destination dir depends on the type of file
    596623            if (defined $ptr) {
     624                # For patch support
     625                $pb{'tuple'} = "$ddir-$dver-$arch";
    597626                foreach my $f (values %bfiles,values %pkgfiles) {
    598                     pb_filter_file("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),\%pb);
     627                    pb_filter_file("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$ddir-$dver-$arch/".basename($f),\%pb);
    599628                }
    600629            }
     
    608637        pb_log(0,"Build files generated for ".join(',',sort(@found))."\n");
    609638        pb_log(0,"No Build files found for ".join(',',sort(@notfound))."\n") if (@notfound);
     639        pb_log(2,"DEBUG: patches: ".Dumper(%patches)."\n");
     640
    610641        # Get the generic filter (all.pbf) and
    611642        # apply those to the non-build files including those
     
    624655        pb_log(2,"Files ".$liste."have been filtered\n");
    625656
    626         # Filter potential patches
    627         pb_mkdir_p("$dest/pbconf/pbpatch");
    628         foreach my $p (sort(@patches)) {
    629             my $pp = basename($p);
    630             pb_filter_file($p,$ptr,"$dest/pbconf/pbpatch/$pp",\%pb);
    631             pb_system("gzip -9 $dest/pbconf/pbpatch/$pp");
    632         }
     657        # Filter potential patches (local + remote)
     658        pb_log(0,"Delivering and compressing patches ");
     659        foreach my $v (keys %patches) {
     660            pb_mkdir_p("$dest/pbconf/$v/pbpatch");
     661            foreach my $pf (split(/,/,$patches{$v})) {
     662                my $pp = basename($pf);
     663                pb_cms_export($pf,undef,"$dest/pbconf/$v/pbpatch");
     664                pb_filter_file_inplace($ptr,"$dest/pbconf/$v/pbpatch/$pp",\%pb);
     665                pb_system("gzip -9f $dest/pbconf/$v/pbpatch/$pp","","quiet");
     666            }
     667            pb_log(0,"$patches{$v} ");
     668        }
     669        pb_log(0,"\n");
    633670
    634671        # Prepare the dest directory for archive
     
    685722    @pkgs = @$ptr;
    686723
     724    my $arch = pb_get_arch();
     725
    687726    my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg");
    688727    $pkg = { } if (not defined $pkg);
     
    712751            symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES";
    713752            # We need to first extract the spec file
    714             my @specfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS");
     753            my @specfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ddir-$dver-$arch/","$ENV{'PBBUILDDIR'}/SPECS","spec");
    715754
    716755            # We need to handle potential patches to upstream sources
    717             my @patchfiles = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/pbpatch/","$ENV{'PBBUILDDIR'}/SOURCES");
     756            pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ddir-$dver-$arch/pbpatch/","$ENV{'PBBUILDDIR'}/SOURCES","patch");
    718757
    719758            pb_log(2,"specfile: ".Dumper(\@specfile)."\n");
     
    742781            chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver";
    743782            pb_rm_rf("debian");
    744             symlink "pbconf/$ddir-$dver","debian" || die "Unable to symlink to pbconf/$ddir-$dver";
     783            symlink "pbconf/$ddir-$dver-$arch","debian" || die "Unable to symlink to pbconf/$ddir-$dver-$arch";
    745784            chmod 0755,"debian/rules";
    746785            if ($dver !~ /[0-9]/) {
     
    763802
    764803            # We need to first extract the ebuild file
    765             @ebuildfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$tmpd");
     804            @ebuildfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ddir-$dver-$arch/","$tmpd","ebuild");
    766805
    767806            # Prepare the build env for gentoo
     
    811850            pb_system("tar xfz $src2","Extracting pbconf");
    812851            chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver";
    813             symlink "pbconf/$ddir-$dver","install" || die "Unable to symlink to pbconf/$ddir-$dver";
     852            symlink "pbconf/$ddir-$dver-$arch","install" || die "Unable to symlink to pbconf/$ddir-$dver-$arch";
    814853            if (-x "install/pbslack") {
    815854                pb_system("./install/pbslack","Building package");
     
    11881227    $v =~ s/,.*//;
    11891228
    1190     # Which is our local arch ? (standardize on i386 for those platforms)
    1191     my $arch = `uname -m`;
    1192     chomp($arch);
    1193     $arch =~ s/i.86/i386/;
     1229    my $arch = pb_get_arch();
    11941230
    11951231    # Launch the VMs/VEs
     
    20432079my $dir=shift;
    20442080my $ddir=shift;
     2081my $mandatory=shift || "spec";
    20452082my @files;
    20462083
     2084my $flag = "mayfail" if ($mandatory eq "patch");
     2085my $res;
     2086
    20472087if ($src =~ /tar\.gz$/) {
    2048     pb_system("tar xfpz $src $dir","Extracting build files");
     2088    $res = pb_system("tar xfpz $src $dir","Extracting $mandatory files from $src",$flag);
    20492089} elsif ($src =~ /tar\.bz2$/) {
    2050     pb_system("tar xfpj $src $dir","Extracting build files");
     2090    $res = pb_system("tar xfpj $src $dir","Extracting $mandatory files from $src",$flag);
    20512091} else {
    20522092    die "Unknown compression algorithm for $src";
    20532093}
     2094# If not mandatory return now
     2095return() if (($res != 0) and ($mandatory eq "patch"));
    20542096opendir(DIR,"$dir") || die "Unable to open directory $dir";
    20552097foreach my $f (readdir(DIR)) {
    20562098    next if ($f =~ /^\./);
     2099    # Skip potential patch dir
     2100    next if ($f =~ /^pbpatch/);
    20572101    move("$dir/$f","$ddir") || die "Unable to move $dir/$f to $ddir";
    20582102    pb_log(2,"mv $dir/$f $ddir\n");
     
    21002144}
    21012145
     2146# Which is our local arch ? (standardize on i386 for those platforms)
     2147sub pb_get_arch {
     2148
     2149my $arch = `uname -m`;
     2150chomp($arch);
     2151$arch =~ s/i.86/i386/;
     2152return($arch);
     2153}
     2154
    210221551;
Note: See TracChangeset for help on using the changeset viewer.