]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Author attribution updates
authorHarlan Stenn <stenn@ntp.org>
Tue, 5 Nov 2024 02:37:16 +0000 (18:37 -0800)
committerHarlan Stenn <stenn@ntp.org>
Tue, 5 Nov 2024 02:37:16 +0000 (18:37 -0800)
bk: 672984dcSVp1OF2nuJ2BeOqYiXT_RQ

Makefile.am
configure.ac
scripts/build/Makefile.am
scripts/build/genAuthors.in

index 2d5e6183261fa7dc0361a9fbe54103c15af4da51..d155b89b6da0dd2201f61cf028a387d794d88dca 100644 (file)
@@ -156,6 +156,9 @@ BHOST=`(hostname || uname -n)`
                echo " "; \
        fi
 
+check-local:
+       bk version > /dev/null 2>&1 && scripts/build/checkAuthors $(top_srcdir)/BitKeeper/etc/authors.txt $(top_srcdir)/BitKeeper/etc/Authors
+
 FRC.CommitLog FRC.checkcvo FRC.checkhost FRC.distwarn FRC.html FRC.sntp:
        @: do-nothing action prevents any default
 
index aef705394309a1e5e650ac50d5e4adc9c9ada884..9a8e7993a58a2a366761e0ca73d840887674c95c 100644 (file)
@@ -4461,6 +4461,7 @@ AC_CONFIG_FILES([ntpsnmpd/Makefile])
 AC_CONFIG_FILES([parseutil/Makefile])
 AC_CONFIG_FILES([scripts/Makefile])
 AC_CONFIG_FILES([scripts/build/Makefile])
+AC_CONFIG_FILES([scripts/build/checkAuthors],  [chmod +x scripts/build/checkAuthors])
 AC_CONFIG_FILES([scripts/build/genAuthors],    [chmod +x scripts/build/genAuthors])
 AC_CONFIG_FILES([scripts/build/mkver], [chmod +x scripts/build/mkver])
 AC_CONFIG_FILES([scripts/calc_tickadj/Makefile])
index a165b1cd88f327ae584cb47180aa99cc80f3c8a3..36236d0aaea7242cdaacf97dab1ca3cf7662cc87 100644 (file)
@@ -1,7 +1,7 @@
 run_ag=                cd $(srcdir) && env PATH="$(abs_builddir):$(PATH)" AUTOGEN_DNE_DATE=-D  \
                autogen -L ../sntp/include -L ../sntp/ag-tpl
 
-noinst_SCRIPTS = genAuthors mkver
+noinst_SCRIPTS = checkAuthors genAuthors mkver
 
 NULL=
 EXTRA_DIST =                   \
index a1b5a4023acd61c9ff8b7f38504f3dc519a3b0f9..2a7105fbe1c8c9bc9bb5f7c2a0cda8b8706d5d3f 100644 (file)
@@ -1,10 +1,16 @@
-#! @PATH_PERL@
+#! /bin/sh
 # @configure_input@
 
 # DESCRIPTION
 #
-# Make sure we have the list of authors for git imports.
+# Generate an authors.txt file.  If the generated file is different
+# from any existing copy, install it.
 # Call with the path to the Authors/ subdirectory.
+# - Why?  We know where it has to live...
+# We might want either the path to checkAuthors or insist that
+# checkAuthors is in the PATH (which is kinda horrible).
+# Remember that genAuthors and checkAuthors are generated scripts
+# that are not installed, so they're in the build tree.
 #
 # AUTHOR
 #
 #
 # LICENSE
 #
-#  This file is Copyright (c) 2016 Network Time Foundation
+#  This file is Copyright (c) 2024 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;
+CA="@abs_builddir@/checkAuthors"
 
-# 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. 
+case "$#" in
+ 0) ;;
+ *) echo "Usage: $0"
+    exit 1
+    ;;
+esac
+
+echo "CA is <$CA>"
 
-my $bk_u = "bk changes -and:USER: | sort -u |";
-chomp(my $bk_root = `bk root`);
-my $A_dir = "$bk_root/BitKeeper/etc/Authors";
-my $A_file = "$bk_root/BitKeeper/etc/authors.txt";
-my %authors;
-my $problem = 0;
+if ! test -x $CA
+then
+    echo "$CA does not point to an executable checkAuthors script!"
+    echo "Usage: $0 path/to/checkAuthors"
+    exit 1
+fi
 
-die "bkroot: <$bk_root>, A_dir: <$A_dir>\n" if (! -r $A_dir);
-die "bkroot: <$bk_root>, A_file: <$A_file>\n" if (! -r $A_file);
+set -e
+set -x
 
-# Process the authors.txt file
-open(my $FILE, '<', $A_file) or die "Could not open <$A_file>: $!\n";
-while (<$FILE>) {
-  chomp;
-  if (/^([\S]+) = ([\V]+) <([\w.-]+\@[\w.-]+)>$/) {
-    # print "Got '$1 = $2 <$3>'\n";
-    $authors{$1} = "";
-  } else {
-    print "In $A_file: unrecognized line: '$_'\n";
-    $problem = 1;
-  }
-}
-close($FILE);
+# If we don't have bk, just exit.
 
-#print "\%authors = ", join(' ', sort keys %authors), "\n";
+bk version > /dev/null 2>&1 || exit 0
 
-die "Fix the problem(s) noted above!\n" if $problem;
+# Make sure we're in the correct directory
+# We might not need to 'cd' at all, and we can expect
+# authors.txt to live in $1/../authors.txt.
+# But we still might want to CD there so we can 'bk get'.
 
-# Process "bk changes ..."
+cd `bk root`/BitKeeper/etc
 
-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_dir/$name.txt") || die "Cannot create '$A_dir/$name.txt': $!\n";
-    print $FILE "$Name = \n";
-    close($FILE);
-  }
-}
+# Note the following will likely be checked out read-only
+bk get -q Authors || true
+bk get -q authors.txt || true
 
-die "Fix the problem(s) noted above!\n" if $problem;
+cat Authors/*.txt > authors.txt+
 
-# Local Variables:     **
-# mode:cperl           **
-# End:                 **
+if ! $CA authors.txt+ Authors
+then
+    echo "Fix the described errors and try again."
+    exit 1
+fi
+    
+if ! cmp -s authors.txt authors.txt+
+then
+    if bk pending -q
+    then
+       bk edit authors.txt
+       mv -f authors.txt authors.txt-
+       mv authors.txt+ authors.txt
+       bk ci -y'Updated authors.txt' authors.txt
+       bk commit -y'Updated authors.txt'
+    else
+       echo "An updated authors.txt is ready to check in but there are pending commits!"
+       echo "Commit all pending changes before updating the authors.txt file!"
+       exit 1
+else
+    rm -f authors.txt+
+fi