maint: Support `make doc-pot-update' from a tarball.

* build-aux/xgettext.scm: Move setting of environment variables to shell
header.
(main): Use SOURCE_DATE_EPOCH as fallback for timestamp.  This fixes running
from a tarball.
* Makefile.am (EXTRA_DIST): Add it.

Change-Id: Ic487587b22495868fd2a21545a13dc9e3458299c
This commit is contained in:
Janneke Nieuwenhuizen 2024-04-17 19:54:05 +02:00
parent bb089f7622
commit f83b5274c8
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
2 changed files with 6 additions and 5 deletions

View file

@ -727,6 +727,7 @@ EXTRA_DIST += \
build-aux/test-driver.scm \ build-aux/test-driver.scm \
build-aux/update-NEWS.scm \ build-aux/update-NEWS.scm \
build-aux/update-guix-package.scm \ build-aux/update-guix-package.scm \
build-aux/xgettext.scm \
doc/build.scm \ doc/build.scm \
etc/disarchive-manifest.scm \ etc/disarchive-manifest.scm \
etc/guix-install.sh \ etc/guix-install.sh \

View file

@ -2,6 +2,8 @@
# -*-scheme-*- # -*-scheme-*-
build_aux=$(dirname $0) build_aux=$(dirname $0)
srcdir=$build_aux/.. srcdir=$build_aux/..
export LC_ALL=en_US.UTF-8
export TZ=UTC0
exec guile --no-auto-compile -L $srcdir -C $srcdir -e main -s "$0" "$@" exec guile --no-auto-compile -L $srcdir -C $srcdir -e main -s "$0" "$@"
!# !#
@ -59,9 +61,6 @@ (define (pipe-command command)
;;; Entry point. ;;; Entry point.
;;; ;;;
(define (main args) (define (main args)
;; Cater for being run in a container.
(setenv "LC_ALL" "en_US.UTF-8")
(setenv "TZ" "UTC0")
(fluid-set! %default-port-encoding #f) (fluid-set! %default-port-encoding #f)
(let* ((files-from (get-option args "--files-from=")) (let* ((files-from (get-option args "--files-from="))
(default-domain (get-option args "--default-domain=")) (default-domain (get-option args "--default-domain="))
@ -82,9 +81,10 @@ (define (main args)
(files (map (cute string-append directory "/" <>) files)) (files (map (cute string-append directory "/" <>) files))
(git-command `("git" "log" "--pretty=format:%ci" "-n1" ,@files)) (git-command `("git" "log" "--pretty=format:%ci" "-n1" ,@files))
(timestamp (pipe-command git-command)) (timestamp (pipe-command git-command))
(source-date-epoch (or (getenv "SOURCE_DATE_EPOCH") "1"))
(timestamp (if (string-null? timestamp) source-date-epoch
timestamp))
(po-file (string-append default-domain ".po"))) (po-file (string-append default-domain ".po")))
(when (string-null? timestamp)
(exit 1))
(substitute* po-file (substitute* po-file
(("(\"POT-Creation-Date: )[^\\]*" all header) (("(\"POT-Creation-Date: )[^\\]*" all header)
(string-append header timestamp))))))) (string-append header timestamp)))))))