|
18 | 18 |
|
19 | 19 | use Getopt::Long qw(:config no_auto_abbrev); |
20 | 20 | use Cwd; |
| 21 | +use File::Find; |
21 | 22 |
|
22 | 23 | my $cur_path = fastgetcwd() . '/'; |
23 | 24 | my $lk_path = "./"; |
|
58 | 59 | my $pattern_depth = 0; |
59 | 60 | my $version = 0; |
60 | 61 | my $help = 0; |
| 62 | +my $find_maintainer_files = 0; |
61 | 63 |
|
62 | 64 | my $vcs_used = 0; |
63 | 65 |
|
|
249 | 251 | 'sections!' => \$sections, |
250 | 252 | 'fe|file-emails!' => \$file_emails, |
251 | 253 | 'f|file' => \$from_filename, |
| 254 | + 'find-maintainer-files' => \$find_maintainer_files, |
252 | 255 | 'v|version' => \$version, |
253 | 256 | 'h|help|usage' => \$help, |
254 | 257 | )) { |
|
307 | 310 |
|
308 | 311 | my @typevalue = (); |
309 | 312 | my %keyword_hash; |
| 313 | +my @mfiles = (); |
310 | 314 |
|
311 | | -open (my $maint, '<', "${lk_path}MAINTAINERS") |
312 | | - or die "$P: Can't open MAINTAINERS: $!\n"; |
313 | | -while (<$maint>) { |
314 | | - my $line = $_; |
315 | | - |
316 | | - if ($line =~ m/^([A-Z]):\s*(.*)/) { |
317 | | - my $type = $1; |
318 | | - my $value = $2; |
319 | | - |
320 | | - ##Filename pattern matching |
321 | | - if ($type eq "F" || $type eq "X") { |
322 | | - $value =~ s@\.@\\\.@g; ##Convert . to \. |
323 | | - $value =~ s/\*/\.\*/g; ##Convert * to .* |
324 | | - $value =~ s/\?/\./g; ##Convert ? to . |
325 | | - ##if pattern is a directory and it lacks a trailing slash, add one |
326 | | - if ((-d $value)) { |
327 | | - $value =~ s@([^/])$@$1/@; |
| 315 | +sub read_maintainer_file { |
| 316 | + my ($file) = @_; |
| 317 | + |
| 318 | + open (my $maint, '<', "$file") |
| 319 | + or die "$P: Can't open MAINTAINERS file '$file': $!\n"; |
| 320 | + while (<$maint>) { |
| 321 | + my $line = $_; |
| 322 | + |
| 323 | + if ($line =~ m/^([A-Z]):\s*(.*)/) { |
| 324 | + my $type = $1; |
| 325 | + my $value = $2; |
| 326 | + |
| 327 | + ##Filename pattern matching |
| 328 | + if ($type eq "F" || $type eq "X") { |
| 329 | + $value =~ s@\.@\\\.@g; ##Convert . to \. |
| 330 | + $value =~ s/\*/\.\*/g; ##Convert * to .* |
| 331 | + $value =~ s/\?/\./g; ##Convert ? to . |
| 332 | + ##if pattern is a directory and it lacks a trailing slash, add one |
| 333 | + if ((-d $value)) { |
| 334 | + $value =~ s@([^/])$@$1/@; |
| 335 | + } |
| 336 | + } elsif ($type eq "K") { |
| 337 | + $keyword_hash{@typevalue} = $value; |
328 | 338 | } |
329 | | - } elsif ($type eq "K") { |
330 | | - $keyword_hash{@typevalue} = $value; |
| 339 | + push(@typevalue, "$type:$value"); |
| 340 | + } elsif (!(/^\s*$/ || /^\s*\#/)) { |
| 341 | + $line =~ s/\n$//g; |
| 342 | + push(@typevalue, $line); |
331 | 343 | } |
332 | | - push(@typevalue, "$type:$value"); |
333 | | - } elsif (!/^(\s)*$/) { |
334 | | - $line =~ s/\n$//g; |
335 | | - push(@typevalue, $line); |
336 | 344 | } |
| 345 | + close($maint); |
| 346 | +} |
| 347 | + |
| 348 | +sub find_is_maintainer_file { |
| 349 | + my ($file) = $_; |
| 350 | + return if ($file !~ m@/MAINTAINERS$@); |
| 351 | + $file = $File::Find::name; |
| 352 | + return if (! -f $file); |
| 353 | + push(@mfiles, $file); |
337 | 354 | } |
338 | | -close($maint); |
339 | 355 |
|
| 356 | +sub find_ignore_git { |
| 357 | + return grep { $_ !~ /^\.git$/; } @_; |
| 358 | +} |
| 359 | + |
| 360 | +if (-d "${lk_path}MAINTAINERS") { |
| 361 | + opendir(DIR, "${lk_path}MAINTAINERS") or die $!; |
| 362 | + my @files = readdir(DIR); |
| 363 | + closedir(DIR); |
| 364 | + foreach my $file (@files) { |
| 365 | + push(@mfiles, "${lk_path}MAINTAINERS/$file") if ($file !~ /^\./); |
| 366 | + } |
| 367 | +} |
| 368 | + |
| 369 | +if ($find_maintainer_files) { |
| 370 | + find( { wanted => \&find_is_maintainer_file, |
| 371 | + preprocess => \&find_ignore_git, |
| 372 | + no_chdir => 1, |
| 373 | + }, "${lk_path}"); |
| 374 | +} else { |
| 375 | + push(@mfiles, "${lk_path}MAINTAINERS") if -f "${lk_path}MAINTAINERS"; |
| 376 | +} |
| 377 | + |
| 378 | +foreach my $file (@mfiles) { |
| 379 | + read_maintainer_file("$file"); |
| 380 | +} |
340 | 381 |
|
341 | 382 | # |
342 | 383 | # Read mail address map |
@@ -873,7 +914,7 @@ sub top_of_kernel_tree { |
873 | 914 | if ( (-f "${lk_path}COPYING") |
874 | 915 | && (-f "${lk_path}CREDITS") |
875 | 916 | && (-f "${lk_path}Kbuild") |
876 | | - && (-f "${lk_path}MAINTAINERS") |
| 917 | + && (-e "${lk_path}MAINTAINERS") |
877 | 918 | && (-f "${lk_path}Makefile") |
878 | 919 | && (-f "${lk_path}README") |
879 | 920 | && (-d "${lk_path}Documentation") |
|
0 commit comments