build: honor SOURCE_DATE_EPOCH for the build date; graceful git fallback
MAGIC_BUILDDATE now derives from SOURCE_DATE_EPOCH (UTC) when it is set,
falling back to the current local time otherwise. This makes the date baked
into buildinfo.o reproducible for the appimage/npm tarballs (cf. npm/pack.sh,
which already normalizes mtimes).
Also add `2>/dev/null` to the MAGIC_COMMIT git call so a source tarball or a
non-work-tree ${MAGICSRC} yields an empty commit rather than a git error.
Only buildinfo.o consumes these (see the prior commit), so the shell still
runs at defs.mak parse time but affects just that one unit's define.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b3d6540f13
commit
20911acc49
|
|
@ -121,8 +121,15 @@ TCL_LIB_DIR = @TCL_LIB_DIR@
|
|||
|
||||
MAGIC_VERSION ?= $(shell cat ${MAGICSRC}/VERSION | cut -d. -f1-2)
|
||||
MAGIC_REVISION ?= $(shell cat ${MAGICSRC}/VERSION | cut -d. -f3)
|
||||
MAGIC_COMMIT ?= $(shell git -C ${MAGICSRC} rev-parse HEAD)
|
||||
MAGIC_BUILDDATE ?= $(shell date | tr -d '\r\n')
|
||||
# git may be absent (source tarball) or ${MAGICSRC} not a work-tree: fall back to
|
||||
# empty rather than emitting an error.
|
||||
MAGIC_COMMIT ?= $(shell git -C ${MAGICSRC} rev-parse HEAD 2>/dev/null)
|
||||
# Honor SOURCE_DATE_EPOCH (reproducible builds -- appimage/npm tarballs) when set,
|
||||
# else the current time. UTC so the stamp does not depend on the builder's zone.
|
||||
MAGIC_BUILDDATE ?= $(shell if [ -n "$$SOURCE_DATE_EPOCH" ]; then \
|
||||
date -u -d "@$$SOURCE_DATE_EPOCH" 2>/dev/null \
|
||||
|| date -u -r "$$SOURCE_DATE_EPOCH" 2>/dev/null; \
|
||||
else date; fi | tr -d '\r\n')
|
||||
|
||||
# This allow inheritence of the values from toplevel Makefile
|
||||
export MAGIC_VERSION
|
||||
|
|
|
|||
Loading…
Reference in New Issue