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

[BUG] Error in autogen on Mac #1230

Closed
vr8hub opened this issue Feb 15, 2020 · 18 comments · Fixed by #1232
Closed

[BUG] Error in autogen on Mac #1230

vr8hub opened this issue Feb 15, 2020 · 18 comments · Fixed by #1232
Assignees

Comments

@vr8hub
Copy link

vr8hub commented Feb 15, 2020

  • Is this a regression (i.e. did it work before)? {YES/NO} Yes
  • What platform did you use? {Window/Linux/Mac} Mac
  • What were the used arguments? {replace with the arguments} build error, not runtime error

There is an error when running autogen.sh in the Mac subdirectory.

Obtaining Git commit
date: illegal option -- -
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
Storing variables in file
Commit: db646f50ac14a772de9f374b2b40e05dbc6c0da9
Date:
Stored all in compile_info_real.h
Done.

This is actually an error in pre-build.sh, which autogen.sh calls. Line 24 of the pre-build script is

builddate=`date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y-%m-%d`

But the Mac's date command has neither a --utc or a --date option. (The Mac's date command is BSD-based; I don't know about Linux.)

[Edit] Sorry, should have said: I'm on Mojave 10.14.6.

@canihavesomecoffee
Copy link
Member

Traces back to b364298.

If we don't care about reproducible builds on Mac, we can just revert that part of the change...

@NilsIrl
Copy link
Contributor

NilsIrl commented Feb 15, 2020

If we don't care about reproducible builds on Mac, we can just revert that part of the change...

Probably best to have both scripts (linux + mac) do the same thing.

@canihavesomecoffee
Copy link
Member

Removing the reproducible build for Linux is not an option here. It was specifically requested by guys at the Debian project.

For Mac we either need to find other parameters, or we could revert it.

@NilsIrl
Copy link
Contributor

NilsIrl commented Feb 15, 2020

b364298#r37313277

CC @lamby (in case the ping in an edited review for a closed PR doesn't go through). (Also if you could address my comment below as well.)

@NilsIrl
Copy link
Contributor

NilsIrl commented Feb 15, 2020

Also for that PR, why --utc needed since a format is provided and the source of the date is the --date argument?

@cfsmp3
Copy link
Contributor

cfsmp3 commented Feb 15, 2020

@vr8hub can you send us the correct syntax for Mac? Seems trivial to change but I can't test:

https://ss64.com/osx/date.html

@canihavesomecoffee
Copy link
Member

@cfsmp3 There's no option for inputting a specific date in there it seems. We can replace the --utc with -u most likely without any problems, but that won't fix the remainder of the command.

We should perhaps see if @lamby has a suggestion for reproducible builds on Mac, or if we can revert that for Mac only.

@vr8hub
Copy link
Author

vr8hub commented Feb 15, 2020

Possibly. I don't have a Linux box handy, so I don't know what the existing command is trying to do.

@canihavesomecoffee
Copy link
Member

@vr8hub The current command is adding the date to the build, in a reproducible manner.

This means that it either takes the time from an environment variable, or picks the current date if that is missing.

@vr8hub
Copy link
Author

vr8hub commented Feb 15, 2020

From a little searching, it seems the SOURCE_DATE_EPOCH is formatted as number of seconds since epoch. Which would agree with the +%s format on the current date/time.

So, take # of seconds, either from SOURCE_DATE_EPOCH or the current datetime, and output in the indicated format.

I think that might be possible (the ss64 page is incorrect or outdated; there are quite a few other options available in date on Mojave; I don't have an older OS available right now). Let me play with it a bit.

@lamby
Copy link
Contributor

lamby commented Feb 15, 2020

Just a drive-by comment please check out https://reproducible-builds.org/docs/source-date-epoch/#bash--posix-shell

@vr8hub
Copy link
Author

vr8hub commented Feb 15, 2020

Excellent, thanks Chris. And that does work; I tried it first with SOURCE_DATE_EPOCH set to current date, then set it back a couple of months, and BUILD_DATE ended up with the correct value both times.

I suspect this could be shortened, but since it works and I have other things to do, let's just go with this for now. :)

DATE_FMT="+%Y-%m-%d"
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
builddate=$(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")

@lamby
Copy link
Contributor

lamby commented Feb 15, 2020

I keep forgetting that Mac has the BSD date, apologies for the ~noise.

@canihavesomecoffee
Copy link
Member

If https://travis-ci.org/CCExtractor/ccextractor/builds/650958611 passes I'll merge that (which is basically the thing mentioned here).

@vr8hub
Copy link
Author

vr8hub commented Feb 15, 2020

Actually, I don't think that first command is needed, and doesn't do what they think it does, at least on a Mac. The -d option is to "Set the kernel's value for daylight saving time."

Also, the date command should probably include -j to prevent it from trying to set the date.

I think those three lines can be shortened to the equivalent one-liner for what's there now:

builddate=`date -j -u -r "${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y-%m-%d`

That works for me when SOURCE_DATE_EPOCH isn't set and when it is.

@lamby
Copy link
Contributor

lamby commented Feb 15, 2020

That works for me when SOURCE_DATE_EPOCH isn't set and when it is.

This will not work under GNU date as -j is not an option there.

@vr8hub
Copy link
Author

vr8hub commented Feb 15, 2020

We're not worried about GNU date, are we? This is a Mac-specific file.

@lamby
Copy link
Contributor

lamby commented Feb 15, 2020

Ah, did not realise that...! I should go to bed, really. :)

canihavesomecoffee added a commit that referenced this issue Feb 16, 2020
* Fix Mac build error for reproducible builds
* Shorten solution with vr8hub's suggestion

Closes #1230
tasmo pushed a commit to prototypefund/reproducible-website that referenced this issue Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants