Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to override build date with SOURCE_DATE_EPOCH #31

Merged
merged 1 commit into from Jul 1, 2019

Conversation

Projects
None yet
3 participants
@bmwiedemann
Copy link
Contributor

commented Jun 28, 2019

in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.
This date call works with various variants of date.

Also use UTC to be independent of timezone.

@codecov-io

This comment has been minimized.

Copy link

commented Jun 28, 2019

Codecov Report

❗️ No coverage uploaded for pull request base (master@1df34c4). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##             master     #31   +/-   ##
========================================
  Coverage          ?   73.3%           
========================================
  Files             ?      15           
  Lines             ?     487           
  Branches          ?       0           
========================================
  Hits              ?     357           
  Misses            ?     103           
  Partials          ?      27

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1df34c4...2e40a6e. Read the comment docs.

@corneliusweig
Copy link
Owner

left a comment

Thanks for reporting this and providing a fix too! It makes absolute sense to make the build reproducible. As far as I understand, this is just the first step until the build is fully reproducible. For example, the build environment is also not well controlled.

Can you also make sure to include a a sign-off line in your commit, for example git commit --amend --signoff?

Makefile Outdated
@@ -34,9 +34,15 @@ CHECKSUMS += $(BUNDLE).sha256

VERSION_PACKAGE := $(REPOPATH)/pkg/rakkess/version

DATE_FMT = %Y-%m-%dT%H:%M:%SZ
ifdef SOURCE_DATE_EPOCH
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)")

This comment has been minimized.

Copy link
@corneliusweig

corneliusweig Jun 28, 2019

Owner

I'm a bit worried about all the alternatives here. Quoting the spec for SOURCE_DATE_EPOCH:

The value MUST be an ASCII representation of an integer with no fractional component, identical to the output format of date +%s.

That seems to be covered by the first alternative.

The second looks as if it is using a reference file to obtain a timestamp. As this is not specified by the spec, why should we do that?

Finally, the last alternative seems to be a fallback in case the other ones failed. Here I would rather fail fast and fail the build instead of pretending that everything went fine. WDYT?

This comment has been minimized.

Copy link
@bmwiedemann

bmwiedemann Jul 1, 2019

Author Contributor

This is to handle different variants of date - the first is for GNU date as used in every GNU/Linux distribution, the 2nd for FreeBSD date and the 3rd one as fallback (e.g. DOS and Solaris date) that have no way to make the output reproducible.

This comment has been minimized.

Copy link
@bmwiedemann

bmwiedemann Jul 1, 2019

Author Contributor

If you think, that this program will never be built outside of GNU/Linux, we can simplify the code.

This comment has been minimized.

Copy link
@corneliusweig

corneliusweig Jul 1, 2019

Owner

I see. So I think the last variant is obsolete, because on these systems people should simply not set the SOURCE_DATE_EPOCH env var and the build will do as expected.
And for the two remaining alternatives, a comment would be nice, such as

GNU and BSD date require different options for a fixed date

I don't mind if the comment is in code or in the commit message, whatever you prefer.

@bmwiedemann bmwiedemann force-pushed the bmwiedemann:master branch from 65ff959 to 0204bde Jul 1, 2019

Allow to override build date with SOURCE_DATE_EPOCH
in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.
This date call works with various variants of date.

Also use UTC to be independent of timezone.

Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de>

@bmwiedemann bmwiedemann force-pushed the bmwiedemann:master branch from 0204bde to 2e40a6e Jul 1, 2019

@corneliusweig corneliusweig merged commit 6f7f2f5 into corneliusweig:master Jul 1, 2019

3 checks passed

Travis CI - Pull Request Build Passed
Details
codecov/patch Coverage not affected.
Details
codecov/project No report found to compare against
Details
@corneliusweig

This comment has been minimized.

Copy link
Owner

commented Jul 1, 2019

Thanks again for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.