diff mbox

[v2,01/15] reproducibility: generate SOURCE_DATE_EPOCH

Message ID 1479460224-6119-2-git-send-email-jezz@sysmic.org
State Superseded
Headers show

Commit Message

Jérôme Pouiller Nov. 18, 2016, 9:10 a.m. UTC
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>

When reproducibility is requested, generate a global SOURCE_DATE_EPOCH
environment variable which contains either the date of Buildroot last
commit if running from a git repository, or the latest release date.

This means that all packages embedding build dates will appear to
have the same build date, so in case of new commit or release, all
packages will appear to have been change, even though some of them
may not have changed in fact.

The meaning of SOURCE_DATE_EPOCH is specified by the following
specification:
  https://reproducible-builds.org/specs/source-date-epoch/

Signed-off-by: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Signed-off-by: Jérôme Pouiller <jezz@sysmic.org>
---
 Makefile | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Thomas Petazzoni Nov. 18, 2016, 11:33 a.m. UTC | #1
Hello,

On Fri, 18 Nov 2016 10:10:10 +0100, Jérôme Pouiller wrote:

> diff --git a/Makefile b/Makefile
> index eff814b..17e49e4 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -249,6 +249,10 @@ ifeq ($(BR2_REPRODUCIBLE),y)
>  export TZ=UTC
>  export LANG=C
>  export LC_ALL=C
> +export SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)

Why do you do this instead of just doing

export SOURCE_DATE_EPOCH = $(if $(wildcard $(TOPDIR)/.git),$(SOURCE_DATE_GIT),$(SOURCE_DATE_CHANGES))

> +SOURCE_DATE_GIT = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1 --format=%at)
> +SOURCE_DATE_CHANGES = $(shell date -d `echo $(BR2_VERSION) | sed 's/^\(....\)\.\(..\).*/\1-\2-01T23:59:59/'` +%s)

Why don't we change the way BR2_VERSION is defined in order to avoid having to do this?

BR2_VERSION_DATE = 2016.11
BR2_VERSION = $(BR2_VERSION)-rc1

for example.

Thanks,

Thomas
Jérôme Pouiller Nov. 18, 2016, 1:48 p.m. UTC | #2
On 2016-11-18 12:33, Thomas Petazzoni wrote:
> Hello,
> 
> On Fri, 18 Nov 2016 10:10:10 +0100, Jérôme Pouiller wrote:
> 
>> diff --git a/Makefile b/Makefile
>> index eff814b..17e49e4 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -249,6 +249,10 @@ ifeq ($(BR2_REPRODUCIBLE),y)
>>  export TZ=UTC
>>  export LANG=C
>>  export LC_ALL=C
>> +export SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)
> 
> Why do you do this instead of just doing
> 
> export SOURCE_DATE_EPOCH = $(if $(wildcard
> $(TOPDIR)/.git),$(SOURCE_DATE_GIT),$(SOURCE_DATE_CHANGES))

I wanted keep all exported variables together, but ok.


>> +SOURCE_DATE_GIT = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1 
>> --format=%at)
>> +SOURCE_DATE_CHANGES = $(shell date -d `echo $(BR2_VERSION) | sed 
>> 's/^\(....\)\.\(..\).*/\1-\2-01T23:59:59/'` +%s)
> 
> Why don't we change the way BR2_VERSION is defined in order to avoid
> having to do this?
> 
> BR2_VERSION_DATE = 2016.11
> BR2_VERSION = $(BR2_VERSION)-rc1
> 
> for example.

OK
Arnout Vandecappelle Nov. 19, 2016, 8:40 a.m. UTC | #3
In addition to Thomas's comments:

On 18-11-16 10:10, Jérôme Pouiller wrote:
> From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> 
> When reproducibility is requested, generate a global SOURCE_DATE_EPOCH
> environment variable which contains either the date of Buildroot last
> commit if running from a git repository, or the latest release date.
> 
> This means that all packages embedding build dates will appear to
> have the same build date, so in case of new commit or release, all
> packages will appear to have been change, even though some of them
                                    changed


 Regards,
 Arnout

