| 1 |
#! /usr/bin/perl |
| 2 |
use warnings; |
| 3 |
use strict; |
| 4 |
use integer; |
| 5 |
use FindBin; |
| 6 |
use lib $FindBin::RealBin; |
| 7 |
use Def; |
| 8 |
|
| 9 |
# This helper script checks for different maintainers who claim the same |
| 10 |
# e-mail address. Because such different maintainers are probably |
| 11 |
# really the same maintainer, the script warns the developer to look |
| 12 |
# into the matter. Additionally, the script ensures that the std maint |
| 13 |
# names fit the proper format. (It does not check alphebetization, |
| 14 |
# though. See `sort-maint' for this.) |
| 15 |
# |
| 16 |
# usage: check-maint maint.txt Packages |
| 17 |
# |
| 18 |
# |
| 19 |
|
| 20 |
my $pat_mnstd = qr/^.{1,${Def::n_init}} .{1,${Def::n_last}}$/; |
| 21 |
my %mnlong; # long-form maintainer names |
| 22 |
my %mnstd ; # debram-standard short-form maintainer names |
| 23 |
my %addr ; # e-mail addresses |
| 24 |
|
| 25 |
@ARGV == 2 or die "usage: $0 maint.txt Packages\n"; |
| 26 |
my ( $maint_txt, $packages_file ) = @ARGV; |
| 27 |
|
| 28 |
# Read maint.txt. |
| 29 |
{ |
| 30 |
local $/ = ''; |
| 31 |
open MAINT_TXT, '<', $maint_txt |
| 32 |
or die "$0: cannot open maint file $maint_txt\n"; |
| 33 |
while ( <MAINT_TXT> ) { |
| 34 |
my @c = grep { /\S/ } split '\n'; |
| 35 |
my $mnstd = shift @c; |
| 36 |
$mnstd =~ $pat_mnstd or die "$0: bad std maint name $mnstd\n"; |
| 37 |
$mnstd{$mnstd} |
| 38 |
and die "$0: std maint name $mnstd given twice\n"; |
| 39 |
@c or die "$0: $mnstd has no full name\n"; |
| 40 |
for ( @c ) { |
| 41 |
defined $mnlong{$_} |
| 42 |
and die "$0: long maint name $_ given twice\n"; |
| 43 |
$mnlong{$_} = $mnstd; |
| 44 |
} |
| 45 |
$mnstd{$mnstd} = { mnlong => [ sort @c ], addr => {} }; |
| 46 |
} |
| 47 |
close MAINT_TXT; |
| 48 |
} |
| 49 |
|
| 50 |
# Read the e-mail addresses from the Packages file. |
| 51 |
{ |
| 52 |
open PACKAGES_FILE, '<', $packages_file |
| 53 |
or die "$0: cannot open Packages file $packages_file\n"; |
| 54 |
while ( <PACKAGES_FILE> ) { |
| 55 |
my( $mnlong, $addr ) = |
| 56 |
/^${Def::Maintainer}:[ \t]+([^<>]+?)[ \t]+<([^<>]+?)>/o |
| 57 |
or next; |
| 58 |
my $mnstd = $mnlong{$mnlong}; |
| 59 |
defined $mnstd or print( |
| 60 |
"unknown ${Def::Maintainer} $mnlong <$addr>\n\n" |
| 61 |
), next; |
| 62 |
$mnstd{$mnstd}{addr}{$addr} = 1; |
| 63 |
$addr{$addr}{$mnstd} = 1; |
| 64 |
} |
| 65 |
close PACKAGES_FILE; |
| 66 |
} |
| 67 |
|
| 68 |
# Report e-mail addresses claimed by multiple maintainers. |
| 69 |
my $exit = 0; |
| 70 |
for my $addr ( keys %addr ) { |
| 71 |
if ( scalar keys %{ $addr{$addr} } > 1 ) { |
| 72 |
print "$_ <$addr>\n" for keys %{ $addr{$addr} }; |
| 73 |
print "\n"; |
| 74 |
} |
| 75 |
} |
| 76 |
|