Changeset 499 in ProjectBuilder
- Timestamp:
- Jul 30, 2008, 5:58:00 AM (17 years ago)
- Location:
- devel/pb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r498 r499 454 454 my @pkgs = @$pkg; 455 455 my %pkgs; 456 my %pb; # Structure to store conf info 456 457 457 458 my ($scheme, $uri) = pb_cms_init($pbinit); … … 520 521 my @pt; 521 522 my $tmpl = ""; 523 my @patches = (); 522 524 523 525 @pt = pb_conf_get_if("vmlist","velist"); … … 532 534 $tmpl .= $pt[1]->{$ENV{'PBPROJ'}} 533 535 } 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 534 550 foreach my $d (split(/,/,$tmpl)) { 535 551 my ($name,$ver,$arch) = split(/-/,$d); 536 552 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"); 539 556 pb_log(2,"DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n"); 540 557 … … 548 565 $build{"$ddir-$dver"} = "yes"; 549 566 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); 552 569 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$dfam") { 553 570 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$dfam",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); … … 563 580 564 581 # 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); 566 583 567 584 # Prepare patches for this distro 568 my @patches;569 570 585 foreach my $p (sort(<$ENV{'PBROOTDIR'}/$pbpkg/pbpatch/*>)) { 571 586 push @patches,$p if ($p =~ /\.all$/); 572 push @patches,$p if ($p =~ /\.$ dtype$/);587 push @patches,$p if ($p =~ /\.$pb{'dtype'}$/); 573 588 push @patches,$p if ($p =~ /\.$dfam$/); 574 589 push @patches,$p if ($p =~ /\.$ddir$/); 575 590 push @patches,$p if ($p =~ /\.$ddir-$dver$/); 576 591 } 592 $pb{'patches'} = \@patches; 577 593 578 594 # Apply now all the filters on all the files concerned … … 580 596 if (defined $ptr) { 581 597 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); 583 599 } 584 600 } … … 602 618 if (defined $filteredfiles->{$pbpkg}) { 603 619 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); 605 621 $liste = "$f $liste"; 606 622 } 607 623 } 608 624 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 } 609 633 610 634 # Prepare the dest directory for archive 611 635 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); 613 637 chmod 0755,"$ENV{'PBTMP'}/pbinit"; 614 638 pb_system("cd $dest ; $ENV{'PBTMP'}/pbinit","Executing init script from $ENV{'PBROOTDIR'}/$pbpkg/pbinit","verbose"); 615 }616 617 # Filter potential patches618 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'});621 639 } 622 640 … … 694 712 symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES"; 695 713 # 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"); 698 715 699 716 # We need to handle potential patches to upstream sources 717 my @patchfiles = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/pbpatch/","$ENV{'PBBUILDDIR'}/SOURCES"); 700 718 701 719 pb_log(2,"specfile: ".Dumper(\@specfile)."\n"); -
devel/pb/lib/ProjectBuilder/Filter.pm
r475 r499 119 119 } 120 120 121 =item B<pb_filter_file _pb>122 123 This function applies all filters to pb buildfiles.124 125 It takes 15 parameters. To be filtered a variable has to be passed to that function.121 =item B<pb_filter_file> 122 123 This function applies all filters to files. 124 125 It takes 4 parameters. 126 126 127 127 The first parameter is the file to filter. 128 128 The second parameter is the pointer on the hash of filters. 129 129 The third parameter is the destination file after filtering. 130 The fourth parameter is the distribution type. 131 The fifth parameter is the suffix of the distribution. 132 The sixth parameter is the package name. 133 The seventh parameter is the version of the package. 134 The eighth parameter is the tag of the package. 135 The nineth parameter is the revision of the package. 136 The tenth parameter is the current date. 137 The eleventh parameter is the list of required packages. 138 The twelveth parameter is the list of optional packages. 139 The thirteenth parameter is the packager name. 140 The fourteenth parameter is the changelog. 141 The fifteenth parameter is the project. 142 The sixteenth parameter is the repo. 143 144 =cut 145 146 sub pb_filter_file_pb { 130 The fourth parameter is the pointer on the hash of variables to filter (tag, ver, ...) 131 132 =cut 133 134 sub pb_filter_file { 147 135 148 136 my $f=shift; … … 150 138 my %filter=%$ptr; 151 139 my $destfile=shift; 152 my $dtype=shift; 153 my $pbsuf=shift; 154 my $pbpkg=shift; 155 my $pbver=shift; 156 my $pbtag=shift; 157 my $pbrev=shift; 158 my $pbdate=shift; 159 my $defpkgdir = shift; 160 my $extpkgdir = shift; 161 my $pbpackager = shift; 162 my $chglog = shift || undef; 163 my $pbproj = shift; 164 my $pbrepo = shift; 140 my $pb=shift; 141 my %pb = %$pb; 165 142 166 143 pb_log(2,"DEBUG: From $f to $destfile\n"); … … 182 159 # special case for ChangeLog only for pb 183 160 } elsif (($s =~ /^PBLOG$/) && ($line =~ /^PBLOG$/)) { 184 my $p = $defpkgdir->{$pbpkg}; 185 $p = $extpkgdir->{$pbpkg} if (not defined $p); 186 pb_changelog($dtype, $pbpkg, $pbver, $pbtag, $pbsuf, $p, \*DEST, $tmp, $chglog); 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'}); 164 $tmp = ""; 165 } elsif (($s =~ /^PBPATCHSRC$/) && ($line =~ /^PBPATCHSRC$/)) { 166 my $i = 0; 167 foreach my $p (sort @$pb{'patches'}) { 168 print DEST "Patch$i: $p\n"; 169 } 170 $tmp = ""; 171 } elsif (($s =~ /^PBPATCHCMD$/) && ($line =~ /^PBPATCHCMD$/)) { 172 my $i = 0; 173 foreach my $p (sort @$pb{'patches'}) { 174 print DEST "%patch$i\n"; 175 } 176 print DEST "\n"; 187 177 $tmp = ""; 188 178 } … … 199 189 This function applies all filters to a file in place. 200 190 201 It takes 9parameters.191 It takes 3 parameters. 202 192 203 193 The first parameter is the pointer on the hash of filters. 204 194 The second parameter is the destination file after filtering. 205 The third parameter is the package name. 206 The fourth parameter is the version of the package. 207 The fifth parameter is the tag of the package. 208 The sixth parameter is the revision of the package. 209 The seventh parameter is the current date. 210 The eighth parameter is the packager name. 211 The nineth parameter is the project name. 212 The tenth parameter is the repo. 195 The third parameter is the pointer on the hash of variables to filter (tag, ver, ...) 213 196 214 197 =cut … … 220 203 my %filter=%$ptr; 221 204 my $destfile=shift; 222 my $pbpkg=shift; 223 my $pbver=shift; 224 my $pbtag=shift; 225 my $pbrev=shift; 226 my $pbdate=shift; 227 my $pbpackager=shift; 228 my $pbproj=shift; 229 my $pbrepo = shift; 205 my $pb=shift; 206 my %pb = %$pb; 230 207 231 208 my $cp = "$ENV{'PBTMP'}/".basename($destfile); 232 209 copy($destfile,$cp) || die "Unable to create $cp"; 233 210 234 pb_filter_file($cp,$ptr,$destfile,$pb pkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager,$pbproj,$pbrepo);211 pb_filter_file($cp,$ptr,$destfile,$pb); 235 212 unlink $cp; 236 213 } 237 214 238 =item B<pb_filter_file>239 240 This function applies all filters on a file to generate a new filtered one.241 242 It takes 10 parameters. To be filtered a variable has to be passed to that function.243 244 The first parameter is the original file to filter.245 The second parameter is the pointer on the hash of filters.246 The third parameter is the destination file after filtering.247 The fourth parameter is the package name.248 The fifth parameter is the version of the package.249 The sixth parameter is the tag of the package.250 The seventh parameter is the revision of the package.251 The eighth parameter is the current date.252 The nineth parameter is the packager name.253 The tenth parameter is the project name.254 The eleventh parameter is the repo.255 256 =cut257 258 259 # Function which applies filter on files (external call)260 sub pb_filter_file {261 262 my $f=shift;263 my $ptr=shift;264 my %filter=%$ptr;265 my $destfile=shift;266 my $pbpkg=shift;267 my $pbver=shift;268 my $pbtag=shift;269 my $pbrev=shift;270 my $pbdate=shift;271 my $pbpackager=shift;272 my $pbproj=shift;273 my $pbrepo = shift;274 275 pb_log(2,"DEBUG: From $f to $destfile\n");276 pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));277 open(DEST,"> $destfile") || die "Unable to create $destfile";278 open(FILE,"$f") || die "Unable to open $f: $!";279 while (<FILE>) {280 my $line = $_;281 foreach my $s (keys %filter) {282 # Process single variables283 pb_log(2,"DEBUG filter{$s}: $filter{$s}\n");284 my $tmp = $filter{$s};285 next if (not defined $tmp);286 # Expand variables if any single one found287 if ($tmp =~ /\$/) {288 eval { $tmp =~ s/(\$\w+)/$1/eeg };289 eval { $tmp =~ s/(\$\/)/$1/eeg };290 }291 $line =~ s|$s|$tmp|g;292 }293 print DEST $line;294 }295 close(FILE);296 close(DEST);297 }298 215 299 216 =back
Note:
See TracChangeset
for help on using the changeset viewer.