build: make it even more reproducible

* Makefile.am (today): Consistently print the UTC date in C locale.
* configure.ac (RPM_CHANGELOGTIME, DEB_CHANGELOGTIME): Likewise.
* maint/update_copyright_years.sh: Likewise.
* copyright-year-gen: Likewise.  When $SOURCE_DATE_EPOCH is non-empty,
use it as fallback date before the current system date.

References: https://github.com/strace/strace/pull/68
This commit is contained in:
Дмитрий Левин 2018-04-20 13:15:38 +00:00
parent 2e5167cc4f
commit fc8294cbc2
4 changed files with 16 additions and 8 deletions

View File

@ -992,7 +992,7 @@ dist-hook:
${AM_V_GEN}echo $(COPYRIGHT_YEAR) > $(distdir)/.year
${AM_V_GEN}echo $(MANPAGE_DATE) > $(distdir)/.strace.1.in.date
today = $(shell date +%Y-%m-%d)
today = $(shell LC_TIME=C date -u +%Y-%m-%d)
version_regexp = $(subst .,\.,$(VERSION))
news_check_regexp = 'Noteworthy changes in release $(version_regexp) ($(today))'

View File

@ -46,9 +46,9 @@ AM_INIT_AUTOMAKE([foreign nostdinc dist-xz silent-rules parallel-tests 1.13])
AM_MAINTAINER_MODE
AC_CANONICAL_HOST
RPM_CHANGELOGTIME="$(LC_TIME=C date '+%a %b %d %Y')"
RPM_CHANGELOGTIME="$(LC_TIME=C date -u '+%a %b %d %Y')"
AC_SUBST(RPM_CHANGELOGTIME)
DEB_CHANGELOGTIME="$(LC_TIME=C date -R)"
DEB_CHANGELOGTIME="$(LC_TIME=C date -u -R)"
AC_SUBST(DEB_CHANGELOGTIME)
AC_PROG_CC

View File

@ -2,6 +2,7 @@
: ${YEAR_FILE:=$1}
: ${DEFAULT_YEAR:=$2}
LC_TIME=C; export LC_TIME
year=
@ -13,11 +14,17 @@ year=
[ -f "${YEAR_FILE}" ] && year="$(cat "${YEAR_FILE}")"
[ -n "${year}" ] ||
year="$(date +%Y -d "$(git show --format=format:%cD --no-patch)")"
year="$(date -u +%Y -d "$(git show --format=format:%cD --no-patch)")"
[ -n "${year}" ] || year="${DEFAULT_YEAR}"
[ -n "${year}" ] ||
year="${DEFAULT_YEAR}"
[ -n "${year}" ] || year="$(date "+%Y")"
[ -n "${year}" ] ||
[ -z "${SOURCE_DATE_EPOCH-}" ] ||
year="$(date -u +%Y -d "@${SOURCE_DATE_EPOCH}")"
[ -n "${year}" ] ||
year="$(date -u +%Y)"
[ -n "${year}" ] || {
echo >&2 'Undefined year.'

View File

@ -40,6 +40,7 @@ Headers updated automatically with
: ${CALL_GIT_ADD=0}
: ${CALL_GIT_COMMIT=0}
: ${GIT_COMMIT_TEMPLATE=$DEFAULT_GIT_COMMIT_TEMPLATE}
LC_TIME=C; export LC_TIME
# These files are only imported into strace and not changed.
# Remove them from the list once they have been changed.
@ -121,9 +122,9 @@ process_file()
continue
fi
last_commit_year=$(date +%Y -d "$(git log -n1 --format=format:%aD \
last_commit_year=$(date -u +%Y -d "$(git log -n1 --format=format:%aD \
-- "$f")")
first_commit_year=$(date +%Y -d "$(git log --reverse --format=format:%aD \
first_commit_year=$(date -u +%Y -d "$(git log --reverse --format=format:%aD \
-- "$f" | head -n 1)")
copyright_year=$(printf '%s' "$copyright_year_raw" |
sort -r -n | head -n 1)