From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752856AbdHKKCs (ORCPT ); Fri, 11 Aug 2017 06:02:48 -0400 Received: from smtprelay0248.hostedemail.com ([216.40.44.248]:54575 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751932AbdHKKCq (ORCPT ); Fri, 11 Aug 2017 06:02:46 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:599:800:960:973:982:983:988:989:1208:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1543:1593:1594:1605:1711:1730:1747:1777:1792:2197:2199:2393:2559:2562:2828:2840:3138:3139:3140:3141:3142:3622:3653:3865:3866:3867:3868:3871:3872:3873:3874:4321:4362:4605:5007:6299:7903:7974:8957:9163:10004:10226:10400:10848:11026:11232:11658:11914:12043:12291:12296:12555:12683:12740:12760:12895:13439:14180:14181:14659:14721:21080:21221:21325:21451:21627:30054:30062:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: paste35_6f285dee37e58 X-Filterd-Recvd-Size: 4340 Message-ID: <1502445761.3099.8.camel@perches.com> Subject: Re: [PATCH] parse-maintainers: Add ability to specify filenames From: Joe Perches To: Linus Torvalds , linux-kernel@vger.kernel.org Cc: Andrew Morton Date: Fri, 11 Aug 2017 03:02:41 -0700 In-Reply-To: <48703c068b3235223ffa3b2eb268fa0a125b25e0.1502251549.git.joe@perches.com> References: <48703c068b3235223ffa3b2eb268fa0a125b25e0.1502251549.git.joe@perches.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2017-08-08 at 21:06 -0700, Joe Perches wrote: > parse-maintainers.pl is convenient, but currently hard-code the > filenames that are used. > > Allow user-specified filenames to simplify the use of the script. > > Miscellanea: > > o Change the file permissions to 755 to the script is executable Hey Linus. Andrew picked this up, but his quilt based tools to not keep the file permission change. Could you pick this up instead please? It could be useful if/when the MAINTAINERS file is split and when the individual files need to be realphabetized. Thanks. > Signed-off-by: Joe Perches > --- > scripts/parse-maintainers.pl | 52 +++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 47 insertions(+), 5 deletions(-) > mode change 100644 => 100755 scripts/parse-maintainers.pl > > diff --git a/scripts/parse-maintainers.pl b/scripts/parse-maintainers.pl > old mode 100644 > new mode 100755 > index e40b53db7f9f..4499cefce348 > --- a/scripts/parse-maintainers.pl > +++ b/scripts/parse-maintainers.pl > @@ -1,9 +1,44 @@ > #!/usr/bin/perl -w > > use strict; > +use Getopt::Long qw(:config no_auto_abbrev); > + > +my $input_file = "MAINTAINERS"; > +my $output_file = "MAINTAINERS.new"; > +my $output_section = "SECTION.new"; > +my $help = 0; > > my $P = $0; > > +if (!GetOptions( > + 'input=s' => \$input_file, > + 'output=s' => \$output_file, > + 'section=s' => \$output_section, > + 'h|help|usage' => \$help, > + )) { > + die "$P: invalid argument - use --help if necessary\n"; > +} > + > +if ($help != 0) { > + usage(); > + exit 0; > +} > + > +sub usage { > + print < +usage: $P [options] > + > + --input => MAINTAINERS file to read (default: MAINTAINERS) > + --output => sorted MAINTAINERS file to write (default: MAINTAINERS.new) > + --section => new sorted MAINTAINERS file to write to (default: SECTION.new) > + > +If exist, then the sections that match the > +regexes are not written to the output file but are written to the > +section file. > + > +EOT > +} > + > # sort comparison functions > sub by_category($$) { > my ($a, $b) = @_; > @@ -55,13 +90,20 @@ sub trim { > sub alpha_output { > my ($hashref, $filename) = (@_); > > + return if ! scalar(keys %$hashref); > + > open(my $file, '>', "$filename") or die "$P: $filename: open failed - $!\n"; > + my $separator; > foreach my $key (sort by_category keys %$hashref) { > if ($key eq " ") { > - chomp $$hashref{$key}; > print $file $$hashref{$key}; > } else { > - print $file "\n" . $key . "\n"; > + if (! defined $separator) { > + $separator = "\n"; > + } else { > + print $file $separator; > + } > + print $file $key . "\n"; > foreach my $pattern (sort by_pattern split('\n', %$hashref{$key})) { > print $file ($pattern . "\n"); > } > @@ -111,7 +153,7 @@ sub file_input { > my %hash; > my %new_hash; > > -file_input(\%hash, "MAINTAINERS"); > +file_input(\%hash, $input_file); > > foreach my $type (@ARGV) { > foreach my $key (keys %hash) { > @@ -122,7 +164,7 @@ foreach my $type (@ARGV) { > } > } > > -alpha_output(\%hash, "MAINTAINERS.new"); > -alpha_output(\%new_hash, "SECTION.new"); > +alpha_output(\%hash, $output_file); > +alpha_output(\%new_hash, $output_section); > > exit(0);