> may not have changed in fact.
> 
> The meaning of SOURCE_DATE_EPOCH is specified by the following
> specification:
>   https://reproducible-builds.org/specs/source-date-epoch/
> 
> Signed-off-by: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> Signed-off-by: Jérôme Pouiller <jezz@sysmic.org>
> ---
>  Makefile | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index eff814b..17e49e4 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -249,6 +249,10 @@ ifeq ($(BR2_REPRODUCIBLE),y)
>  export TZ=UTC
>  export LANG=C
>  export LC_ALL=C
> +export SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)
> +SOURCE_DATE_GIT = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1 --format=%at)
> +SOURCE_DATE_CHANGES = $(shell date -d `echo $(BR2_VERSION) | sed 's/^\(....\)\.\(..\).*/\1-\2-01T23:59:59/'` +%s)
> +SOURCE_DATE_EPOCH = $(if $(wildcard $(TOPDIR)/.git),$(SOURCE_DATE_GIT),$(SOURCE_DATE_CHANGES))
>  endif
>  
>  # To put more focus on warnings, be less verbose as default
>
Arnout Vandecappelle Nov. 19, 2016, 8:51 a.m. UTC | #4
On 18-11-16 12:33, Thomas Petazzoni wrote:
> Hello,
> 
> On Fri, 18 Nov 2016 10:10:10 +0100, Jérôme Pouiller wrote:
> 
>> diff --git a/Makefile b/Makefile
>> index eff814b..17e49e4 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -249,6 +249,10 @@ ifeq ($(BR2_REPRODUCIBLE),y)
>>  export TZ=UTC
>>  export LANG=C
>>  export LC_ALL=C
>> +export SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)
> 
> Why do you do this instead of just doing
> 
> export SOURCE_DATE_EPOCH = $(if $(wildcard $(TOPDIR)/.git),$(SOURCE_DATE_GIT),$(SOURCE_DATE_CHANGES))
> 
>> +SOURCE_DATE_GIT = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1 --format=%at)
>> +SOURCE_DATE_CHANGES = $(shell date -d `echo $(BR2_VERSION) | sed 's/^\(....\)\.\(..\).*/\1-\2-01T23:59:59/'` +%s)
> 
> Why don't we change the way BR2_VERSION is defined in order to avoid having to do this?
> 
> BR2_VERSION_DATE = 2016.11
> BR2_VERSION = $(BR2_VERSION)-rc1

 Or maybe even easier:

BR2_VERSION = 2016.11-rc1
BR2_VERSION_EPOCH = 1479545409

(where the EPOCH is the actual time the release is cut, instead of some fixed
time in the month).

 This is particularly useful for 2016.11.1, which otherwise would have the same
EPOCH as 2016.11.


 Regards,
 Arnout

> 
> for example.
> 
> Thanks,
> 
> Thomas
>
Thomas Petazzoni Nov. 19, 2016, 9:51 a.m. UTC | #5
Hello,

On Sat, 19 Nov 2016 09:51:27 +0100, Arnout Vandecappelle wrote:

>  Or maybe even easier:
> 
> BR2_VERSION = 2016.11-rc1
> BR2_VERSION_EPOCH = 1479545409

Yes, this seems like a good idea. It's a bit annoying that we have to
update this, but it's the cleanest solution.

Thanks,

Thomas
Arnout Vandecappelle Nov. 19, 2016, 10:01 a.m. UTC | #6
On 19-11-16 10:51, Thomas Petazzoni wrote:
> Hello,
> 
> On Sat, 19 Nov 2016 09:51:27 +0100, Arnout Vandecappelle wrote:
> 
>>  Or maybe even easier:
>>
>> BR2_VERSION = 2016.11-rc1
>> BR2_VERSION_EPOCH = 1479545409
> 
> Yes, this seems like a good idea. It's a bit annoying that we have to
> update this, but it's the cleanest solution.

 An additional advantage is that you can leave it empty when no release has been
made yet, and error out in that case if no git is available.

 Regards,
 Arnout
diff mbox

Patch

diff --git a/Makefile b/Makefile
index eff814b..17e49e4 100644
--- a/Makefile
+++ b/Makefile
@@ -249,6 +249,10 @@  ifeq ($(BR2_REPRODUCIBLE),y)
 export TZ=UTC
 export LANG=C
 export LC_ALL=C
+export SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)
+SOURCE_DATE_GIT = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1 --format=%at)
+SOURCE_DATE_CHANGES = $(shell date -d `echo $(BR2_VERSION) | sed 's/^\(....\)\.\(..\).*/\1-\2-01T23:59:59/'` +%s)
+SOURCE_DATE_EPOCH = $(if $(wildcard $(TOPDIR)/.git),$(SOURCE_DATE_GIT),$(SOURCE_DATE_CHANGES))
 endif
 
 # To put more focus on warnings, be less verbose as default