build: Set DATE to SOURCE_DATE_EPOCH if available

Use the solution described in [1] to provide a wrapper to the 'date'
command that uses SOURCE_DATE_EPOCH if available.  This is needed for
reproducible builds.

The -d "@..." syntax was introduced in GNU date about 2005 (but only
added to the docuemntation in 2011), so I assume a version supporting
this syntax is available, if SOURCE_DATE_EPOCH is defined. If
SOURCE_DATE_EPOCH is not defined, nothing changes with respect to the
current behavior.

Update all users of 'date' in the tree to use the new wrapper.

[1] https://reproducible-builds.org/docs/source-date-epoch/

Signed-off-by: Maximilian Engelhardt <maxi@daemonizer.de>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
Maximilian Engelhardt authored and Andrew Cooper committed 2025-01-13 13:51:42 +00:00
1 parent 5dd85073d1
commit 8aaf5dc2c9
5 files changed
+23 -9

No files matched your search

+8
View File
@@ -141,6 +141,14 @@ export XEN_HAS_BUILD_ID=y
build_id_linker := --build-id=sha1
endif
# Wrap date(1) to use SOURCE_DATE_EPOCH if set the environment.
# See https://reproducible-builds.org/docs/source-date-epoch/
ifdef SOURCE_DATE_EPOCH
date = $(shell LC_ALL=C date -u -d "@$(SOURCE_DATE_EPOCH)" $(1) 2>/dev/null || LC_ALL=C date -u -r "$(SOURCE_DATE_EPOCH)" $(1) 2>/dev/null || LC_ALL=C date -u $(1))
else
date = $(shell LC_ALL=C date $(1))
endif
define buildmakevars2shellvars
export PREFIX="$(prefix)"; \
export XEN_SCRIPT_DIR="$(XEN_SCRIPT_DIR)"; \
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.