Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

parse-maintainers: add ability to specify filenames

parse-maintainers.pl is convenient, but currently hard-codes the
filenames that are used.

Allow user-specified filenames to simplify the use of the script.

Link: http://lkml.kernel.org/r/48703c068b3235223ffa3b2eb268fa0a125b25e0.1502251549.git.joe@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Joe Perches and committed by
Linus Torvalds
1e6270d0 aaf5dcfb

+47 -5
+47 -5
scripts/parse-maintainers.pl
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 4 use strict; 5 + use Getopt::Long qw(:config no_auto_abbrev); 6 + 7 + my $input_file = "MAINTAINERS"; 8 + my $output_file = "MAINTAINERS.new"; 9 + my $output_section = "SECTION.new"; 10 + my $help = 0; 5 11 6 12 my $P = $0; 13 + 14 + if (!GetOptions( 15 + 'input=s' => \$input_file, 16 + 'output=s' => \$output_file, 17 + 'section=s' => \$output_section, 18 + 'h|help|usage' => \$help, 19 + )) { 20 + die "$P: invalid argument - use --help if necessary\n"; 21 + } 22 + 23 + if ($help != 0) { 24 + usage(); 25 + exit 0; 26 + } 27 + 28 + sub usage { 29 + print <<EOT; 30 + usage: $P [options] <pattern matching regexes> 31 + 32 + --input => MAINTAINERS file to read (default: MAINTAINERS) 33 + --output => sorted MAINTAINERS file to write (default: MAINTAINERS.new) 34 + --section => new sorted MAINTAINERS file to write to (default: SECTION.new) 35 + 36 + If <pattern match regexes> exist, then the sections that match the 37 + regexes are not written to the output file but are written to the 38 + section file. 39 + 40 + EOT 41 + } 7 42 8 43 # sort comparison functions 9 44 sub by_category($$) { ··· 91 56 sub alpha_output { 92 57 my ($hashref, $filename) = (@_); 93 58 59 + return if ! scalar(keys %$hashref); 60 + 94 61 open(my $file, '>', "$filename") or die "$P: $filename: open failed - $!\n"; 62 + my $separator; 95 63 foreach my $key (sort by_category keys %$hashref) { 96 64 if ($key eq " ") { 97 - chomp $$hashref{$key}; 98 65 print $file $$hashref{$key}; 99 66 } else { 100 - print $file "\n" . $key . "\n"; 67 + if (! defined $separator) { 68 + $separator = "\n"; 69 + } else { 70 + print $file $separator; 71 + } 72 + print $file $key . "\n"; 101 73 foreach my $pattern (sort by_pattern split('\n', %$hashref{$key})) { 102 74 print $file ($pattern . "\n"); 103 75 } ··· 154 112 my %hash; 155 113 my %new_hash; 156 114 157 - file_input(\%hash, "MAINTAINERS"); 115 + file_input(\%hash, $input_file); 158 116 159 117 foreach my $type (@ARGV) { 160 118 foreach my $key (keys %hash) { ··· 165 123 } 166 124 } 167 125 168 - alpha_output(\%hash, "MAINTAINERS.new"); 169 - alpha_output(\%new_hash, "SECTION.new"); 126 + alpha_output(\%hash, $output_file); 127 + alpha_output(\%new_hash, $output_section); 170 128 171 129 exit(0);