Makefile: Make builds reproducible

Make builds reproducible by honoring SOURCE_DATE_EPOCH and USER
environment variables in the respective Makefiles. Just follow the
recommendations at https://reproducible-builds.org/

Build tools (e.g. Debian packaging, Yocto) use this to ensure reproducibility
of packages.

Tracked-On: #6035
Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
This commit is contained in:
Helmut Buchsbaum
2020-04-05 09:56:29 +02:00
committed by wenlingz
parent 3db4491e1c
commit 596f27bad3
4 changed files with 8 additions and 8 deletions

View File

@@ -66,8 +66,8 @@ $(VERSION_H):
@COMMIT=`git log -1 --pretty=format:%h . 2>/dev/null`;\
DIRTY=`git diff --name-only $(CURDIR)`;\
if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\
TIME=`date "+%Y-%m-%d %H:%M:%S"`;\
USER=`id -u -n`; \
TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%Y-%m-%d %H:%M:%S"); \
USER="$${USER:-$$(id -u -n)}"; \
cat $(CURDIR)/../license_header > $(VERSION_H);\
echo "#define AP_MAJOR_VERSION $(MAJOR_VERSION)" >> $(VERSION_H);\
echo "#define AP_MINOR_VERSION $(MINOR_VERSION)" >> $(VERSION_H);\

View File

@@ -45,8 +45,8 @@ $(VERSION_H):
@COMMIT=`git log -1 --pretty=format:%h . 2>/dev/null`;\
DIRTY=`git diff --name-only $(CURDIR)`;\
if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\
TIME=`date "+%Y-%m-%d %H:%M:%S"`;\
USER=`id -u -n`; \
TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%Y-%m-%d %H:%M:%S"); \
USER="$${USER:-$$(id -u -n)}"; \
cat $(CURDIR)/../license_header > $(VERSION_H);\
echo "#define UC_MAJOR_VERSION $(MAJOR_VERSION)" >> $(VERSION_H);\
echo "#define UC_MINOR_VERSION $(MINOR_VERSION)" >> $(VERSION_H);\