Changeset 499 in ProjectBuilder for devel/pb/lib/ProjectBuilder/Filter.pm
- Timestamp:
- Jul 30, 2008, 5:58:00 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.