Changeset 499 for devel/pb/bin/pb


Ignore:
Timestamp:
Jul 30, 2008, 5:58:00 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Modification of filter interface: use a single pb hash which contains the tag that will be handled during the filtering. Allow for easiest interface of functions, removal of a redundant function and evolution by simple addition of tags in pb.
  • Attempt to code patch management. Not tested yet.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r498 r499  
    454454    my @pkgs = @$pkg;
    455455    my %pkgs;
     456    my %pb;             # Structure to store conf info
    456457
    457458    my ($scheme, $uri) = pb_cms_init($pbinit);
     
    520521        my @pt;
    521522        my $tmpl = "";
     523        my @patches = ();
    522524
    523525        @pt = pb_conf_get_if("vmlist","velist");
     
    532534            $tmpl .= $pt[1]->{$ENV{'PBPROJ'}}
    533535        }
     536
     537        # Setup %pb structure to allow filtering later on on files using that structure
     538        $pb{'tag'} = $pbtag;
     539        $pb{'rev'} = $pbrev;
     540        $pb{'pkg'} = $pbpkg;
     541        $pb{'ver'} = $pbver;
     542        $pb{'date'} = $pbdate;
     543        $pb{'defpkgdir'} = $defpkgdir;
     544        $pb{'extpkgdir'} = $extpkgdir;
     545        $pb{'chglog'} = $chglog;
     546        $pb{'packager'} = $ENV{'PBPACKAGER'};
     547        $pb{'proj'} = $ENV{'PBPROJ'};
     548        $pb{'repo'} = $ENV{'PBREPO'};
     549
    534550        foreach my $d (split(/,/,$tmpl)) {
    535551            my ($name,$ver,$arch) = split(/-/,$d);
    536552            chomp($arch);
    537             my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($name,$ver);
    538             pb_log(2,"DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf)."\n");
     553            my ($ddir, $dver, $dfam);
     554            ($ddir, $dver, $dfam, $pb{'dtype'}, $pb{'suf'}) = pb_distro_init($name,$ver);
     555            pb_log(2,"DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $pb{'dtype'}, $pb{'suf'})."\n");
    539556            pb_log(2,"DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n");
    540557
     
    548565            $build{"$ddir-$dver"} = "yes";
    549566
    550             if (-d "$ENV{'PBROOTDIR'}/$pbpkg/$dtype") {
    551                 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$dtype",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
     567            if (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pb{'dtype'}") {
     568                pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pb{'dtype'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
    552569            } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$dfam") {
    553570                pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$dfam",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
     
    563580
    564581            # Get all filters to apply
    565             my $ptr = pb_get_filters($pbpkg, $dtype, $dfam, $ddir, $dver);
     582            my $ptr = pb_get_filters($pbpkg, $pb{'dtype'}, $dfam, $ddir, $dver);
    566583
    567584            # Prepare patches for this distro
    568             my @patches;
    569 
    570585            foreach my $p (sort(<$ENV{'PBROOTDIR'}/$pbpkg/pbpatch/*>)) {
    571586                push @patches,$p if ($p =~ /\.all$/);
    572                 push @patches,$p if ($p =~ /\.$dtype$/);
     587                push @patches,$p if ($p =~ /\.$pb{'dtype'}$/);
    573588                push @patches,$p if ($p =~ /\.$dfam$/);
    574589                push @patches,$p if ($p =~ /\.$ddir$/);
    575590                push @patches,$p if ($p =~ /\.$ddir-$dver$/);
    576591            }
     592            $pb{'patches'} = \@patches;
    577593
    578594            # Apply now all the filters on all the files concerned
     
    580596            if (defined $ptr) {
    581597                foreach my $f (values %bfiles,values %pkgfiles) {
    582                     pb_filter_file_pb("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),$dtype,$pbsuf,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$defpkgdir,$extpkgdir,$ENV{'PBPACKAGER'},$chglog,$ENV{'PBPROJ'},$ENV{'PBREPO'});
     598                    pb_filter_file("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),\%pb);
    583599                }
    584600            }
     
    602618        if (defined $filteredfiles->{$pbpkg}) {
    603619            foreach my $f (split(/,/,$filteredfiles->{$pbpkg})) {
    604                 pb_filter_file_inplace($ptr,"$dest/$f",$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$ENV{'PBPACKAGER'},$ENV{'PBPROJ'},$ENV{'PBREPO'});
     620                pb_filter_file_inplace($ptr,"$dest/$f",\%pb);
    605621                $liste = "$f $liste";
    606622            }
    607623        }
    608624        pb_log(2,"Files ".$liste."have been filtered\n");
     625
     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        }
    609633
    610634        # Prepare the dest directory for archive
    611635        if (-x "$ENV{'PBROOTDIR'}/$pbpkg/pbinit") {
    612             pb_filter_file("$ENV{'PBROOTDIR'}/$pbpkg/pbinit",$ptr,"$ENV{'PBTMP'}/pbinit",$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$ENV{'PBPACKAGER'},$ENV{'PBPROJ'},$ENV{'PBREPO'});
     636            pb_filter_file("$ENV{'PBROOTDIR'}/$pbpkg/pbinit",$ptr,"$ENV{'PBTMP'}/pbinit",\%pb);
    613637            chmod 0755,"$ENV{'PBTMP'}/pbinit";
    614638            pb_system("cd $dest ; $ENV{'PBTMP'}/pbinit","Executing init script from $ENV{'PBROOTDIR'}/$pbpkg/pbinit","verbose");
    615         }
    616 
    617         # Filter potential patches
    618         foreach my $p (sort(<$ENV{'PBROOTDIR'}/$pbpkg/pbpatch/*>)) {
    619             pb_mkdir_p("$dest/pbconf/pbpatch");
    620             pb_filter_file("$ENV{'PBROOTDIR'}/$pbpkg/pbpatch/$p",$ptr,"$dest/pbconf/pbpatch/$p",$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$ENV{'PBPACKAGER'},$ENV{'PBPROJ'},$ENV{'PBREPO'});
    621639        }
    622640
     
    694712            symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES";
    695713            # We need to first extract the spec file
    696             my @specfile;
    697             @specfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS");
     714            my @specfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS");
    698715
    699716            # We need to handle potential patches to upstream sources
     717            my @patchfiles = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/pbpatch/","$ENV{'PBBUILDDIR'}/SOURCES");
    700718
    701719            pb_log(2,"specfile: ".Dumper(\@specfile)."\n");
Note: See TracChangeset for help on using the changeset viewer.