From: Harlan Stenn Date: Tue, 5 Nov 2024 02:37:16 +0000 (-0800) Subject: Author attribution updates X-Git-Tag: NTP_4_3_106~4^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54373cc299bbd32bf4e2d943057ca5682d7e249e;p=thirdparty%2Fntp.git Author attribution updates bk: 672984dcSVp1OF2nuJ2BeOqYiXT_RQ --- diff --git a/Makefile.am b/Makefile.am index 2d5e61832..d155b89b6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index aef705394..9a8e7993a 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/scripts/build/Makefile.am b/scripts/build/Makefile.am index a165b1cd8..36236d0aa 100644 --- a/scripts/build/Makefile.am +++ b/scripts/build/Makefile.am @@ -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 = \ diff --git a/scripts/build/genAuthors.in b/scripts/build/genAuthors.in index a1b5a4023..2a7105fbe 100644 --- a/scripts/build/genAuthors.in +++ b/scripts/build/genAuthors.in @@ -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 # @@ -12,74 +18,70 @@ # # 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 -# -# 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 () { - 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