xref: /freebsd/contrib/ntp/scripts/build/genAuthors.in (revision e27abb6689c5733dd08ce240d5402a0de3a42254)
1*e27abb66SXin LI#! @PATH_PERL@
2*e27abb66SXin LI
3*e27abb66SXin LI# DESCRIPTION
4*e27abb66SXin LI#
5*e27abb66SXin LI# Make sure we have the list of authors for git imports.
6*e27abb66SXin LI# Call with the path to the Authors/ subdirectory.
7*e27abb66SXin LI#
8*e27abb66SXin LI# AUTHOR
9*e27abb66SXin LI#
10*e27abb66SXin LI#  Harlan Stenn
11*e27abb66SXin LI#
12*e27abb66SXin LI# LICENSE
13*e27abb66SXin LI#
14*e27abb66SXin LI#  This file is Copyright (c) 2016 Network Time Foundation
15*e27abb66SXin LI#
16*e27abb66SXin LI#  Copying and distribution of this file, with or without modification, are
17*e27abb66SXin LI#  permitted in any medium without royalty provided the copyright notice,
18*e27abb66SXin LI#  author attribution and this notice are preserved.  This file is offered
19*e27abb66SXin LI#  as-is, without any warranty.
20*e27abb66SXin LI
21*e27abb66SXin LIuse strict;
22*e27abb66SXin LIuse warnings;
23*e27abb66SXin LI
24*e27abb66SXin LI# Read in the list of known authors.
25*e27abb66SXin LI# run:
26*e27abb66SXin LI#  bk changes -and:USER: | sort -u
27*e27abb66SXin LI# to get the list of users who have made commits.
28*e27abb66SXin LI# Make sure that each of these users is in the set of known authors.
29*e27abb66SXin LI# Make sure the format of that file is 1 or more lines of the form:
30*e27abb66SXin LI#  user = User Name <user@place>
31*e27abb66SXin LI#
32*e27abb66SXin LI# If all of the above is true, exit 0.
33*e27abb66SXin LI# If there are any problems, squawk and exit 1.
34*e27abb66SXin LI
35*e27abb66SXin LImy $bk_u = "bk changes -and:USER: | sort -u |";
36*e27abb66SXin LIchomp(my $bk_root = `bk root`);
37*e27abb66SXin LImy $A_path = "$bk_root/BitKeeper/etc/authors.txt";
38*e27abb66SXin LImy %authors;
39*e27abb66SXin LImy $problem = 0;
40*e27abb66SXin LI
41*e27abb66SXin LIdie "bkroot: <$bk_root>, A_path: <$A_path>\n" if (! -r $A_path);
42*e27abb66SXin LI
43*e27abb66SXin LI# Process the authors.txt file
44*e27abb66SXin LIopen(my $FILE, '<', $A_path) or die "Could not open <$A_path>: $!\n";
45*e27abb66SXin LIwhile (<$FILE>) {
46*e27abb66SXin LI  chomp;
47*e27abb66SXin LI  if (/^([\S]+) = ([\V]+) <([\w.-]+\@[\w.-]+)>$/) {
48*e27abb66SXin LI    # print "Got '$1 = $2 <$3>'\n";
49*e27abb66SXin LI    $authors{$1} = "";
50*e27abb66SXin LI  } else {
51*e27abb66SXin LI    print "In $A_path: unrecognized line: '$_'\n";
52*e27abb66SXin LI    $problem = 1;
53*e27abb66SXin LI  }
54*e27abb66SXin LI}
55*e27abb66SXin LIclose($FILE);
56*e27abb66SXin LI
57*e27abb66SXin LI#print "\%authors = ", join(' ', sort keys %authors), "\n";
58*e27abb66SXin LI
59*e27abb66SXin LIdie "Fix the problem(s) noted above!\n" if $problem;
60*e27abb66SXin LI
61*e27abb66SXin LI# Process "bk changes ..."
62*e27abb66SXin LI
63*e27abb66SXin LIopen(BKU, $bk_u) || die "$0: <$bk_u> failed: $!\n";
64*e27abb66SXin LIwhile (<BKU>) {
65*e27abb66SXin LI  chomp;
66*e27abb66SXin LI  my $Name = $_;
67*e27abb66SXin LI  my $name = lc;
68*e27abb66SXin LI  # print "Got Name <$Name>, name <$name>\n";
69*e27abb66SXin LI  if (!defined($authors{$Name})) {
70*e27abb66SXin LI    $problem = 1;
71*e27abb66SXin LI    print "<$Name> is not a defined author!\n";
72*e27abb66SXin LI    open(my $FILE, '>>', "$A_path/$name.txt") || die "Cannot create '$A_path/$name.txt': $!\n";
73*e27abb66SXin LI    print $FILE "$Name = \n";
74*e27abb66SXin LI    close($FILE);
75*e27abb66SXin LI  }
76*e27abb66SXin LI}
77*e27abb66SXin LI
78*e27abb66SXin LIdie "Fix the problem(s) noted above!\n" if $problem;
79*e27abb66SXin LI
80*e27abb66SXin LI# Local Variables:	**
81*e27abb66SXin LI# mode:cperl		**
82*e27abb66SXin LI# End:			**
83