From c42880d994c3162efdd583d4a6097538cd185eb3 Mon Sep 17 00:00:00 2001 From: Casey Reeves Date: Thu, 19 Jan 2023 13:10:04 +0100 Subject: [PATCH] boot/barebox: pass required environment variables for reproducible build Barebox makes use of the same variables as the linux kernel does for handling reproducible build -- KBUILD_BUILD_HOST, KBUILD_BUILD_TIMESTAMP, KBUILD_BUILD_USER. This patch sets the proper variables based on linux/linux.mk, and passes them to the make invocation when building, to ensure a reproducible build is possible when BR2_REPRODUCIBLE is enabled. Signed-off-by: Casey Reeves Signed-off-by: Thomas Petazzoni (cherry picked from commit c90bd74ebb264ccc925f10a142ccd82ef63a4601) Signed-off-by: Peter Korsgaard --- boot/barebox/barebox.mk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/boot/barebox/barebox.mk b/boot/barebox/barebox.mk index 6506294d6d..05629bb4e3 100644 --- a/boot/barebox/barebox.mk +++ b/boot/barebox/barebox.mk @@ -74,6 +74,13 @@ endif $(1)_MAKE_FLAGS = ARCH=$$($(1)_ARCH) CROSS_COMPILE="$$(TARGET_CROSS)" $(1)_MAKE_ENV = $$(TARGET_MAKE_ENV) +ifeq ($(BR2_REPRODUCIBLE),y) +$(1)_MAKE_ENV += \ + KBUILD_BUILD_USER=buildroot \ + KBUILD_BUILD_HOST=buildroot \ + KBUILD_BUILD_TIMESTAMP="$(shell LC_ALL=C date -d @$(SOURCE_DATE_EPOCH))" +endif + ifeq ($$(BR2_TARGET_$(1)_USE_DEFCONFIG),y) $(1)_KCONFIG_DEFCONFIG = $$(call qstrip,$$(BR2_TARGET_$(1)_BOARD_DEFCONFIG))_defconfig else ifeq ($$(BR2_TARGET_$(1)_USE_CUSTOM_CONFIG),y) @@ -121,7 +128,7 @@ endef define $(1)_BUILD_CMDS $$($(1)_BUILD_BAREBOXENV_CMDS) - $$(TARGET_MAKE_ENV) $$(MAKE) $$($(1)_MAKE_FLAGS) -C $$(@D) + $$($(1)_MAKE_ENV) $$(MAKE) $$($(1)_MAKE_FLAGS) -C $$(@D) $$($(1)_BUILD_CUSTOM_ENV) endef