Skip to content

Commit

Permalink
build: make it even more reproducible
Browse files Browse the repository at this point in the history
* 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: #68
  • Loading branch information
ldv-alt committed Apr 20, 2018
1 parent 2e5167c commit fc8294c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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))'

Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions copyright-year-gen
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

: ${YEAR_FILE:=$1}
: ${DEFAULT_YEAR:=$2}
LC_TIME=C; export LC_TIME

year=

Expand All @@ -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}" ] ||
[ -z "${SOURCE_DATE_EPOCH-}" ] ||

This comment has been minimized.

Copy link
@lamby

lamby Apr 21, 2018

Did you mean:

- [ -z "${SOURCE_DATE_EPOCH-}" ] ||
+ [ -z "${SOURCE_DATE_EPOCH:-}" ] ||

This comment has been minimized.

Copy link
@ldv-alt

ldv-alt Apr 21, 2018

Author Member

"${SOURCE_DATE_EPOCH-}" and "${SOURCE_DATE_EPOCH:-}" always expand to the same value.

This comment has been minimized.

Copy link
@lamby

lamby Apr 21, 2018

TIL

This comment has been minimized.

year="$(date -u +%Y -d "@${SOURCE_DATE_EPOCH}")"

[ -n "${year}" ] || year="$(date "+%Y")"
[ -n "${year}" ] ||
year="$(date -u +%Y)"

[ -n "${year}" ] || {
echo >&2 'Undefined year.'
Expand Down
5 changes: 3 additions & 2 deletions maint/update_copyright_years.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fc8294c

Please sign in to comment.