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