From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id 6B2ONPc7FGY0UQEAqHPOHw:P1 (envelope-from ) for ; Mon, 08 Apr 2024 20:48:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 6B2ONPc7FGY0UQEAqHPOHw (envelope-from ) for ; Mon, 08 Apr 2024 20:48:23 +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=YEH2xdBh; 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=1712602103; 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=ayXRRmKjJHsqNJtIiD6bfpWrcTEOto8i0xY81TFJtUph8Jckh6nd1gOshvo/aYpilMNTyV 5JIzJOLfbEkKqnUkPmoXRqX1gevx9R1atUGuecmgiGOwnpw2j2QHMbhOh0KLaZgo+237NQ HJFSypgOttxuMa+ghmcmy1D8xEV/APCf+DPDNKHfZOdASYajkCsku2Z2eykA0yIQpNxj/K hvBUL9BQoOTKUIixvnSENRbnjCAxb3YaIa6rSVaGdsmsstpnwB3RcggaZfSHUSUb2XE2+v aJPingx4bOYiaxj8Rk1og0HWfCuDNWVKHd3BrlRsIABPae0M2l2eboATwmNnig== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1712602103; a=rsa-sha256; cv=none; b=d6kvcKvNYpKewtB0Pn7Y0L7Dd23VaR0Sd28t/IB/sjw5S4MWuvICvhhfjShnq2tVTdmtCd qxcuG38JTmdCg/96XbUh57yw7zf+9+uQmXplzbo+coLWrZ/u1aJVUx7GVhp4FQh+lnUGT/ TEE8XOAISQqYfDOPGf3tzWq8bzzRrZQWHhGb0/pR+9zr2ErAjz9UPde4bF5kaskxXMBW1+ PT85kmJKzgpePGJokMQnhrtKYDaRGhrAvlrwtxeRSO//aLDVNNjXKKXqzOFxLKqC+nDcdn OpcSL3h7Kf1CbgEcdgvz76enyBc0qsRcm4B/ILO6u5Mk2/BprHuaezl0B8H0TQ== 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=YEH2xdBh; 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 A112A150F5 for ; Mon, 8 Apr 2024 20:48:23 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rtu2F-00047s-GJ; Mon, 08 Apr 2024 14:48:03 -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 1rtu2B-00043Q-2b for guix-patches@gnu.org; Mon, 08 Apr 2024 14:47:59 -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 1rtu2A-00056m-Qk for guix-patches@gnu.org; Mon, 08 Apr 2024 14:47:58 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rtu2H-0005XK-AD; Mon, 08 Apr 2024 14:48:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70169] [PATCH v3 08/13] 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: Mon, 08 Apr 2024 18:48:05 +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.171260206421032 (code B ref 70169); Mon, 08 Apr 2024 18:48:05 +0000 Received: (at 70169) by debbugs.gnu.org; 8 Apr 2024 18:47:44 +0000 Received: from localhost ([127.0.0.1]:47658 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rtu1s-0005SG-3b for submit@debbugs.gnu.org; Mon, 08 Apr 2024 14:47:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59300) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rtu1p-0005RC-2t for 70169@debbugs.gnu.org; Mon, 08 Apr 2024 14:47:37 -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 1rtu1c-00052T-7H; Mon, 08 Apr 2024 14:47:24 -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=YEH2xdBhPc4w3twW9zB/ N66lUZjNK6BRqxRtwgUtBA4UJvuswathKAmayPLRGVaHqckbA8N2Glho2/R+Eu+RmX+hT+gYtx5h5 +xns/3tDBHlH/AzMzWRY6DD7m0aAx+VE7dRgu5uzMqn8b2BGkizRyYsOhkzSSD+iSXfkDAUXOkRcf ysCUT/Ae3Cubsa4h/0wMr4jEmdXvVl2C0MQizbE7fA0K6UH2Oktt1nZkVN9sxhueUmJdvANRxqyne HAPQn5P4csQApQd9Zg7d+03yZJqI4W+DN+LWjDFQXSSWY/ZfJWEVWyGdtJaHvumsLJLdVIIYRkaaZ /o1USqoJWiTQYw==; From: Janneke Nieuwenhuizen Date: Mon, 8 Apr 2024 18:46:51 +0000 Message-ID: <166e00ca6ee00be9e6f353fc32bb4c5b3bc93bb8.1712600307.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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -6.07 X-Spam-Score: -6.07 X-Migadu-Queue-Id: A112A150F5 X-Migadu-Scanner: mx13.migadu.com X-TUID: MPwyKUkXmPWX * 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