From dacd2d34b98aa151fc28e2ad57b476a3686416f1 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Thu, 8 Aug 2019 12:28:22 +0200 Subject: [PATCH] scripts/lib: Allow to override build date Allow to override build date with SOURCE_DATE_EPOCH in order to make builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. Also use UTC to be independent of timezone. This date call only works with GNU date. Without this patch, kata-containers-initrd.img contained varying var/lib/osbuilder/osbuilder.yaml with version: "1.9.0-alpha0" -rootfs-creation-time: "2019-08-06T18:40:27.402493939+0000Z" +rootfs-creation-time: "2034-09-08T07:57:34.386990704+0000Z" Fixes #340 Signed-off-by: Bernhard M. Wiedemann --- scripts/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index c4aa142350..0691563d94 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -170,7 +170,7 @@ create_summary_file() local -r filename="osbuilder.yaml" local file="${dir}/${filename}" - local -r now=$(date '+%Y-%m-%dT%T.%N%zZ') + local -r now=$(date -u -d@${SOURCE_DATE_EPOCH:-$(date +%s.%N)} '+%Y-%m-%dT%T.%N%zZ') # sanitise package lists PACKAGES=$(echo "$PACKAGES"|tr ' ' '\n'|sort -u|tr '\n' ' ')