From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id +LWADVG8EWafegEA62LTzQ:P1 (envelope-from ) for ; Sat, 06 Apr 2024 23:19:13 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id +LWADVG8EWafegEA62LTzQ (envelope-from ) for ; Sat, 06 Apr 2024 23:19:13 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=PbrZdlgq; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1712438353; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=1eVD3MxAZ1OnJTp1FtGqHJG7nb7XygoiqlLWAcW7G+g=; b=QAFfizqJ+TVXYv2yAXIe8hXlsjP+MIubEEj2D5Rtn9um1rdF4KC1K3f22jKpSVRaLIhIzV m6Y9xozishp5MEiJH6Ng9pjcH2hdO0Kv66kMRSxxYWvtNR57upqFpV+AAv5Esuwowpz1om ihlkGA+qSju+fDb6pRU+5Ws5ezqOhjw20lm7DvKZLI9FqICEXqXjf4YH5RG4q714e6FRMS dVbYWYFmHFfIZj01WbRJWD/D+Zslw8sucd9vuZDcuqh1tEXUFoRnDn6EXgtjwehxj9GAuX lxVegHsQNiBZe1Q+e7BCHSa1XnPnRadKHD6a2ZL9NEI6k6k77ipFWP3hi9S5Cg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1712438353; a=rsa-sha256; cv=none; b=q07L6n/iNdOfxvM3CJzriUPdq5wtyEKsjG77Umk91u/OGT1Hrl9OMQ6ePwoJE4UuUBJIZo O/11rfsjeuQ/NHcvZJGWY3GkepgrNQOky1BA8sVjxAp8ppVTd0xd854r0gfF16QDhylR4u Pw7N4HqYUqb0srC1fxMi9UJd0hIzut4L8i3in2hjY4Qp3CNgH8qRgvPwX3fxVR63keJFM6 ukzkMJx+Ygbyxnhqr7ook9zG26sVgX/fHniKt2Pbj3s5WeO4zLAeUdJVncToxnwl41V0gt DpfZEfOa3vDuCivFBxGlQpc2voGbdlu5p4vKHf+8Es/Vdx8ZA3Gk0eQP2eoZxg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=PbrZdlgq; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id BD253228D3 for ; Sat, 6 Apr 2024 23:19:12 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rtDRL-0000R6-4u; Sat, 06 Apr 2024 17:19:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rtDRG-0000Oj-T7 for guix-patches@gnu.org; Sat, 06 Apr 2024 17:19:03 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rtDRF-0004TF-Vf for guix-patches@gnu.org; Sat, 06 Apr 2024 17:19:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rtDRK-0000a0-EM; Sat, 06 Apr 2024 17:19:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70169] [PATCH v2 07/12] maint: Use xgettext.scm wrapper to create .PO files reproducibly. Resent-From: Janneke Nieuwenhuizen Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, julien@lepiller.eu, guix-patches@gnu.org Resent-Date: Sat, 06 Apr 2024 21:19:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70169 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70169@debbugs.gnu.org Cc: Florian Pelz , Julien Lepiller X-Debbugs-Original-Xcc: Florian Pelz , Julien Lepiller Received: via spool by 70169-submit@debbugs.gnu.org id=B70169.17124383221992 (code B ref 70169); Sat, 06 Apr 2024 21:19:06 +0000 Received: (at 70169) by debbugs.gnu.org; 6 Apr 2024 21:18:42 +0000 Received: from localhost ([127.0.0.1]:41133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rtDQu-0000Vq-QT for submit@debbugs.gnu.org; Sat, 06 Apr 2024 17:18:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53958) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rtDQk-0000Sr-9W for 70169@debbugs.gnu.org; Sat, 06 Apr 2024 17:18:32 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rtDQY-0004Hg-JJ; Sat, 06 Apr 2024 17:18:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=5f51ZRcnHNEpCFQtNyXonoM9juLiNt3lIbdge0bzb7s=; b=PbrZdlgqPi3q2xQNVv8K gGRhaNeC4uLd6LGSWH8vLWNEeKXmRO5EkglDJTTjiX3tX0Rkp6ev+ck3LuW4m42GclTtDNoTFsa43 433socCr1XHmTJmnQg60LCc+phhpJwDX9QmwdcCuZ+9BJlbp/R6ULvib4SAzufg40yceymoPXLgP5 ghgm7Hpq/m36JSEVCRTXQgZrwp7sORlGL5cvP2iOjuc8vo4pxbedY//kWMsaZSXKgI+cii2qdRsOM vDAewcZZOk1rz1xpmiEoPc1TFN4dQFJ8iSOamQC4fyCaa5YkdLuDWipAjKrame156rx39ZXWCY65j /iDt+Uq5kjb+Cw==; From: Janneke Nieuwenhuizen Date: Sat, 6 Apr 2024 23:17:59 +0200 Message-ID: <83a27ee0460886ac9802caa34addd8d111acf68a.1712437365.git.janneke@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.06 X-Spam-Score: -6.06 X-Migadu-Queue-Id: BD253228D3 X-Migadu-Scanner: mx12.migadu.com X-TUID: shzON9giF1i2 * build-aux/xgettext.scm: New script. * po/guix/Makevars (XGETTEXT): Set it. (XGETTEXT_OPTIONS): Add --xgettext option to `real' xgettext. * po/packages/Makevars (XGETTEXT): Set it. (XGETTEXT_OPTIONS): Add --xgettext option to `real' xgettext. Change-Id: I71b6b843970090f765f46ac346b92a346560e3f0 --- build-aux/xgettext.scm | 87 ++++++++++++++++++++++++++++++++++++++++++ po/guix/Makevars | 7 +++- po/packages/Makevars | 10 ++++- 3 files changed, 101 insertions(+), 3 deletions(-) create mode 100755 build-aux/xgettext.scm diff --git a/build-aux/xgettext.scm b/build-aux/xgettext.scm new file mode 100755 index 0000000000..e8a970f251 --- /dev/null +++ b/build-aux/xgettext.scm @@ -0,0 +1,87 @@ +#! /bin/sh +# -*-scheme-*- +build_aux=$(dirname $0) +srcdir=$build_aux/.. +exec guile --no-auto-compile -L $srcdir -C $srcdir -e main -s "$0" "$@" +!# + +;;; Copyright © 2024 Janneke Nieuwenhuizen +;;; +;;; This program is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + +;;;; Commentary: +;;; +;;; This script provides an xgettext wrapper to (re)set POT-Creation-Date from +;;; a Git timestamp. Test doing something like: +;;; +;;; build-aux/xgettext.scm --files-from=po/guix/POTFILES.in --default-domain=test +;;; +;;;; Code: + +(use-modules (srfi srfi-1) + (srfi srfi-26) + (ice-9 curried-definitions) + (ice-9 match) + (ice-9 popen) + (ice-9 rdelim) + (guix build utils)) + +(define ((option? name) option) + (string-prefix? name option)) + +(define (get-option args name) + (let ((option (find (option? name) args))) + (and option + (substring option (string-length name))))) + +(define (pipe-command command) + (let* ((port (apply open-pipe* OPEN_READ command)) + (output (read-string port))) + (close-port port) + output)) + + +;;; +;;; Entry point. +;;; +(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) + (let* ((files-from (get-option args "--files-from=")) + (default-domain (get-option args "--default-domain=")) + (directory (or (get-option args "--directory=") ".")) + (xgettext (or (get-option args "--xgettext=") "xgettext")) + (xgettext-args (filter (negate (option? "--xgettext=")) args)) + (command (match xgettext-args + ((xgettext.scm args ...) + `(,xgettext ,@args)))) + (result (apply system* command)) + (status (/ result 256))) + (if (or (not (zero? status)) + (not files-from)) + (exit status) + (let* ((text (with-input-from-file files-from read-string)) + (lines (string-split text #\newline)) + (files (filter (negate (cute string-prefix? "#" <>)) lines)) + (files (map (cute string-append directory "/" <>) files)) + (git-command `("git" "log" "--pretty=format:%ci" "-n1" ,@files)) + (timestamp (pipe-command git-command)) + (po-file (string-append default-domain ".po"))) + (when (string-null? timestamp) + (exit 1)) + (substitute* po-file + (("(\"POT-Creation-Date: )[^\\]*" all header) + (string-append header timestamp))))))) diff --git a/po/guix/Makevars b/po/guix/Makevars index 88a4e8c7bc..4cfd0f431d 100644 --- a/po/guix/Makevars +++ b/po/guix/Makevars @@ -5,6 +5,10 @@ DOMAIN = guix subdir = po/guix top_builddir = ../.. +# We use our xgettext.scm wrapper to produce .PO files reproducibly using a +# timestamp from Git. +XGETTEXT:=$(top_srcdir)/build-aux/xgettext.scm + # These options get passed to xgettext. We want to catch standard # gettext uses, and SRFI-35 error condition messages. In C++ code # we use 'n_' instead of the more usual 'N_' for no-ops. @@ -14,7 +18,8 @@ XGETTEXT_OPTIONS = \ --keyword=message \ --keyword=description \ --keyword=synopsis \ - --keyword=n_ + --keyword=n_ \ + --xgettext=$(XGETTEXT_) COPYRIGHT_HOLDER = the authors of Guix (msgids) diff --git a/po/packages/Makevars b/po/packages/Makevars index 65912786d8..0ba4f1ba7e 100644 --- a/po/packages/Makevars +++ b/po/packages/Makevars @@ -6,12 +6,18 @@ DOMAIN = guix-packages subdir = po/packages top_builddir = ../.. +# We use our xgettext.scm wrapper to produce .PO files reproducibly using a +# timestamp from Git. The `real' xgettext is passed as an option to +# xgettext.scm +XGETTEXT:=$(top_srcdir)/build-aux/xgettext.scm + # These options get passed to xgettext. We want to catch exclusively package # synopses and descriptions. XGETTEXT_OPTIONS = \ --language=Scheme --from-code=UTF-8 \ - --keyword=synopsis --keyword=description \ - --keyword=output-synopsis:2 + --keyword=synopsis --keyword=description \ + --keyword=output-synopsis:2 \ + --xgettext=$(XGETTEXT_) COPYRIGHT_HOLDER = the authors of Guix (msgids) -- 2.41.0