From 693d2409711fa91d73898e0681fd5068a8b7fdb0 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Tue, 12 Mar 2019 14:28:17 +0100 Subject: [PATCH] Override build user+host+timestamp to make kata-linux-container package builds reproducible. See https://reproducible-builds.org/ for why this is good. Uses -u to be independent of timezone. Uses LANG=C to not have Day-of-Week and Month names vary. Signed-off-by: Bernhard M. Wiedemann --- obs-packaging/linux-container/debian.rules | 5 +++++ .../linux-container/kata-linux-container.spec-template | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/obs-packaging/linux-container/debian.rules b/obs-packaging/linux-container/debian.rules index 8f6b1941ec..42545c1c13 100755 --- a/obs-packaging/linux-container/debian.rules +++ b/obs-packaging/linux-container/debian.rules @@ -18,6 +18,11 @@ override_dh_auto_build: rm -f .config find $(KERNEL_CONFIGS) -name "$(KERNEL_ARCH)_kata_kvm_*" -exec cp {} .config \; [ -f .config ] || (@echo "ERROR: cannot find the kernel config file for the $(KERNEL_ARCH) architecture"; exit 1) + # https://github.com/kata-containers/packaging/issues/394 enable reproducible builds: + export KBUILD_BUILD_USER=katabuilduser + export KBUILD_BUILD_HOST=katabuildhost + # Default to zero seconds after midnight 1970-01-01 (the epoch) + export KBUILD_BUILD_TIMESTAMP="$(LANG=C date -u -d "@${SOURCE_DATE_EPOCH:-0}")" make -s ARCH=$(KERNEL_ARCH) oldconfig > /dev/null make -s CONFIG_DEBUG_SECTION_MISMATCH=y ARCH=$(KERNEL_ARCH) diff --git a/obs-packaging/linux-container/kata-linux-container.spec-template b/obs-packaging/linux-container/kata-linux-container.spec-template index 22af171750..97d3546690 100644 --- a/obs-packaging/linux-container/kata-linux-container.spec-template +++ b/obs-packaging/linux-container/kata-linux-container.spec-template @@ -87,6 +87,11 @@ BuildKernel() { export CFLAGS="-Wno-error=restrict" export EXTRA_CFLAGS="-Wno-format-truncation -Wno-cast-function-type -Wno-error=restrict -Wno-error" %endif + # https://github.com/kata-containers/packaging/issues/394 enable reproducible builds: + export KBUILD_BUILD_USER=katabuilduser + export KBUILD_BUILD_HOST=katabuildhost + # Default to zero seconds after midnight 1970-01-01 (the epoch) + export KBUILD_BUILD_TIMESTAMP="$(LANG=C date -u -d "@${SOURCE_DATE_EPOCH:-0}")" make -s ARCH=$kernelArch oldconfig > /dev/null make -s CONFIG_DEBUG_SECTION_MISMATCH=y %{?_smp_mflags} ARCH=$kernelArch %{?sparse_mflags} || exit 1