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