aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/ntp/scripts/build/genAuthors.in
blob: f0e49c587e7c7a70e1099e212d546d9eee7221a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#! @PATH_PERL@

# DESCRIPTION
#
# Make sure we have the list of authors for git imports.
# Call with the path to the Authors/ subdirectory.
#
# AUTHOR
#
#  Harlan Stenn
#
# LICENSE
#
#  This file is Copyright (c) 2016 Network Time Foundation
#
#  Copying and distribution of this file, with or without modification, are
#  permitted in any medium without royalty provided the copyright notice,
#  author attribution and this notice are preserved.  This file is offered
#  as-is, without any warranty.

use strict;
use warnings;

# Read in the list of known authors.
# run:
#  bk changes -and:USER: | sort -u
# to get the list of users who have made commits.
# Make sure that each of these users is in the set of known authors.
# Make sure the format of that file is 1 or more lines of the form:
#  user = User Name <user@place>
#
# If all of the above is true, exit 0.
# If there are any problems, squawk and exit 1. 

my $bk_u = "bk changes -and:USER: | sort -u |";
chomp(my $bk_root = `bk root`);
my $A_path = "$bk_root/BitKeeper/etc/authors.txt";
my %authors;
my $problem = 0;

die "bkroot: <$bk_root>, A_path: <$A_path>\n" if (! -r $A_path);

# Process the authors.txt file
open(my $FILE, '<', $A_path) or die "Could not open <$A_path>: $!\n";
while (<$FILE>) {
  chomp;
  if (/^([\S]+) = ([\V]+) <([\w.-]+\@[\w.-]+)>$/) {
    # print "Got '$1 = $2 <$3>'\n";
    $authors{$1} = "";
  } else {
    print "In $A_path: unrecognized line: '$_'\n";
    $problem = 1;
  }
}
close($FILE);

#print "\%authors = ", join(' ', sort keys %authors), "\n";

die "Fix the problem(s) noted above!\n" if $problem;

# Process "bk changes ..."

open(BKU, $bk_u) || die "$0: <$bk_u> failed: $!\n";
while (<BKU>) {
  chomp;
  my $Name = $_;
  my $name = lc;
  # print "Got Name <$Name>, name <$name>\n";
  if (!defined($authors{$Name})) {
    $problem = 1;
    print "<$Name> is not a defined author!\n";
    open(my $FILE, '>>', "$A_path/$name.txt") || die "Cannot create '$A_path/$name.txt': $!\n";
    print $FILE "$Name = \n";
    close($FILE);
  }
}

die "Fix the problem(s) noted above!\n" if $problem;

# Local Variables:	**
# mode:cperl		**
# End:			**