[Buildroot] BR2_REPRODUCIBLE issues

Einar Jón Gunnarsson tolvupostur at gmail.com
Fri Nov 3 14:40:41 UTC 2017


Hello all.

I've been using BR2_REPRODUCIBLE, and it mostly works.

But when it is using a git repo, I have the following issues with creating
SOURCE_DATE_EPOCH:
1) It uses $(GIT), but the GIT variable is only defined in line 487:
"include package/Makefile.in".
Note that this is done around line 250 in $(TOPDIR)/Makefile, so sometimes
$(GIT) is unset then getting BR2_VERSION_GIT_EPOCH
2) It always uses the last git commit to calculate the date. So any commit
changes the timestamp, while the non-git timestamp stays the same.
This makes the whole thing almost useless.
If the git log command could take a parameter, you could make reproducible
builds based on e.g. tag 2017.08, which would be much more useful.

Regards,
Einar Jón

An idea for a patch made against origin/next - feel free to do whatever with
it.
if BR2_REPRODUCIBLE_CUSTOM_REPO_VERSION is empty, the behaviour is unchanged
from before.
Maybe setting the default value of BR2_REPRODUCIBLE_CUSTOM_REPO_VERSION to
the last major tag version might make sense.
------
>From ba5e36391f698946e6b5e02c4e7ab389f88f1373 Mon Sep 17 00:00:00 2001
From: Einar Jon Gunnarsson <tolvupostur at gmail.com>
Date: Fri, 3 Nov 2017 15:15:16 +0100
Subject: [PATCH] BR2_REPRODUCIBLE can use a custom git commit

---
 Config.in | 12 ++++++++++++
 Makefile  |  3 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Config.in b/Config.in
index e395995..faab671 100644
--- a/Config.in
+++ b/Config.in
@@ -726,6 +726,18 @@ config BR2_REPRODUCIBLE
          This is labeled as an experimental feature, as not all
          packages behave properly to ensure reproducibility.

+if BR2_REPRODUCIBLE
+
+config BR2_REPRODUCIBLE_CUSTOM_REPO_VERSION
+       string "Git version for reproducible builds"
+       help
+         Revision to use in the typical format used by Git
+         E.G. a sha id, a tag, branch, ..
+         Uses the last commit if empty.
+         Only useful if TOPDIR is a git repository.
+
+endif
+
 endmenu

 endmenu
diff --git a/Makefile b/Makefile
index 6d4aeca..a19d20e 100644
--- a/Makefile
+++ b/Makefile
@@ -253,7 +253,8 @@ export TZ = UTC
 export LANG = C
 export LC_ALL = C
 export GZIP = -n
-BR2_VERSION_GIT_EPOCH = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1
--format=%at)
+GIT := $(call qstrip,$(BR2_GIT))
+BR2_VERSION_GIT_EPOCH = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1
--format=%at $(BR2_REPRODUCIBLE_CUSTOM_REPO_VERSION))
 export SOURCE_DATE_EPOCH = $(if $(wildcard
$(TOPDIR)/.git),$(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
 DEPENDENCIES_HOST_PREREQ += host-fakedate
 endif
--
1.9.1



--
Sent from: http://buildroot-busybox.2317881.n4.nabble.com/


More information about the buildroot mailing list