Skip to content

Commit

Permalink
Makefile.inc1: Make package timestamps reproducible by default
Browse files Browse the repository at this point in the history
Set package archive timestamps based on most recent source commit
timestamp (approach suggested by bapt).

I'd like to include git metadata in a file included in src tarballs, so
that the build is reproducible (including the hash shown in uname etc.)
outside of a git checkout.  There are still details to be sorted out to
do that, so this is an interim step to improve reproducibility.

Reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D49165
  • Loading branch information
emaste committed Feb 28, 2025
1 parent f2644d6 commit 8a3537a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile.inc1
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,12 @@ PKG_VERSION:= ${_PKG_REVISION}${EXTRA_REVISION:C/[[:space:]]//g}
.endif # !defined(PKG_VERSION)

.if !defined(PKG_TIMESTAMP)
.if !empty(GIT_CMD) && exists(${GIT_CMD}) && exists(${SRCDIR}/.git)
SOURCE_DATE_EPOCH!= ${GIT_CMD} -C ${SRCDIR} show -s --format=%ct HEAD
.else
TIMEEPOCHNOW= %s
SOURCE_DATE_EPOCH= ${TIMEEPOCHNOW:gmtime}
.endif
.else
SOURCE_DATE_EPOCH= ${PKG_TIMESTAMP}
.endif
Expand Down

0 comments on commit 8a3537a

Please sign in to comment.