Skip to content

build: improve reliability/portability of date command usage #6404

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

Merged
merged 1 commit into from
Jul 20, 2024

Conversation

kmk3
Copy link
Collaborator

@kmk3 kmk3 commented Jul 11, 2024

Changes:

  • Use the exact same source date string for all date invocations
  • Use -d instead of --date=
  • Fallback to -r and then to no argument

Some date implementations only support BSD -r instead of GNU -d /
--date= and others may not support any of them since neither option is
in POSIX.

For example, if zoneinfo is installed by chromebrew on ChromeOS, it
provides a date program that only supports -r and overrides the system
one (which supports -d) [1]:

./mkman.sh 0.9.72 src/man/firejail.man firejail.1
date: invalid option -- '-'
date: usage: date [-u] [-c] [-r seconds] [+format]
make: *** [Makefile:42: firejail.1] Error 1

Environment: zoneinfo 2024a on ChromeOS M125.

Note: The changes are based on what is suggested by
reproducible-builds.org [2].

Relates to #193.

Fixes #6403.

[1] #6403 (comment)
[2] https://reproducible-builds.org/docs/source-date-epoch/

Reported-by: @Zopolis4
Cc: @reinerh (from #193)

@kmk3 kmk3 marked this pull request as draft July 11, 2024 10:40
Copy link
Collaborator

@glitsj16 glitsj16 left a comment

Choose a reason for hiding this comment

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

LGTM

Changes:

* Use the exact same source date string for all `date` invocations
* Use `-d` instead of `--date=`
* Fallback to `-r` and then to no argument

Some `date` implementations only support BSD `-r` instead of GNU `-d` /
`--date=` and others may not support any of them since neither option is
in POSIX.

For example, if zoneinfo is installed by chromebrew on ChromeOS, it
provides a date program that only supports `-r` and overrides the system
one (which supports `-d`) [1]:

    ./mkman.sh 0.9.72 src/man/firejail.man firejail.1
    date: invalid option -- '-'
    date: usage: date [-u] [-c] [-r seconds] [+format]
    make: *** [Makefile:42: firejail.1] Error 1

Environment: zoneinfo 2024a on ChromeOS M125.

Note: The changes are based on what is suggested by
reproducible-builds.org [2].

Relates to netblue30#193.

Fixes netblue30#6403.

[1] netblue30#6403 (comment)
[2] https://reproducible-builds.org/docs/source-date-epoch/

Reported-by: @Zopolis4
@kmk3 kmk3 force-pushed the build-man-fix-date branch from e9ba1f9 to ca2d752 Compare July 13, 2024 10:40
@kmk3 kmk3 changed the title build: man: improve usage of date command build: improve reliability/portability of date command usage Jul 13, 2024
@kmk3 kmk3 marked this pull request as ready for review July 13, 2024 10:41
@kmk3 kmk3 merged commit 969e29b into netblue30:master Jul 20, 2024
2 checks passed
@kmk3 kmk3 deleted the build-man-fix-date branch July 20, 2024 14:11
kmk3 added a commit that referenced this pull request Jul 26, 2024
@kmk3 kmk3 added enhancement New feature request bugfix This fixes a bug labels Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This fixes a bug enhancement New feature request
Projects
Status: Done (on RELNOTES)
Development

Successfully merging this pull request may close these issues.

build: failure due to invalid --date option (ChromeOS)
2 participants