Changeset 500 in ProjectBuilder for devel/pb/lib


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)
Location:
devel/pb/lib/ProjectBuilder
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/lib/ProjectBuilder/CMS.pm

    r452 r500  
    1616use English;
    1717use File::Basename;
     18use File::Copy;
    1819use POSIX qw(strftime);
    1920use lib qw (lib);
     
    109110This function exports a CMS content to a directory.
    110111The first parameter is the URL of the CMS content.
    111 The second parameter is the directory in which it is locally exposed (result of a checkout).
     112The second parameter is the directory in which it is locally exposed (result of a checkout). If undef, then use the original CMS content.
    112113The third parameter is the directory where we want to deliver it (result of export).
    113114
     
    127128
    128129if ($scheme =~ /^svn/) {
    129     if (-d $source) {
    130         $tmp = $destdir;
    131     } else {
    132         $tmp = "$destdir/".basename($source);
    133     }
    134     pb_system("svn export $source $tmp","Exporting $source from SVN to $tmp");
     130    if (defined $source) {
     131        if (-d $source) {
     132            $tmp = $destdir;
     133        } else {
     134            $tmp = "$destdir/".basename($source);
     135        }
     136        pb_system("svn export $source $tmp","Exporting $source from SVN to $tmp");
     137    } else {
     138        pb_system("svn export $uri $destdir","Exporting $uri from SVN to $destdir");
     139    }
    135140} elsif ($scheme eq "dir") {
    136141    pb_system("cp -a $path $destdir","Copying $uri from DIR to $destdir");
     
    152157    pb_mkdir_p($destdir);
    153158
    154     # Check whether the file is well formed
    155     # (containing already a directory with the project-version name)
    156     my ($pbwf) = pb_conf_get_if("pbwf");
    157     if ((defined $pbwf) && (defined $pbwf->{$ENV{'PBPROJ'}})) {
    158         $destdir = dirname($destdir);
     159    if (defined $source) {
     160        # Check whether the file is well formed
     161        # (containing already a directory with the project-version name)
     162        my ($pbwf) = pb_conf_get_if("pbwf");
     163        if ((defined $pbwf) && (defined $pbwf->{$ENV{'PBPROJ'}})) {
     164            $destdir = dirname($destdir);
     165        }
    159166    }
    160167
     
    174181        # zip
    175182        pb_system("cd $destdir ; unzip $path","Extracting $path in $destdir");
     183    } else {
     184        # simple file: copy it (patch e.g.)
     185        copy($path,$destdir);
    176186    }
    177187} elsif ($scheme =~ /^cvs/) {
     
    179189    my $dir=dirname($destdir);
    180190    my $base=basename($destdir);
    181     # CVS also needs a modules name not a dir
    182     #if (-d $source) {
     191    if (defined $source) {
     192        # CVS also needs a modules name not a dir
    183193        $tmp1 = basename($source);
    184         #} else {
    185         #$tmp1 = dirname($source);
    186         #$tmp1 = basename($tmp1);
    187         #}
     194    } else {
     195        # Probably not right, should be checked, but that way I'll notice it :-)
     196        $tmp1 = $uri;
     197    }
    188198    my $optcvs = "";
    189199
     
    304314} elsif ($scheme =~ /^cvs/) {
    305315    pb_system("cvs co $url $destination","Checking out $url to $destination ");
     316} elsif ($scheme =~ /^file/) {
     317    pb_cms_export($url,undef,$destination);
    306318} else {
    307319    die "cms $scheme unknown";
     
    417429}
    418430
    419 =item B<pb_cms_isdiff>
     431=item B<pb_cms_getpkg>
    420432
    421433This function returns the list of packages we are working on in a CMS action.
  • devel/pb/lib/ProjectBuilder/Env.pm

    r484 r500  
    477477#
    478478# PBREPO is replaced by the root URL to access the repository
    479 filter PBREPO = \$pbrepo
     479filter PBREPO = \$pb->{'repo'}
    480480
    481481# PBSRC is replaced by the source package location after the repo
    482482#filter PBSRC = src/%{name}-%{version}.tar.gz
    483483
    484 # PBVER is replaced by the version (\$pbver in code)
    485 filter PBVER = \$pbver
    486 
    487 # PBDATE is replaced by the date (\$pbdate in code)
    488 filter PBDATE = \$pbdate
     484# PBVER is replaced by the version (\$pb->{'ver'} in code)
     485filter PBVER = \$pb->{'ver'}
     486
     487# PBDATE is replaced by the date (\$pb->{'date'} in code)
     488filter PBDATE = \$pb->{'date'}
    489489
    490490# PBLOG is replaced by the changelog if value is yes
    491491#filter PBLOG = yes
    492492
    493 # PBTAG is replaced by the tag (\$pbtag in code)
    494 filter PBTAG = \$pbtag
    495 
    496 # PBREV is replaced by the revision (\$pbrev in code)
    497 filter PBREV = \$pbrev
    498 
    499 # PBPKG is replaced by the package name (\$pbpkg in code)
    500 filter PBPKG = \$pbpkg
    501 
    502 # PBPACKAGER is replaced by the packager name (\$pbpackager in code)
    503 filter PBPACKAGER = \$pbpackager
     493# PBPATCHSRC is replaced by the patches names if value is yes
     494#filter PBPATCHSRC = yes
     495
     496# PBPATCHCMD is replaced by the patches commands if value is yes
     497#filter PBPATCHCMD = yes
     498
     499# PBTAG is replaced by the tag (\$pb->{'tag'} in code)
     500filter PBTAG = \$pb->{'tag'}
     501
     502# PBREV is replaced by the revision (\$pb->{'rev'} in code)
     503filter PBREV = \$pb->{'rev'}
     504
     505# PBPKG is replaced by the package name (\$pb->{'pkg'} in code)
     506filter PBPKG = \$pb->{'pkg'}
     507
     508# PBPACKAGER is replaced by the packager name (\$pb->{'packager'} in code)
     509filter PBPACKAGER = \$pb->{'packager'}
    504510
    505511# PBDESC contains the description of the package
     
    527533#filter PBDEP =
    528534
    529 # PBSUF is replaced by the package suffix (\$pbsuf in code)
    530 filter PBSUF = \$pbsuf
     535# PBSUF is replaced by the package suffix (\$pb->{'suf'} in code)
     536filter PBSUF = \$pb->{'suf'}
    531537
    532538# PBOBS is replaced by the Obsolete line
     
    554560#filter PBDEP =
    555561
    556 # PBSUF is replaced by the package suffix (\$pbsuf in code)
     562# PBSUF is replaced by the package suffix (\$pbsuf'} in code)
    557563filter PBSUF = %{dist}
    558564
     
    844850Url:            PBURL
    845851Source:         PBREPO/PBSRC
     852#PBPATCHSRC
    846853BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n)
    847854#Requires:       PBDEP
     
    855862%prep
    856863%setup -q
     864#PBPATCHCMD
    857865
    858866%build
  • devel/pb/lib/ProjectBuilder/Filter.pm

    r499 r500  
    139139my $destfile=shift;
    140140my $pb=shift;
    141 my %pb = %$pb;
    142141
    143142pb_log(2,"DEBUG: From $f to $destfile\n");
     
    149148    foreach my $s (keys %filter) {
    150149        # Process single variables
    151         pb_log(2,"DEBUG filter{$s}: $filter{$s}\n");
    152150        my $tmp = $filter{$s};
    153151        next if (not defined $tmp);
     152        pb_log(3,"DEBUG filter{$s}: $filter{$s}\n");
    154153        # Expand variables if any single one found
    155         pb_log(2,"DEBUG tmp: $tmp\n");
    156154        if ($tmp =~ /\$/) {
     155            # Order is important as we need to handle hashes refs before simple vars
     156            eval { $tmp =~ s/(\$\w+-\>\{\'\w+\'\})/$1/eeg };
    157157            eval { $tmp =~ s/(\$\w+)/$1/eeg };
    158158            eval { $tmp =~ s/(\$\/)/$1/eeg };
    159159        # special case for ChangeLog only for pb
    160160        } elsif (($s =~ /^PBLOG$/) && ($line =~ /^PBLOG$/)) {
    161             my $p = $pb{'defpkgdir'}->{$pbpkg};
    162             $p = $pb{'extpkgdir'}->{$pbpkg} if (not defined $p);
    163             pb_changelog($pb{'dtype'}, $pb{'pkg'}, $pb{'ver'}, $pb{'tag'}, $pb{'suf'}, $p, \*DEST, $tmp, $pb{'chglog'});
     161            pb_log(3,"DEBUG filtering PBLOG\n");
     162            my $p = $pb->{'defpkgdir'}->{$pb->{'pkg'}};
     163            $p = $pb->{'extpkgdir'}->{$pb->{'pkg'}} if (not defined $p);
     164            pb_changelog($pb->{'dtype'}, $pb->{'pkg'}, $pb->{'ver'}, $pb->{'tag'}, $pb->{'suf'}, $p, \*DEST, $tmp, $pb->{'chglog'});
    164165            $tmp = "";
    165166        } elsif (($s =~ /^PBPATCHSRC$/) && ($line =~ /^PBPATCHSRC$/)) {
     167            pb_log(3,"DEBUG filtering PBPATCHSRC\n");
    166168            my $i = 0;
    167             foreach my $p (sort @$pb{'patches'}) {
    168                 print DEST "Patch$i: $p\n";
     169            foreach my $p (split(/,/,$pb->{'patches'}->{$pb->{'tuple'}})) {
     170                print DEST "Patch$i:         ".basename($p).".gz\n";
     171                $i++;
    169172            }
    170173            $tmp = "";
    171174        } elsif (($s =~ /^PBPATCHCMD$/) && ($line =~ /^PBPATCHCMD$/)) {
     175            pb_log(3,"DEBUG filtering PBPATCHCMD\n");
    172176            my $i = 0;
    173             foreach my $p (sort @$pb{'patches'}) {
    174                 print DEST "%patch$i\n";
     177            foreach my $p (split(/,/,$pb->{'patches'}->{$pb->{'tuple'}})) {
     178                print DEST "%patch$i -p1\n";
     179                $i++;
    175180            }
    176181            print DEST "\n";
     
    204209my $destfile=shift;
    205210my $pb=shift;
    206 my %pb = %$pb;
    207211
    208212my $cp = "$ENV{'PBTMP'}/".basename($destfile);
    209 copy($destfile,$cp) || die "Unable to create $cp";
     213copy($destfile,$cp) || die "Unable to copy $destfile to $cp";
    210214
    211215pb_filter_file($cp,$ptr,$destfile,$pb);
Note: See TracChangeset for help on using the changeset viewer.