diff mbox series

[bug#70169,5/7] maint: Generate 'doc/version-LANG.texi' reproducibly.

Message ID 947bed93d2e2fec221fdec0d247f61912fb89567.1712165977.git.janneke@gnu.org
State New
Headers show
Series Reproducible `make dist' tarball in defiance of Autotools and Gettext | expand

Commit Message

Janneke Nieuwenhuizen April 3, 2024, 7:11 p.m. UTC
* doc/local.mk ($(srcdir)/doc/stamp-vti): Change rule into...
(version.texi-from-git): ...this new function.  Call it with vti,guix.texi,;
and for all MANUAL_LANGUAGES with $(i),po/doc/guix-manual.$(lang).po,
-$(lang.po).

Change-Id: Ia8df618178066cad320eecea0299337224e23a73
---
 doc/local.mk | 42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

Comments

Ludovic Courtès April 3, 2024, 8:25 p.m. UTC | #1
Janneke Nieuwenhuizen <janneke@gnu.org> skribis:

> +# Define a rule to build `version[LANG].texi' reproducibly using metadata from
> +# Git rather than using metadata from the filesystem.
> +define version.texi-from-git
> +override $(srcdir)/doc/stamp-$(1): $(srcdir)/$(2) $(top_srcdir)/configure
> +	$$(AM_V_GEN)set -e					\
> +	export LC_ALL=C;					\
> +	export TZ=UTC0;						\
> +	timestamp=$$$$(git log --pretty=format:%ct -n1 -- $$<	\
> +		2>/dev/null					\
> +		|| echo $$(SOURCE_DATE_EPOCH))			\
> +	dmy=$$$$(date --date="@$$$$timestamp" "+%-d %B %Y");	\
> +	my=$$$$(date --date="@$$$$timestamp" "+%B %Y");		\
> +	{ echo "@set UPDATED $$$$dmy";				\
> +	  echo "@set UPDATED-MONTH $$$$my";			\
> +	  echo "@set EDITION $$$(VERSION)";			\
> +	  echo "@set VERSION $$$(VERSION)"; } > $$@-t;
> +	mv $$@-t $$@
> +	cp -p $$@ $$(srcdir)/doc/version$(3).texi
> +endef
> +
> +i:=0
> +$(eval $(call version.texi-from-git,vti,doc/guix.texi,))
> +$(foreach lang, $(MANUAL_LANGUAGES),				\
> +	$(eval i=$(shell echo $$(($(i)+1))))			\
> +	$(eval $(call version.texi-from-git,$(i),po/doc/guix-manual.$(lang).po,-$(lang))))

Maybe we could drop ‘i’ and instead create ‘samp-fr’, ‘stamp-de’, and so
on?  That is, ‘version.texi-from-git’ would take 2 arguments instead of 3.

(That’s really a minor issue though.)

Ludo’.
Janneke Nieuwenhuizen April 3, 2024, 8:33 p.m. UTC | #2
Ludovic Courtès writes:

> Janneke Nieuwenhuizen <janneke@gnu.org> skribis:
>
>> +$(eval $(call version.texi-from-git,vti,doc/guix.texi,))
>> +$(foreach lang, $(MANUAL_LANGUAGES),				\
>> +	$(eval i=$(shell echo $$(($(i)+1))))			\
>> +	$(eval $(call version.texi-from-git,$(i),po/doc/guix-manual.$(lang).po,-$(lang))))
>
> Maybe we could drop ‘i’ and instead create ‘samp-fr’, ‘stamp-de’, and so
> on?  That is, ‘version.texi-from-git’ would take 2 arguments instead of 3.

I don't think so, or, I wouldn't know how to do that.  The stamp-N is
created by Automake's magic.  They are distributed together with the
version-LANG.texi files.

If Automake would have used stamp-LANG, this would have been much
easier, we could probably have used stem (%) instead of this hairy
function.

> (That’s really a minor issue though.)

Ok, but if it's somehow possible, I agree it would be nice.

Greetings,
Janneke
Ludovic Courtès April 3, 2024, 8:39 p.m. UTC | #3
Janneke Nieuwenhuizen <janneke@gnu.org> skribis:

> * doc/local.mk ($(srcdir)/doc/stamp-vti): Change rule into...
> (version.texi-from-git): ...this new function.  Call it with vti,guix.texi,;
> and for all MANUAL_LANGUAGES with $(i),po/doc/guix-manual.$(lang).po,
> -$(lang.po).
>
> Change-Id: Ia8df618178066cad320eecea0299337224e23a73

[...]

> +i:=0
> +$(eval $(call version.texi-from-git,vti,doc/guix.texi,))
> +$(foreach lang, $(MANUAL_LANGUAGES),				\
> +	$(eval i=$(shell echo $$(($(i)+1))))			\
> +	$(eval $(call version.texi-from-git,$(i),po/doc/guix-manual.$(lang).po,-$(lang))))

Also, not sure why but I get this:

--8<---------------cut here---------------start------------->8---
make[2]: Entering directory '/home/ludo/src/guix'
Makefile:7389: warning: overriding recipe for target 'doc/stamp-vti'
Makefile:5111: warning: ignoring old recipe for target 'doc/stamp-vti'
Makefile:7390: warning: overriding recipe for target 'override'
Makefile:7389: warning: ignoring old recipe for target 'override'
Makefile:7390: warning: overriding recipe for target 'doc/stamp-1'
Makefile:5176: warning: ignoring old recipe for target 'doc/stamp-1'
[…]
--8<---------------cut here---------------end--------------->8---

Ludo’.
Janneke Nieuwenhuizen April 3, 2024, 8:43 p.m. UTC | #4
Ludovic Courtès writes:

[cc: Timothy Samplet who created an early version of this patch]

> Janneke Nieuwenhuizen <janneke@gnu.org> skribis:
>
>> * doc/local.mk ($(srcdir)/doc/stamp-vti): Change rule into...
>> (version.texi-from-git): ...this new function.  Call it with vti,guix.texi,;
>> and for all MANUAL_LANGUAGES with $(i),po/doc/guix-manual.$(lang).po,
>> -$(lang.po).
>>
>> Change-Id: Ia8df618178066cad320eecea0299337224e23a73
>
> [...]
>
>> +i:=0
>> +$(eval $(call version.texi-from-git,vti,doc/guix.texi,))
>> +$(foreach lang, $(MANUAL_LANGUAGES),				\
>> +	$(eval i=$(shell echo $$(($(i)+1))))			\
>> +	$(eval $(call version.texi-from-git,$(i),po/doc/guix-manual.$(lang).po,-$(lang))))
>
> Also, not sure why but I get this:
>
> make[2]: Entering directory '/home/ludo/src/guix'
> Makefile:7389: warning: overriding recipe for target 'doc/stamp-vti'
> Makefile:5111: warning: ignoring old recipe for target 'doc/stamp-vti'
> Makefile:7390: warning: overriding recipe for target 'override'
> Makefile:7389: warning: ignoring old recipe for target 'override'
> Makefile:7390: warning: overriding recipe for target 'doc/stamp-1'
> Makefile:5176: warning: ignoring old recipe for target 'doc/stamp-1'
> […]

Yes, sadly that's expected, and couldn't figure out how to avoid this.
Any ideas would be greatly appreciated.  Automake will just create those
targets, and it seems we must override exactly those.  May Timothy has
an idea?
Ludovic Courtès April 8, 2024, 9:26 a.m. UTC | #5
Janneke Nieuwenhuizen <janneke@gnu.org> skribis:

> Ludovic Courtès writes:
>
>> Janneke Nieuwenhuizen <janneke@gnu.org> skribis:
>>
>>> +$(eval $(call version.texi-from-git,vti,doc/guix.texi,))
>>> +$(foreach lang, $(MANUAL_LANGUAGES),				\
>>> +	$(eval i=$(shell echo $$(($(i)+1))))			\
>>> +	$(eval $(call version.texi-from-git,$(i),po/doc/guix-manual.$(lang).po,-$(lang))))
>>
>> Maybe we could drop ‘i’ and instead create ‘samp-fr’, ‘stamp-de’, and so
>> on?  That is, ‘version.texi-from-git’ would take 2 arguments instead of 3.
>
> I don't think so, or, I wouldn't know how to do that.  The stamp-N is
> created by Automake's magic.  They are distributed together with the
> version-LANG.texi files.
>
> If Automake would have used stamp-LANG, this would have been much
> easier, we could probably have used stem (%) instead of this hairy
> function.

Oh, I see.  I didn't know there were internal uses of ‘stamp-N’.

Ludo’.
diff mbox series

Patch

diff --git a/doc/local.mk b/doc/local.mk
index 99a7e84361..893c99e1b1 100644
--- a/doc/local.mk
+++ b/doc/local.mk
@@ -6,6 +6,7 @@ 
 # Copyright © 2016, 2018 Mathieu Lirzin <mthl@gnu.org>
 # Copyright © 2018, 2021 Julien Lepiller <julien@lepiller.eu>
 # Copyright © 2019 Timothy Sample <samplet@ngyro.com>
+# Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
 #
 # This file is part of GNU Guix.
 #
@@ -254,19 +255,28 @@  endif
 
 # Reproducible tarball
 
-# Generate 'version.texi' reproducibly using metadata from Git rather
-# than using metadata from the filesystem.
-override $(srcdir)/doc/stamp-vti: $(srcdir)/doc/guix.texi $(top_srcdir)/configure
-	$(AM_V_GEN)set -e						\
-	export LC_ALL=C;						\
-	export TZ=UTC0;							\
-	timestamp=$$(git log --pretty=format:%ct -n1 -- $< 2>/dev/null	\
-		|| echo $(SOURCE_DATE_EPOCH))				\
-	dmy=$$(date --date="@$$timestamp" "+%-d %B %Y");		\
-	my=$$(date --date="@$$timestamp" "+%B %Y");			\
-	{ echo "@set UPDATED $$dmy";					\
-	  echo "@set UPDATED-MONTH $$my";				\
-	  echo "@set EDITION $(VERSION)";				\
-	  echo "@set VERSION $(VERSION)"; } > $@-t;			\
-	mv $@-t $@
-	@cp $@ $(srcdir)/doc/version.texi
+# Define a rule to build `version[LANG].texi' reproducibly using metadata from
+# Git rather than using metadata from the filesystem.
+define version.texi-from-git
+override $(srcdir)/doc/stamp-$(1): $(srcdir)/$(2) $(top_srcdir)/configure
+	$$(AM_V_GEN)set -e					\
+	export LC_ALL=C;					\
+	export TZ=UTC0;						\
+	timestamp=$$$$(git log --pretty=format:%ct -n1 -- $$<	\
+		2>/dev/null					\
+		|| echo $$(SOURCE_DATE_EPOCH))			\
+	dmy=$$$$(date --date="@$$$$timestamp" "+%-d %B %Y");	\
+	my=$$$$(date --date="@$$$$timestamp" "+%B %Y");		\
+	{ echo "@set UPDATED $$$$dmy";				\
+	  echo "@set UPDATED-MONTH $$$$my";			\
+	  echo "@set EDITION $$$(VERSION)";			\
+	  echo "@set VERSION $$$(VERSION)"; } > $$@-t;
+	mv $$@-t $$@
+	cp -p $$@ $$(srcdir)/doc/version$(3).texi
+endef
+
+i:=0
+$(eval $(call version.texi-from-git,vti,doc/guix.texi,))
+$(foreach lang, $(MANUAL_LANGUAGES),				\
+	$(eval i=$(shell echo $$(($(i)+1))))			\
+	$(eval $(call version.texi-from-git,$(i),po/doc/guix-manual.$(lang).po,-$(lang))))