[BUG] Error in autogen on Mac #559

Closed
opened 2026-01-29 16:47:36 +00:00 by claunia · 18 comments
Owner

Originally created by @vr8hub on GitHub (Feb 15, 2020).

Originally assigned to: @canihavesomecoffee on GitHub.

  • 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.

Originally created by @vr8hub on GitHub (Feb 15, 2020). Originally assigned to: @canihavesomecoffee on GitHub. - 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.
claunia added the difficulty: easy label 2026-01-29 16:47:36 +00:00
Author
Owner

@canihavesomecoffee commented on GitHub (Feb 15, 2020):

Traces back to b36429879d.

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

@canihavesomecoffee commented on GitHub (Feb 15, 2020): Traces back to https://github.com/CCExtractor/ccextractor/commit/b36429879dd0136fce519c0c67aedab5f85739c6. If we don't care about reproducible builds on Mac, we can just revert that part of the change...
Author
Owner

@NilsIrl commented on GitHub (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.

@NilsIrl commented on GitHub (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.
Author
Owner

@canihavesomecoffee commented on GitHub (Feb 15, 2020):

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.

@canihavesomecoffee commented on GitHub (Feb 15, 2020): 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.
Author
Owner

@NilsIrl commented on GitHub (Feb 15, 2020):

b36429879d (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 commented on GitHub (Feb 15, 2020): https://github.com/CCExtractor/ccextractor/commit/b36429879dd0136fce519c0c67aedab5f85739c6#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.)
Author
Owner

@NilsIrl commented on GitHub (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?

@NilsIrl commented on GitHub (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?
Author
Owner

@cfsmp3 commented on GitHub (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

@cfsmp3 commented on GitHub (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
Author
Owner

@canihavesomecoffee commented on GitHub (Feb 15, 2020):

@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.

@canihavesomecoffee commented on GitHub (Feb 15, 2020): @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.
Author
Owner

@vr8hub commented on GitHub (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.

@vr8hub commented on GitHub (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.
Author
Owner

@canihavesomecoffee commented on GitHub (Feb 15, 2020):

@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.

@canihavesomecoffee commented on GitHub (Feb 15, 2020): @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.
Author
Owner

@vr8hub commented on GitHub (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.

@vr8hub commented on GitHub (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.
Author
Owner

@lamby commented on GitHub (Feb 15, 2020):

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

@lamby commented on GitHub (Feb 15, 2020): Just a drive-by comment please check out https://reproducible-builds.org/docs/source-date-epoch/#bash--posix-shell
Author
Owner

@vr8hub commented on GitHub (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")

@vr8hub commented on GitHub (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")
Author
Owner

@lamby commented on GitHub (Feb 15, 2020):

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

@lamby commented on GitHub (Feb 15, 2020): I keep forgetting that Mac has the BSD `date`, apologies for the ~noise.
Author
Owner

@canihavesomecoffee commented on GitHub (Feb 15, 2020):

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

@canihavesomecoffee commented on GitHub (Feb 15, 2020): If https://travis-ci.org/CCExtractor/ccextractor/builds/650958611 passes I'll merge that (which is basically the thing mentioned here).
Author
Owner

@vr8hub commented on GitHub (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.

@vr8hub commented on GitHub (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.
Author
Owner

@lamby commented on GitHub (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.

@lamby commented on GitHub (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.
Author
Owner

@vr8hub commented on GitHub (Feb 15, 2020):

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

@vr8hub commented on GitHub (Feb 15, 2020): We're not worried about GNU date, are we? This is a Mac-specific file.
Author
Owner

@lamby commented on GitHub (Feb 15, 2020):

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

@lamby commented on GitHub (Feb 15, 2020): Ah, did not realise that...! I should go to bed, really. :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#559