Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] Makefile: Correctly take source date from commit date
@ 2018-03-28 12:26 James Byrne
  2018-03-30 19:28 ` Arnout Vandecappelle
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: James Byrne @ 2018-03-28 12:26 UTC (permalink / raw)
  To: buildroot

For reproducible builds SOURCE_DATE_EPOCH is supposed to be set to the
date of the last Buildroot commit if running from a git repository, but
this doesn't actually work. This corrects this in the following way:

1) Set GIT from BR2_GIT, otherwise it may be undefined.

2) Use 'git rev-parse --is-inside-work-tree' to see if we are inside a
Git repository. There is no need to use TOPDIR, because the current
directory will always be TOPDIR, and in any case the Git repository may
be at a higher directory level if Buildroot has been imported into a
larger build system.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
---
 Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 9e2402d..59af554 100644
--- a/Makefile
+++ b/Makefile
@@ -253,8 +253,10 @@ 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)
-export SOURCE_DATE_EPOCH ?= $(if $(wildcard $(TOPDIR)/.git),$(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
+GIT := $(call qstrip,$(BR2_GIT))
+BR2_IN_WORK_TREE = $(if $(subst false,,$(shell $(GIT) rev-parse --is-inside-work-tree 2> /dev/null || echo false)),Y,)
+BR2_VERSION_GIT_EPOCH = $(shell $(GIT) log -1 --format=%at)
+export SOURCE_DATE_EPOCH ?= $(if $(BR2_IN_WORK_TREE),$(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
 endif

 # To put more focus on warnings, be less verbose as default
--
2.7.4

The contents of this email and any attachment are confidential to the intended recipient(s). If you are not an intended recipient: (i) do not use, disclose, distribute, copy or publish this email or its contents; (ii) please contact the sender immediately; and (iii) delete this email. Origami Energy Limited (company number 8619644); Origami Storage Limited (company number 10436515) and OSSPV001 Limited (company number 10933403), each registered in England and each with a registered office at: Ashcombe Court, Woolsack Way, Godalming, GU7 1LQ.

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-04-09 19:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-28 12:26 [Buildroot] [PATCH 1/1] Makefile: Correctly take source date from commit date James Byrne
2018-03-30 19:28 ` Arnout Vandecappelle
2018-04-06 10:22   ` James Byrne
2018-04-01  6:23 ` Yann E. MORIN
2018-04-06 10:26 ` [Buildroot] [PATCH v2] Makefile: Avoid executing 'git log' each time SOURCE_DATE_EPOCH is used James Byrne
2018-04-07 14:33   ` Yann E. MORIN
2018-04-09 15:50     ` James Byrne
2018-04-09 16:47       ` Yann E. MORIN
2018-04-09 16:08   ` [Buildroot] [PATCH v3] " James Byrne
2018-04-09 16:35     ` Yann E. MORIN
2018-04-09 19:01     ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox