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 #640

Merged
merged 1 commit into from Jul 13, 2018
Merged

Allow to override build date #640

merged 1 commit into from Jul 13, 2018

Conversation

bmwiedemann
Copy link
Contributor

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.
Also use UTC to be independent of timezone.

This date call is designed to work with all variants of 'date'

Without this patch, the dosemu package in openSUSE would differ for every build.

configure.ac Outdated
CONFIG_TIME=`date +"%F %T %z"`
DATE_FMT="%F %T %z"
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
CONFIG_TIME=$(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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does @$SOURCE_DATE_EPOCH mean here?
And too many bashisms, please write as
if test -n "$SOURCE_DATE_EPOCH"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @ is not shell magic, but a literal @ (at) sign as documented in the GNU date man page

EXAMPLES
       Convert seconds since the epoch (1970-01-01 UTC) to a date

              $ date --date='@2147483647'```

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.
Also use UTC to be independent of timezone.

This date call is designed to work with all variants of 'date'
CONFIG_TIME=`date +"%F %T %z"`
DATE_FMT="%F %T %z"
test -n "$SOURCE_DATE_EPOCH" || SOURCE_DATE_EPOCH=`date +%s`
CONFIG_TIME=`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"`
Copy link
Member

@stsp stsp Jul 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what you do with -r here?
Your doc does not say this can be a file,
or what is the intention?
Can we just have

CONFIG_TIME=`date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT"`

and nothing else in this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

date -d would only work with GNU date. BSD date (e.g. MacOSX) takes such integer dates with the -r option instead. And solaris date has neither - that is covered by the third case.

@stsp stsp merged commit af7f27b into dosemu2:master Jul 13, 2018
@stsp
Copy link
Member

stsp commented Jul 13, 2018

OK, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants