diff mbox series

[bug#70169,6/7] maint: Use reproducible Git timestamp for POT-Creation-Date.

Message ID 45e5e23d88c8846551c7493d3e9ab344dcb2f942.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
* po/doc/local.mk (%D%/%.pot): Replace POT-Creation-Date using timestamp from
Git.
(%D%/guix-manual.pot): Likewise.

Change-Id: I1b7f8cc147084c1804deb7be9d36e5eeda2599cb
---
 po/doc/local.mk | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

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

> +	date=$$(git log --pretty=format:%ci -n 1 -- $< 2>/dev/null	\
> +		|| echo $(SOURCE_DATE_EPOCH))				\
> +	sed -ri -e "s,^(.POT-Creation-Date: )[^\]*,\1$$date," $@-t
> +	mv $@-t $@

Nitpick: I'd use double quotes to avoid bad surprises:

  date="$$(git log …)"
  …
  mv "$@-t" "$@"
Janneke Nieuwenhuizen April 3, 2024, 8:36 p.m. UTC | #2
Ludovic Courtès writes:

> Janneke Nieuwenhuizen <janneke@gnu.org> skribis:
>
>> +	date=$$(git log --pretty=format:%ci -n 1 -- $< 2>/dev/null	\
>> +		|| echo $(SOURCE_DATE_EPOCH))				\
>> +	sed -ri -e "s,^(.POT-Creation-Date: )[^\]*,\1$$date," $@-t
>> +	mv $@-t $@
>
> Nitpick: I'd use double quotes to avoid bad surprises:
>
>   date="$$(git log …)"
>   …
>   mv "$@-t" "$@"

Makes sense, thanks.
Janneke Nieuwenhuizen April 4, 2024, 5:12 a.m. UTC | #3
Ludovic Courtès writes:

> Janneke Nieuwenhuizen <janneke@gnu.org> skribis:
>
>> +	date=$$(git log --pretty=format:%ci -n 1 -- $< 2>/dev/null	\
>> +		|| echo $(SOURCE_DATE_EPOCH))				\
>> +	sed -ri -e "s,^(.POT-Creation-Date: )[^\]*,\1$$date," $@-t
>> +	mv $@-t $@
>
> Nitpick: I'd use double quotes to avoid bad surprises:
>
>   date="$$(git log …)"
>   …
>   mv "$@-t" "$@"

Makes sense, thanks.
diff mbox series

Patch

diff --git a/po/doc/local.mk b/po/doc/local.mk
index dd6ba30133..f68d67ec02 100644
--- a/po/doc/local.mk
+++ b/po/doc/local.mk
@@ -1,6 +1,7 @@ 
 # GNU Guix --- Functional package management for GNU
 # Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
 # Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+# Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
 #
 # This file is part of GNU Guix.
 #
@@ -44,12 +45,19 @@  POT_OPTIONS = \
 	--msgid-bugs-address "bug-guix@gnu.org"
 
 %D%/%.pot: $(srcdir)/doc/%.texi
-	$(AM_V_PO4A)$(PO4A_UPDATEPO) -M UTF-8 -f texinfo -m "$<" \
-	   -p "$@" $(POT_OPTIONS) && \
-	touch $@
+	$(AM_V_PO4A)$(PO4A_UPDATEPO) -M UTF-8 -f texinfo -m "$<"	\
+	   -p "$@-t" $(POT_OPTIONS)
+	date=$$(git log --pretty=format:%ci -n 1 -- $< 2>/dev/null	\
+		|| echo $(SOURCE_DATE_EPOCH))				\
+	sed -ri -e "s,^(.POT-Creation-Date: )[^\]*,\1$$date," $@-t
+	mv $@-t $@
 
 %D%/guix-manual.pot: %D%/guix.pot %D%/contributing.pot
-	msgcat $^ > $@
+	msgcat $^ > $@-t
+	date=$$(git log --pretty=format:%ci -n 1 -- $< 2>/dev/null	\
+		|| echo $(SOURCE_DATE_EPOCH))				\
+	sed -ri "s,^(.POT-Creation-Date: )[^\]*,\1$$date," $@-t
+	mv $@-t $@
 
 doc-pot-update: %D%/guix-manual.pot %D%/guix-cookbook.pot
 .PHONY: doc-pot-update