Message ID | 23352f4835ae58c5cae6f425d5a8378f3d694055.1608319634.git.maxi@daemonizer.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Improvements for reproducible builds | expand |
On 18.12.2020 21:42, Maximilian Engelhardt wrote: > --- a/docs/Makefile > +++ b/docs/Makefile > @@ -3,7 +3,13 @@ include $(XEN_ROOT)/Config.mk > -include $(XEN_ROOT)/config/Docs.mk > > VERSION := $(shell $(MAKE) -C $(XEN_ROOT)/xen --no-print-directory xenversion) > -DATE := $(shell date +%Y-%m-%d) > + > +DATE_FMT := +%Y-%m-%d > +ifdef SOURCE_DATE_EPOCH > +DATE := $(shell 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)") Looking at the doc for a (deliberately) old "date", I can't find any mention of the -d "@..." syntax. I take it the command would fail on that system. It would then go on to try the -r variant, which has entirely different meaning on GNU (Linux) systems. docs/ being subject to configuring, why don't you determine the capabilities of "date" there and invoke just the one command that was found suitable for the system? Jan
On Montag, 21. Dezember 2020 10:01:14 CET Jan Beulich wrote: > On 18.12.2020 21:42, Maximilian Engelhardt wrote: > > --- a/docs/Makefile > > +++ b/docs/Makefile > > @@ -3,7 +3,13 @@ include $(XEN_ROOT)/Config.mk > > > > -include $(XEN_ROOT)/config/Docs.mk > > > > VERSION := $(shell $(MAKE) -C $(XEN_ROOT)/xen --no-print-directory > > xenversion)> > > -DATE := $(shell date +%Y-%m-%d) > > + > > +DATE_FMT := +%Y-%m-%d > > +ifdef SOURCE_DATE_EPOCH > > +DATE := $(shell 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)") > Looking at the doc for a (deliberately) old "date", I can't find > any mention of the -d "@..." syntax. I take it the command would > fail on that system. It would then go on to try the -r variant, > which has entirely different meaning on GNU (Linux) systems. > > docs/ being subject to configuring, why don't you determine the > capabilities of "date" there and invoke just the one command > that was found suitable for the system? > > Jan Hi Jan, I did some research. The -d "@..." syntax was introduced about 2005. Testing a live CD from 2006 (KNOPPIX_V5.0.1CD-2006-06-01-EN.iso) it was supported there. The documentation about this syntax has only been added in 2011 to the date command. I'm wondering if anybody running such an old system wants to use SOURCE_DATE_EPOCH. However, I came up with a patch to determine which suitable date version is available and only call that, as you suggested. I will post the new patch soon. Maxi
diff --git a/docs/Makefile b/docs/Makefile index 8de1efb6f5..ac6792ff7c 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -3,7 +3,13 @@ include $(XEN_ROOT)/Config.mk -include $(XEN_ROOT)/config/Docs.mk VERSION := $(shell $(MAKE) -C $(XEN_ROOT)/xen --no-print-directory xenversion) -DATE := $(shell date +%Y-%m-%d) + +DATE_FMT := +%Y-%m-%d +ifdef SOURCE_DATE_EPOCH +DATE := $(shell 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)") +else +DATE := $(shell date "$(DATE_FMT)") +endif DOC_ARCHES := arm x86_32 x86_64 MAN_SECTIONS := 1 5 7 8
Use the solution described in [1] to replace the call to the 'date' command with a version that uses SOURCE_DATE_EPOCH if available. This is needed for reproducible builds. [1] https://reproducible-builds.org/docs/source-date-epoch/ Signed-off-by: Maximilian Engelhardt <maxi@daemonizer.de> --- docs/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)