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

Make the build reproducible #258

Merged

Conversation

@lamby
Copy link
Contributor

commented Aug 13, 2019

Whilst working on the Reproducible Builds effort we noticed that re2c could not be built reproducibly. This is because it used the current build date in the manual page and was originally filed in Debian as #934697.

This patch uses the SOURCE_DATE_EPOCH environment variable.

Make the build reproducible
Whilst working on the Reproducible Builds effort [0] we noticed
that re2c could not be built reproducibly.

This is because it used the current build date in the manual page and was
originally filed in Debian as #934697 [1].

This patch uses the SOURCE_DATE_EPOCH [2] environment variable.

 [0] https://reproducible-builds.org/
 [1] https://bugs.debian.org/934697
 [2] https://reproducible-builds.org/specs/source-date-epoch/

Signed-off-by: Chris Lamb <lamby@debian.org>

@skvadrik skvadrik merged commit 7e10b11 into skvadrik:master Aug 14, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@skvadrik

This comment has been minimized.

Copy link
Owner

commented Aug 14, 2019

@lamby Merged, thank you.

However, I need to make it compatible with POSIX date, as re2c is built on other platforms as well. Can you suggest a fix? From the guidelines:

If you need to support BSD date as well you should fallback to trying ther -r seconds timestamp variant:

DATE_FMT="%Y-%m-%d"
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
BUILD_DATE=$(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 is not completely POSIX-compliant as well (because of the -d and -r options).

@lamby

This comment has been minimized.

Copy link
Contributor Author

commented Aug 14, 2019

IIRC whilst you are entirely correct about the lack of d and -r is POSIX there is, unfortunately, no way around this. POSIX is minimal after all. I suspect one of the ||/OR'd will capture 99.99999% of platforms. I guess if you are still worried then you could do something like an additional suffix of || echo "[some kind of fallback]"

@skvadrik

This comment has been minimized.

Copy link
Owner

commented Aug 17, 2019

@lamby Thanks, I think you are right about 99.99999%. However, I realized that PACKAGE_DATE was used only in one place (in the manpage) and it was not really needed there. So it was easier to get rid of it altogether: 7648f8d (thanks to @trofi for suggesting the idea).

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