From e9ba1f963740626e1867b23d3ccecd4fbce2b7f6 Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Thu, 11 Jul 2024 03:38:34 -0300 Subject: [PATCH] build: man: improve usage of date command Changes: * Use the exact same source date string for all `date` invocations * Use `date -d` instead of `date --date=` * Only use `-d` if supported The `date` command on ChromeOS does not support the `-d` / `--date=` option[1] [2]: # using `date --date=` ./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 # using `date -d` ./mkman.sh 0.9.72 src/man/firejail.man firejail.1 date: invalid option -- 'd' date: usage: date [-u] [-c] [-r seconds] [+format] make: *** [Makefile:42: firejail.1] Error 1 Environment: zoneinfo 2024a on ChromeOS M125. Relates to #193. Fixes #6403. [1] https://github.com/netblue30/firejail/issues/6403#issue-2402292506 [2] https://github.com/netblue30/firejail/issues/6403#issuecomment-2222184946 Reported-by: @Zopolis4 --- src/man/mkman.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/man/mkman.sh b/src/man/mkman.sh index 00c4ffe720f..65a31b2e513 100755 --- a/src/man/mkman.sh +++ b/src/man/mkman.sh @@ -5,8 +5,15 @@ set -e -MONTH="$(LC_ALL=C date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%b)" -YEAR="$(LC_ALL=C date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y)" +test -z "$SOURCE_DATE_EPOCH" && SOURCE_DATE_EPOCH="$(date +%s)" + +if LC_ALL=C date -d "@$SOURCE_DATE_EPOCH" >/dev/null 2>/dev/null; then + MONTH="$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" +%b)" + YEAR="$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" +%Y)" +else + MONTH="$(LC_ALL=C date -u +%b)" + YEAR="$(LC_ALL=C date -u +%Y)" +fi sed \ -e "s/VERSION/$1/g" \