From 9b92240af4a8f7a3050c13adec367cf48e9ce063 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 25 Jun 2025 14:16:03 -0700 Subject: [PATCH] mdate-sh: ignore $SOURCE_DATE_EPOCH (again). * lib/mdate-sh: pay no attention to SOURCE_DATE_EPOCH. The previous change (2025-05-15) was a misunderstanding; looking at SOURCE_DATE_EPOCH causes spurious makeinfo rebuilds: https://lists.gnu.org/archive/html/automake/2025-06/msg00021.html * t/mdate5.sh: remove check for this. * t/txinfo-vtexi4.sh: likewise. * doc/automake.texi (Texinfo): remove mention of this. * NEWS: update. --- NEWS | 6 +++-- doc/automake.texi | 17 ++------------ lib/mdate-sh | 55 +--------------------------------------------- t/mdate5.sh | 23 +++---------------- t/txinfo-vtexi4.sh | 20 +++++------------ 5 files changed, 15 insertions(+), 106 deletions(-) diff --git a/NEWS b/NEWS index 35c36a7fe..201f3995c 100644 --- a/NEWS +++ b/NEWS @@ -5,8 +5,10 @@ please see NEWS-future and start following the advice there now. - Improve debuggability of installcheck failures. (bug#78850) - - Keep Automake tests working when SOURCE_DATE_EPOCH is set. - (https://lists.gnu.org/archive/html/automake/2025-06/msg00016.html) + - Undo change to mdate-sh; once again, it does not look at + SOURCE_DATE_EPOCH. This change was a misunderstanding that causes + problems, not fixes, for reproducible builds. + (https://lists.gnu.org/archive/html/automake/2025-06/msg00021.html) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New in 1.18 (2025-05-25): diff --git a/doc/automake.texi b/doc/automake.texi index 76656babe..83599a722 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -8339,7 +8339,6 @@ Texinfo flags you can reference using @code{@@value@{EDITION@}}, @code{@@value@{VERSION@}}, @code{@@value@{UPDATED@}}, and @code{@@value@{UPDATED-MONTH@}}. -@vindex SOURCE_DATE_EPOCH@r{, and @command{mdate-sh}} @table @code @item EDITION @itemx VERSION @@ -8347,12 +8346,11 @@ Both of these flags hold the version number of your program. They are kept separate for historical reasons. @item UPDATED -This holds the date the primary @file{.texi} file was last modified, -or the date of the @env{SOURCE_DATE_EPOCH} variable (see below). +This holds the date the primary @file{.texi} file was last modified. @item UPDATED-MONTH This holds the name of the month in which the primary @file{.texi} file -was last modified, or the month of @env{SOURCE_DATE_EPOCH}. +was last modified. @end table The @file{version.texi} support requires the @command{mdate-sh} @@ -8360,17 +8358,6 @@ script; this script is supplied with Automake and automatically included when @command{automake} is invoked with the @option{--add-missing} option. -@cindex reproducible builds -@cindex epoch, and reproducible builds -If the @env{SOURCE_DATE_EPOCH} environment variable is set, -@command{mdate-sh} uses its value, instead of the modification time of -any file. This variable is typically set globally for the sake of -creating a reproducible build across a distribution. Its value is an -integer, the number of seconds since the Unix epoch (January 1, 1970, -00:00:00 UTC). If for any reason the @env{SOURCE_DATE_EPOCH} value -cannot be converted into the human-readable date strings, -@command{mdate-sh} falls back to using the given file's mtime. - If you have multiple Texinfo files, and you want to use the @file{version.texi} feature, then you have to have a separate version file for each Texinfo file. Automake will treat any include in a diff --git a/lib/mdate-sh b/lib/mdate-sh index e87d92873..22396e406 100755 --- a/lib/mdate-sh +++ b/lib/mdate-sh @@ -2,7 +2,7 @@ # Get modification time of a file or directory, or value of # $SOURCE_DATE_EPOCH, and pretty-print it, formatted like 1 January 2000. -scriptversion=2025-06-18.21; # UTC +scriptversion=2025-06-25.21; # UTC # Copyright (C) 1995-2025 Free Software Foundation, Inc. # written by Ulrich Drepper , June 1995 @@ -50,10 +50,6 @@ Usage: mdate-sh [--help] [--version] FILE Pretty-print the modification day of FILE, in the format: 1 January 1970 -If the environment variable SOURCE_DATE_EPOCH is set, use its value (in -epoch-seconds) for the date instead of any FILE mtime. The FILE -argument is still required in this case, but ignored. - Report bugs to . GNU Automake home page: . General help using GNU software: . @@ -108,55 +104,6 @@ export LC_TIME TZ=UTC0 export TZ -# -# https://reproducible-builds.org/docs/source-date-epoch/ -if test -n "$SOURCE_DATE_EPOCH"; then - epoch_ok=true # be optimistic - date_fmt="+%d %B %Y" - result=`date -u --date="@$SOURCE_DATE_EPOCH" "$date_fmt" 2>/dev/null` - if test -z "$result"; then - result=`date -u -r "$SOURCE_DATE_EPOCH" "$date_fmt" 2>/dev/null` - if test -z "$result"; then - # The date command on Solaris 10 and 11 doesn't support any way - # to do this. Fall back to Perl. - # - perlout=`perl -e 'print scalar gmtime($SOURCE_DATE_EPOCH)' 2>/dev/null` - # Output is, e.g., Thu Jan 1 00:00:00 1970. Split it apart, - # since we need to convert "Jan" to "January". - # (We could use cut, but surely if a system has perl, it has awk?) - day=`echo $perlout | awk '{print $3}'` - mon=`echo $perlout | awk '{print $2}'` - mon_to_month $mon # sets $month - year=`echo $perlout | awk '{print $5}'` - result="$day $month $year" - # - if test -z "$result"; then - echo "$0: warning: SOURCE_DATE_EPOCH was set, but can't convert, ignoring: $SOURCE_DATE_EPOCH" >&2 - epoch_ok=false - fi - fi - fi - # - if $epoch_ok; then - # Remove leading spaces and zeros. We don't want to get into the - # various date options to control this. (Not quoting $result here - # isn't important, just another way to omit leading spaces.) - result=`echo $result | sed 's/^[ 0]*//'` - if test -z "$result"; then - echo "$0: SOURCE_DATE_EPOCH was set, but converted to empty: $SOURCE_DATE_EPOCH" >&2 - epoch_ok=false - fi - fi - if $epoch_ok; then - echo $result - exit 0 - else - echo "$0: SOURCE_DATE_EPOCH failed, falling back to using mtime on: $1" >&2 - fi -fi -# end of SOURCE_DATE_EPOCH support, rest is about the normal case of -# using the mtime of the specified file. - # # GNU ls changes its time format in response to the TIME_STYLE # variable. Since we cannot assume 'unset' works, revert this diff --git a/t/mdate5.sh b/t/mdate5.sh index 14c524e9b..5849c4094 100644 --- a/t/mdate5.sh +++ b/t/mdate5.sh @@ -30,7 +30,7 @@ test $# = 3 case $1$3 in *[!0-9]*) exit 1;; esac test $1 -lt 32 case $3 in - 19[0-9][0-9]) :;; # for old SOURCE_DATE_EPOCH. + 19[0-9][0-9]) :;; # just in case. 20[0-9][0-9]) :;; # Hopefully automake will be obsolete in 80 years ;-) *) exit 1;; esac @@ -40,26 +40,9 @@ case $2 in *) exit 1 esac -# Stricter checks on the year required a POSIX date(1) command, -# and that SOURCE_DATE_EPOCH is not set. -if year=$(date +%Y) \ - && test -z "$SOURCE_DATE_EPOCH" \ - && test $year -gt 2010; then +# Stricter checks on the year require a POSIX date(1) command. +if year=$(date +%Y) && test $year -gt 2010; then test $year = $3 || exit 1 fi -# -# Also check that mdate-sh respects SOURCE_DATE_EPOCH. -SOURCE_DATE_EPOCH=123456 # into January 2, 1970, for no particular reason. -export SOURCE_DATE_EPOCH -set x $(./mdate-sh mdate-sh) -shift -echo "$*" # For debugging. - -# Check that mdate output is the expected day (1 January 1970): -test $# = 3 -test x$1 = x2 -test x$2 = xJanuary -test x$3 = x1970 - : diff --git a/t/txinfo-vtexi4.sh b/t/txinfo-vtexi4.sh index a69cc46f2..cb9b4414b 100644 --- a/t/txinfo-vtexi4.sh +++ b/t/txinfo-vtexi4.sh @@ -28,21 +28,11 @@ required='makeinfo tex texi2dvi grep-nonprint' # differ depending on local time. TZ=UTC0; export TZ -if test -n "$SOURCE_DATE_EPOCH"; then - # use mdate-sh to parse SOURCE_DATE_EPOCH. - get_shell_script mdate-sh - result=`mdate-sh /irrelevant` - echo "result of mdate-sh: $result" - day=`echo $result | awk '{print $1}'` - month=`echo $result | awk '{print $2}'` - year=`echo $result | awk '{print $3}'` -else - test $(LC_ALL=C date '+%u') -gt 0 && test $(LC_ALL=C date '+%u') -lt 8 \ - && day=$(LC_ALL=C date '+%d') && test -n "$day" \ - && month=$(LC_ALL=C date '+%B') && test -n "$month" \ - && year=$(LC_ALL=C date '+%Y') && test -n "$year" \ - || skip_ "'date' is not POSIX-compliant enough" -fi +test $(LC_ALL=C date '+%u') -gt 0 && test $(LC_ALL=C date '+%u') -lt 8 \ + && day=$(LC_ALL=C date '+%d') && test -n "$day" \ + && month=$(LC_ALL=C date '+%B') && test -n "$month" \ + && year=$(LC_ALL=C date '+%Y') && test -n "$year" \ + || skip_ "'date' is not POSIX-compliant enough" # day=$(echo "$day" | sed 's/^0//') -- 2.47.3