GNU bug report logs - #42146
[PATCH core-updates 1/?] build: substitute: Don't fail silently.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Jakub Kądziołka <kuba@HIDDEN>; Keywords: patch; dated Tue, 30 Jun 2020 22:10:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 20 Oct 2023 15:39:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 20 11:39:41 2023
Received: from localhost ([127.0.0.1]:41238 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtrbB-0000ty-Bd
	for submit <at> debbugs.gnu.org; Fri, 20 Oct 2023 11:39:41 -0400
Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:54370)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@HIDDEN>) id 1qtrb9-0000th-7A
 for 42146 <at> debbugs.gnu.org; Fri, 20 Oct 2023 11:39:39 -0400
Received: by mail-qk1-x735.google.com with SMTP id
 af79cd13be357-7789a4c01easo59274685a.0
 for <42146 <at> debbugs.gnu.org>; Fri, 20 Oct 2023 08:39:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1697816346; x=1698421146; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=F3SxY+yyDTuA7OsgScSzM199hGmcfhJYuYfLKzt67FQ=;
 b=cufi3ZipZqp27gh/vy1VccyQgZrcynUh6ifKn1rIUNFe3ADMlKoiscPWDnO8+ZGHbA
 8xh02rpb8KI91awPsoX0PhkTzvQ+qzYdgXkrP60WEhZdqfKWzfOE+E04CKOgSxRwSosz
 veWPmUi57J+BYVFLtRKXPJ4JdZYnDbbcKHnskWxqwLG4mEfc1m+nHDNK3xKz/608GJjq
 Lks4MmZWtRrf8aSLLsFK9mRfkXK6TnS85HVRtaBu35fHWeJRmDbaOIh4D6qLhQmh+s3t
 GH6HUu9l9165sfGcZaPeQk7QskiYmeo5uC75jfyNpfI8Vyx+q1C31m6FlcwEbDhpzGGy
 FAvQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1697816346; x=1698421146;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from
 :to:cc:subject:date:message-id:reply-to;
 bh=F3SxY+yyDTuA7OsgScSzM199hGmcfhJYuYfLKzt67FQ=;
 b=KcDbWKN+NlvQzuIpSBNDC6GAQm7i99QJ5kpUPvQ8GWUeGfuaAi+uUeYJHnXKYTpsfD
 nlcMLCkVox7pP20cQ5Tit978H1Ws0YmjV+DE9DJ9htztHKvoMENa1TYij7tbY+x+h2/M
 ey0nxAGq4PoU22u+ChGV3iPWzM+z99msu7s/elkPxG6ADikVcSeMtsC0gCN2xpHPecje
 FsI3QKmK1L/Zh3sgiupPf2Wx6l/6QfoCdWrG4nwKJEwLteVU+ujxkkHUBkiN6hjfzrnJ
 skePE8qPlIm/rcR+j7cWzcBeY8P35gOqPaglLi9oxA8qDqdtcuJjmviLRgajIbZOYMa8
 1E5Q==
X-Gm-Message-State: AOJu0Yz0x9egm4E6YJrl+dEmuuWIyyiFEpx2CR3xHYUz3cPOeuU5mOUt
 Lcdh/hDlwAFrr7GyK5oi4jT/C7xuv20=
X-Google-Smtp-Source: AGHT+IHelFMBTH9UQ0OdAnaITOiMmu/lvjVWtsq46WxR/3LTMDiKJeZ62U1/aCrnxYESiGIeFSD3wA==
X-Received: by 2002:a05:6214:2aa4:b0:66d:4d2c:b0d3 with SMTP id
 js4-20020a0562142aa400b0066d4d2cb0d3mr2499970qvb.4.1697816346230; 
 Fri, 20 Oct 2023 08:39:06 -0700 (PDT)
Received: from hurd (dsl-156-111.b2b2c.ca. [66.158.156.111])
 by smtp.gmail.com with ESMTPSA id
 d9-20020a0cf0c9000000b0066d12d1351fsm751108qvl.143.2023.10.20.08.39.05
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 20 Oct 2023 08:39:05 -0700 (PDT)
From: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
To: Simon Tournier <zimon.toutoune@HIDDEN>
Subject: Re: [bug#42146] [PATCH core-updates 1/?] build: substitute: Don't
 fail silently.
In-Reply-To: <874jilmira.fsf@HIDDEN> (Simon Tournier's message of "Fri, 20
 Oct 2023 17:11:05 +0200")
References: <20200630220913.14665-1-kuba@HIDDEN>
 <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
 <87lebyxs4y.fsf_-_@HIDDEN> <874jilmira.fsf@HIDDEN>
Date: Fri, 20 Oct 2023 11:39:04 -0400
Message-ID: <8734y5i9rb.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
Cc: Jakub =?utf-8?B?S8SF?= =?utf-8?B?ZHppb8WCa2E=?= <kuba@HIDDEN>,
 Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, 42146 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

Simon Tournier <zimon.toutoune@HIDDEN> writes:

> Hi Ludo,
>
> On Thu, 19 Oct 2023 at 22:40, Ludovic Court=C3=A8s <ludo@HIDDEN> wrote:
>
>>> +;;;
>>> +;;; Extend regexp objects with a pattern field.
>>> +;;;
>>> +(define-record-type <regexp*>
>>> +  (%make-regexp* pat flag rx)
>>> +  regexp*?
>>> +  (pat regexp*-pattern)                 ;the regexp pattern, a string
>>> +  (flag regexp*-flag)                   ;regexp flags
>>> +  (rx regexp*-rx))                      ;the compiled regexp object
>>> +
>>> +;;; Work around regexp implementation.
>>> +;;; This record allows to track the regexp pattern and then display it.
>>> +(define* (make-regexp* pat #:optional (flag regexp/extended))
>>
>> I=E2=80=99m skeptical about the concrete benefits.  I would not include =
it in
>> (guix build utils), or at least not in this patch series.
>>
>> (I tend to be super conservative about (guix build utils) because we
>> rarely get a chance to change it.)
>
> If I remember correctly, the record was introduced in #58660 [1].
> Basically, if you have,
>
>               (make-regexp "^gnu/packages/python(-.+|)\\.scm$")
>
> then you only have access to some #<regexp 7f6315fb3500>.  Other said,
> you lost the human-readable "^gnu/packages/python(-.+|)\\.scm$" regexp
> pattern.  The workaround just stores this human-readable regexp pattern.
> Later, it is thus possible to display it; for debugging or else.
>
> For the location of such feature, I do not have an opinion.  For the
> concrete benefits, I have one. :-)
>
> Well, maybe the feature =E2=80=93 keep an access to the human-readable re=
gexp
> pattern =E2=80=93 could be implemented on Guile-side.

Agreed, for the long haul (as with many cool bits that are Guix specific
currently).

--=20
Thanks,
Maxim




Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 20 Oct 2023 15:26:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 20 11:26:23 2023
Received: from localhost ([127.0.0.1]:41208 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtrOJ-0000Pp-47
	for submit <at> debbugs.gnu.org; Fri, 20 Oct 2023 11:26:23 -0400
Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:38220)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1qtrOE-0000P0-Ej
 for 42146 <at> debbugs.gnu.org; Fri, 20 Oct 2023 11:26:19 -0400
Received: by mail-wr1-x430.google.com with SMTP id
 ffacd0b85a97d-32da4180ca2so151971f8f.1
 for <42146 <at> debbugs.gnu.org>; Fri, 20 Oct 2023 08:25:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1697815545; x=1698420345; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id
 :reply-to; bh=2mZk0WVr6Xg0sCIQhm6espXC6FInpPUvKaLbGTuBdfw=;
 b=fSVmO7gnZQy14s4wPr+RZ+CcCqY+q9icqsxD6oRK8PEaYEbPx3JSUCPkZhz9Z9CdQo
 bhBhR2p+e7uA+/8GrS/isWQOiuYKagV2w8V0K/fR0FC1eYxc60jd7DjJY6OAzTfGTwIe
 ZMjvu7bxYm3kJa6QhGowTpXCO3gdga6JJrVGC++fUDx/702ro+MiUUD1kedRd3znint0
 GZsKgbQGR5RahrOgyx1f6L+f1e1Wxd05k1XtvilpSDm5n/ELVBvzc9JC/ShrZ4rUVwi5
 MAnRU+fJNhzW5tdp2FSLnkXa6jkUZY4CIZZBUda4EML0GsYekNP3e0i3fo7GcgifEoe7
 v4Tw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1697815545; x=1698420345;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=2mZk0WVr6Xg0sCIQhm6espXC6FInpPUvKaLbGTuBdfw=;
 b=xBnHR3kfKDl56CJik4+ibyrHwRYW+weaUn63kxa/Nlt039+HsGmGbJoSU83tg8zfmk
 Pp7nuxYBgdGyHMYT+6EtJAsLcn+bvvuZGlraVEWZjgQiw3AQ/sYJNE9eMw11Nxhlbrsd
 ac6XPDURzrJiq/zp1TYRgbc7akWblzRNsn80j0brzoLno/COcD/Y5nTCO8qebp2LQ/Di
 bWkM90Lf1iFh8y672woTvanMjCGZzQsl3n629nzZZwlT6CewXPPuWl90uXhZBjo7I/TL
 c5SkQrZKyDsUIdR8zT+j6DJFkYGkgsJoyeyJ2kehR16bTk4YjIkLsdkB5inuPCwumSZ3
 +b8g==
X-Gm-Message-State: AOJu0YwwuvOPe+KRCd0HUIzccjtqFCkVLYycuUYYGGeCHQg8y2Zpqm9X
 4aoxyz4E2pJw75Lu/oOPx+gPQaGwSqI=
X-Google-Smtp-Source: AGHT+IFxqtEoRIYyH3qMBkrAmXe1hzS4V3GzYEuPfUUNenkIO+mCuiDupUj8ZnKYG1qvaD6KCXm56Q==
X-Received: by 2002:adf:ef52:0:b0:32d:e4b9:4851 with SMTP id
 c18-20020adfef52000000b0032de4b94851mr1470848wrp.7.1697815545402; 
 Fri, 20 Oct 2023 08:25:45 -0700 (PDT)
Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id
 f4-20020a5d50c4000000b0032da319a27asm1928471wrt.9.2023.10.20.08.25.44
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 20 Oct 2023 08:25:45 -0700 (PDT)
From: Simon Tournier <zimon.toutoune@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Maxim Cournoyer
 <maxim.cournoyer@HIDDEN>
Subject: Re: [bug#42146] [PATCH core-updates 1/?] build: substitute: Don't
 fail silently.
In-Reply-To: <87lebyxs4y.fsf_-_@HIDDEN>
References: <20200630220913.14665-1-kuba@HIDDEN>
 <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
 <87lebyxs4y.fsf_-_@HIDDEN>
Date: Fri, 20 Oct 2023 17:11:05 +0200
Message-ID: <874jilmira.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
Cc: Jakub =?utf-8?B?S8SFZHppb8WCa2E=?= <kuba@HIDDEN>,
 42146 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Ludo,

On Thu, 19 Oct 2023 at 22:40, Ludovic Court=C3=A8s <ludo@HIDDEN> wrote:

>> +;;;
>> +;;; Extend regexp objects with a pattern field.
>> +;;;
>> +(define-record-type <regexp*>
>> +  (%make-regexp* pat flag rx)
>> +  regexp*?
>> +  (pat regexp*-pattern)                 ;the regexp pattern, a string
>> +  (flag regexp*-flag)                   ;regexp flags
>> +  (rx regexp*-rx))                      ;the compiled regexp object
>> +
>> +;;; Work around regexp implementation.
>> +;;; This record allows to track the regexp pattern and then display it.
>> +(define* (make-regexp* pat #:optional (flag regexp/extended))
>
> I=E2=80=99m skeptical about the concrete benefits.  I would not include i=
t in
> (guix build utils), or at least not in this patch series.
>
> (I tend to be super conservative about (guix build utils) because we
> rarely get a chance to change it.)

If I remember correctly, the record was introduced in #58660 [1].
Basically, if you have,

              (make-regexp "^gnu/packages/python(-.+|)\\.scm$")

then you only have access to some #<regexp 7f6315fb3500>.  Other said,
you lost the human-readable "^gnu/packages/python(-.+|)\\.scm$" regexp
pattern.  The workaround just stores this human-readable regexp pattern.
Later, it is thus possible to display it; for debugging or else.

For the location of such feature, I do not have an opinion.  For the
concrete benefits, I have one. :-)

Well, maybe the feature =E2=80=93 keep an access to the human-readable rege=
xp
pattern =E2=80=93 could be implemented on Guile-side.

Or maybe there is another simpler way that I am not aware of?

Cheers,
simon


1: https://issues.guix.gnu.org/58660




Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 20 Oct 2023 00:58:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 20:58:40 2023
Received: from localhost ([127.0.0.1]:38248 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtdqZ-0003k0-Ou
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 20:58:40 -0400
Received: from mail-qv1-xf2b.google.com ([2607:f8b0:4864:20::f2b]:57766)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@HIDDEN>) id 1qtdqU-0003jI-8T
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 20:58:34 -0400
Received: by mail-qv1-xf2b.google.com with SMTP id
 6a1803df08f44-66d1ef93284so1846436d6.3
 for <42146 <at> debbugs.gnu.org>; Thu, 19 Oct 2023 17:58:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1697763481; x=1698368281; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=Okco+31FqmL/2OCY1wTsGhnDcafE/pDvBRDkBKQDPMQ=;
 b=aD+J7qj0wzdhyo/s9o/3AXEL9x8CD1em8R2Uv0XT/GngQFOEA0Ix+I8kK5HrLpBBEF
 KNvgbAI+cRKYyI2sXjBoGvZkihQTh3T6AePJ1kMnW1BEOXgrSBIBp8W4aGg/ZXxwYwTJ
 Vvf4yaUgfC3odrFRSCiEuPoq2UKX+TDCnRNHFT8aP8dyjqjzA/8Y2XcEZctx1U/NSraH
 eAj2BL4ry5bh92M50x5NLMBoUM2G2gvYcTD5DMZuRRrAsGZZO+0p6GoBNyNwqNKCAKE2
 AnWOZTn6QGBciMF4WpZw+B7+YZO+VoN2RME7VhcWVsyeGQg1TMgKcDk75qmMGAAoAvn3
 PpMw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1697763481; x=1698368281;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=Okco+31FqmL/2OCY1wTsGhnDcafE/pDvBRDkBKQDPMQ=;
 b=PDtSoIX3DO67IsKMPhqlLqR4Wu7bhKvbvBA3rHLoDcxCmYq4ZmJwexsdbDbwCPLS6H
 KHqPsV2rWqt3SJvBot/o1VxLIsZfa90ENWsjFu2LMSxoXILQ3SUVJGReegyJk/nWJYsI
 5C2sk5S1DPCm6xoVVZVAkvRyFa2dgffO3xxIByMvHi37wgnhDxyRny0kjk8TkbJ1vNSO
 AHOBPRcdBY266CXuRMNO+s3K+Nndy15lynHkP7Ua88a6k2vxL0P/NhhkSQbrvE9NUx1i
 U4EYzWUfwx8AH4Cf3LWPxJq36Mz5Xa8CsvPo2r+SkQAzbprS7Nc2/pAqIB09XLRT7jgi
 sC7A==
X-Gm-Message-State: AOJu0YwrplRQ8NAbe0WGf8ELyQ7u+L8CSX4B45oHPzWfWhq+BhcB2TMr
 /yzV4LnMeYL+QQwDqOYYet3Za0OK0L23sA==
X-Google-Smtp-Source: AGHT+IHOeyg2TlEhzsDG7QYDtqv0C6wCL/uCNhGfkHtGddGZCAeNQkqnKQPedJhYS+Ay1qDn0g0RDg==
X-Received: by 2002:a05:6214:519e:b0:66d:140a:18f3 with SMTP id
 kl30-20020a056214519e00b0066d140a18f3mr541647qvb.45.1697763481643; 
 Thu, 19 Oct 2023 17:58:01 -0700 (PDT)
Received: from localhost.localdomain (dsl-156-111.b2b2c.ca. [66.158.156.111])
 by smtp.gmail.com with ESMTPSA id
 h9-20020a0cf8c9000000b0065d0a4262e0sm279097qvo.70.2023.10.19.17.58.00
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 19 Oct 2023 17:58:01 -0700 (PDT)
From: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH v3 3/3] build: bootstrap-configure: Allow lack of matches in
 substitute.
Date: Thu, 19 Oct 2023 20:57:40 -0400
Message-ID: <0d8764ba1b635d49c07cc1d47f3dcc620bbf482d.1697763444.git.maxim.cournoyer@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697763444.git.maxim.cournoyer@HIDDEN>
References: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697763444.git.maxim.cournoyer@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Jakub Kądziołka <kuba@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
Cc: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <kuba@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

From: Jakub Kądziołka <kuba@HIDDEN>

Matches are not required here, as not every file will use every
variable.

* guix/build/gnu-bootstrap.scm (bootstrap-configure): Pass
  #:require-matches? #f to substitute*.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Change-Id: I7eee433a3af5fa310b3f2e8b8b58ac9befb4b56a
---
 guix/build/gnu-bootstrap.scm | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/guix/build/gnu-bootstrap.scm b/guix/build/gnu-bootstrap.scm
index b4257a3717..b097f410ad 100644
--- a/guix/build/gnu-bootstrap.scm
+++ b/guix/build/gnu-bootstrap.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2020, 2022 Timothy Sample <samplet@HIDDEN>
+;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -52,7 +53,8 @@ (define (bootstrap-configure name version modules scripts)
                     (copy-file template target)
                     (substitute* target
                       (("@PACKAGE_NAME@") name)
-                      (("@VERSION@") version))))
+                      (("@VERSION@") version)
+                      #:require-matches? #f)))
                 (append-map (lambda (dir) (find-files dir "\\.in$"))
                             modules))
       (for-each (lambda (template)
@@ -62,12 +64,12 @@ (define (bootstrap-configure name version modules scripts)
                     (substitute* target
                       (("@GUILE@") guile)
                       (("@MODDIR@") moddir)
-                      (("@GODIR@") godir))
+                      (("@GODIR@") godir)
+                      #:require-matches? #f)
                     (chmod target #o755)))
                 (find-files scripts
                             (lambda (fn st)
-                              (string-suffix? ".in" fn))))
-      #t)))
+                              (string-suffix? ".in" fn)))))))
 
 (define (bootstrap-build modules)
   "Create a procedure that builds an early bootstrap package.  The
-- 
2.41.0





Information forwarded to kuba@HIDDEN, maxim.cournoyer@HIDDEN, ludo@HIDDEN, guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 20 Oct 2023 00:58:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 20:58:38 2023
Received: from localhost ([127.0.0.1]:38246 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtdqU-0003jb-Ix
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 20:58:38 -0400
Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:47167)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@HIDDEN>) id 1qtdqO-0003j9-BQ
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 20:58:32 -0400
Received: by mail-qv1-xf2f.google.com with SMTP id
 6a1803df08f44-66d13ac2796so1888046d6.2
 for <42146 <at> debbugs.gnu.org>; Thu, 19 Oct 2023 17:58:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1697763475; x=1698368275; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=b8visCM1R1nOmFaZmfOgo/UFjx68QHhn/qnzsKsQeAg=;
 b=fYv1je81APKTsJHbV9G021GqdvuqdJEOrNmp2WQ0WUiazmrxHuYtz55PnspYBzl4Jv
 +SJvcGjrxjruNQubqTyG7mBtoZsH/ahkc2MiJMfhEnoibnrTnGmG5VGE4d62N0PliE7w
 dRDRHSSoVQKm/kFSg5cYVNB0dOQkxSdKTDh0bIp/MaqY6WAdYy3yvx5pewi4cgMKgtAt
 ER8vRy2C7hcyzSIMWjQ1ey+ZZzIPG2eWu53aKXlEu+TtMUE3ZJmEeu1RcuAGRvgSCdbe
 RATJ1pr8FtANKROMccMw+9qnB3LJN6ZwIIlnRScAtDCDEn0+5RPoHwG6S8DDNxQ9m83y
 2GCg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1697763475; x=1698368275;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=b8visCM1R1nOmFaZmfOgo/UFjx68QHhn/qnzsKsQeAg=;
 b=jitFJH448g91fKKm8O63DROdN0WXC6kDIFLu4/y8v5qBNghHnNqJoZh36eC6wHGfN5
 guzbG/HSupt4R6wi8fzzYTMwR90i+5mRKQvzRSK2lrxj3zO8S4OB365NL/aSTcnFWWmc
 pP2RFI1dmoGCxOn2z2nhMIbe08Da4h+tzjW/Zp5sghLiRWV14uiq2Kc6w9ptWVEz3h4q
 KKOVPP4lkio5vKwUmK8lx9ZxAXPcuj90idZ1ZUYwdUd/1H6T3w81unkBJzp7kAJTDvCi
 oLFyNpMaPXieuzsBSLmYf29PlX6bstVMTnEVfmpSr6EQ6mT4fHHajGxsZnhakHqMtsRy
 qMVw==
X-Gm-Message-State: AOJu0YwJ8ifcE6Qv/WP766lzudr0cvdBf66kYDUlFIbyaQdN0FfXmzir
 +z4UOR48fF/UXxh/W3FTkhFspNuNvwAVxQ==
X-Google-Smtp-Source: AGHT+IEJVakeO2yux+B7vvrMP2473/ogqwLqgym3fKCN/Q3Do0ZvCANcovJqXZBFZSkb7PR+sQaKaQ==
X-Received: by 2002:a05:6214:230f:b0:66d:62b7:53f4 with SMTP id
 gc15-20020a056214230f00b0066d62b753f4mr517492qvb.45.1697763475332; 
 Thu, 19 Oct 2023 17:57:55 -0700 (PDT)
Received: from localhost.localdomain (dsl-156-111.b2b2c.ca. [66.158.156.111])
 by smtp.gmail.com with ESMTPSA id
 h9-20020a0cf8c9000000b0065d0a4262e0sm279097qvo.70.2023.10.19.17.57.54
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 19 Oct 2023 17:57:54 -0700 (PDT)
From: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH v3 1/3] build: Relocate <regexp*> record and associated
 procedures here.
Date: Thu, 19 Oct 2023 20:57:38 -0400
Message-ID: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697763444.git.maxim.cournoyer@HIDDEN>
X-Mailer: git-send-email 2.41.0
MIME-Version: 1.0
X-Debbugs-Cc: Jakub Kądziołka <kuba@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
Cc: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* etc/teams.scm.in (<regexp*>, make-regexp*, regexp*-exec): Move to...
* guix/build/utils.scm: ... here.
(list-matches*): New procedure.

Change-Id: I566ac372f7d8ba08de94e19b54dcc68da2106a23
---
 etc/teams.scm.in     | 19 +------------------
 guix/build/utils.scm | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/etc/teams.scm.in b/etc/teams.scm.in
index 55242caad1..8af25b9802 100644
--- a/etc/teams.scm.in
+++ b/etc/teams.scm.in
@@ -34,29 +34,12 @@
              (srfi srfi-9)
              (srfi srfi-26)
              (ice-9 format)
-             (ice-9 regex)
              (ice-9 match)
              (ice-9 rdelim)
+             (guix build utils)
              (guix ui)
              (git))
 
-(define-record-type <regexp*>
-  (%make-regexp* pat flag rx)
-  regexp*?
-  (pat regexp*-pattern)
-  (flag regexp*-flag)
-  (rx regexp*-rx))
-
-;;; Work around regexp implementation.
-;;; This record allows to track the regexp pattern and then display it.
-(define* (make-regexp* pat #:optional (flag regexp/extended))
-  "Alternative to `make-regexp' producing annotated <regexp*> objects."
-  (%make-regexp* pat flag (make-regexp pat flag)))
-
-(define (regexp*-exec rx* str)
-  "Execute the RX* regexp, a <regexp*> object."
-  (regexp-exec (regexp*-rx rx*) str))
-
 (define-record-type <team>
   (make-team id name description members scope)
   team?
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 8e630ad586..2b3a8e278b 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@HIDDEN>
 ;;; Copyright © 2021 Brendan Tildesley <mail@HIDDEN>
+;;; Copyright © 2022 Simon Tournier <zimon.toutoune@HIDDEN>
 ;;; Copyright © 2023 Carlo Zancanaro <carlo@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -28,6 +29,7 @@
 
 (define-module (guix build utils)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
@@ -55,6 +57,14 @@ (define-module (guix build utils)
             package-name->name+version
             parallel-job-count
 
+            make-regexp*
+            regexp*-exec
+            regexp*?
+            regexp*-pattern
+            regexp*-flag
+            regexp*-rx
+            list-matches*
+
             compressor
             tarball?
             %xz-parallel-args
@@ -163,6 +173,35 @@ (define-syntax-rule (define-constant name val)
    (module-replace! (current-module) '(setvbuf)))
   (else #f))
 
+
+;;;
+;;; Extend regexp objects with a pattern field.
+;;;
+(define-record-type <regexp*>
+  (%make-regexp* pat flag rx)
+  regexp*?
+  (pat regexp*-pattern)                 ;the regexp pattern, a string
+  (flag regexp*-flag)                   ;regexp flags
+  (rx regexp*-rx))                      ;the compiled regexp object
+
+;;; Work around regexp implementation.
+;;; This record allows to track the regexp pattern and then display it.
+(define* (make-regexp* pat #:optional (flag regexp/extended))
+  "Alternative to `make-regexp' producing annotated <regexp*> objects."
+  (%make-regexp* pat flag (make-regexp pat flag)))
+
+(define (regexp*-exec rx* str)
+  "Execute the RX* regexp, a <regexp*> object."
+  (regexp-exec (regexp*-rx rx*) str))
+
+(define* (list-matches* regexp str #:optional (flags regexp/extended))
+  "Like 'list-matches', but also accepting a regexp* as REGEXP."
+  (match regexp
+    ((or (? string?) (? regexp?))
+     (list-matches regexp str flags))
+    ((? regexp*?)
+     (list-matches (regexp*-rx regexp) str flags))))
+
 
 ;;;
 ;;; Compression helpers.

base-commit: d59653b7c9e43ebdbba20e2ca071429507f94c67
-- 
2.41.0





Information forwarded to kuba@HIDDEN, maxim.cournoyer@HIDDEN, ludo@HIDDEN, guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 20 Oct 2023 00:58:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 20:58:34 2023
Received: from localhost ([127.0.0.1]:38243 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtdqT-0003jY-OW
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 20:58:34 -0400
Received: from mail-vs1-xe33.google.com ([2607:f8b0:4864:20::e33]:54714)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@HIDDEN>) id 1qtdqR-0003jD-CA
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 20:58:32 -0400
Received: by mail-vs1-xe33.google.com with SMTP id
 ada2fe7eead31-4580a2ec248so87551137.1
 for <42146 <at> debbugs.gnu.org>; Thu, 19 Oct 2023 17:58:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1697763478; x=1698368278; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=2eiEVVW1YIPDVs3/30xqVWj4WCnrhALxoLlMnwbevBc=;
 b=IoKCbPRX35cahet1V/Dzbj+HX18OnMOHFotZRlCTd0/B2kTHs+RJ+oWcO9lZYOmEtI
 IioWxCnUsx+iYskfZ/Ia0gFGf2Q4DBgTtfhTNflV+aZPRUk1HAt1WBGoGN5Yq22feKdL
 DpObCGX4Fe9zc5iB/Y+bFifLdMgNL7fzVrI3rfHdjH8c/hyq/JSzlywM1ZRXq9yLXd6p
 Uk3AYW2OWCneLucuGejW6+T4ZLJ0Eayg9Oqwhb81Tbun6IvD71Xc2Ahh8U7FInv9ZSRR
 8eIu2PyHsF2U6Afqz/5YE0TA54GtoUe9LxXQdL7m5uXHub5U1QGX0SsVCnGvxIUS5z88
 Bupg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1697763478; x=1698368278;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=2eiEVVW1YIPDVs3/30xqVWj4WCnrhALxoLlMnwbevBc=;
 b=rPZ7FPqphoYnjKWiQXsX5Jzd3eWsiX2jVdmppg82AQZIU9VccaN0uz59d/GqcA3/bV
 Vf2674tTO7TvV7/XY6lB7Pu1HYyVsGB5EOc+qhYYz+IxfpJW5n8QC0xS8ctSBE0d1+5t
 ZDvyOUgMzWt/NwqoXJRS2byes2CRnscOsjBcVS9IOcJAiVkSt5KCPB1T66zJroxxVEB1
 BN1yO1QHkaiRXzfUHE6wYPCWGsibAOKX6NN0ZOTlhJT/aurOXisP/VBSskO5EKySsxRl
 +cTEfcbZ6H6HAZnMp/GKCh7RYLxIgvUshSLoCzVXV2eUQ3+jXQHYy0Ngv7Ia6qnMSWKZ
 Dk6g==
X-Gm-Message-State: AOJu0Ywt1LJcsT05HvPH15a66wqfiunS6j/VTDmRqA+lZo4t762dKpcA
 yFeSz0uAXSxeq7qdmebYmXcgh5rgVsUp3g==
X-Google-Smtp-Source: AGHT+IFfRU5dHNsQoMCxDMmAySoleppZPRIpE66fblrMLPEF5zzKO8dSii5CS3s278SeXBnLIP/A1A==
X-Received: by 2002:a05:6102:20c4:b0:457:7138:fa74 with SMTP id
 i4-20020a05610220c400b004577138fa74mr552529vsr.35.1697763478521; 
 Thu, 19 Oct 2023 17:57:58 -0700 (PDT)
Received: from localhost.localdomain (dsl-156-111.b2b2c.ca. [66.158.156.111])
 by smtp.gmail.com with ESMTPSA id
 h9-20020a0cf8c9000000b0065d0a4262e0sm279097qvo.70.2023.10.19.17.57.57
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 19 Oct 2023 17:57:58 -0700 (PDT)
From: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH v3 2/3] build: substitute: Error when no substitutions were
 done.
Date: Thu, 19 Oct 2023 20:57:39 -0400
Message-ID: <d80dd0e1134cf608c69f3aaa0769f95a37f35e55.1697763444.git.maxim.cournoyer@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697763444.git.maxim.cournoyer@HIDDEN>
References: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697763444.git.maxim.cournoyer@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Jakub Kądziołka <kuba@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
Cc: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <kuba@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

From: Jakub Kądziołka <kuba@HIDDEN>

* guix/build/utils.scm (substitute, substitute*)
[require-matches?]: New argument.
* tests/build-utils.scm ("substitute*"): New test group.
("substitute*, no match error")
("substitute*, partial no match error"): New tests.

Co-authored-by: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Change-Id: I66ed33d72aa73cd35e5642521efec70bf756f86e
---
 guix/build/utils.scm  | 93 +++++++++++++++++++++++++++++++++----------
 tests/build-utils.scm | 68 +++++++++++++++++++++----------
 2 files changed, 118 insertions(+), 43 deletions(-)

diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 2b3a8e278b..8e4b8321dd 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -6,7 +6,8 @@
 ;;; Copyright © 2018, 2022 Arun Isaac <arunisaac@HIDDEN>
 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@HIDDEN>
 ;;; Copyright © 2020 Efraim Flashner <efraim@HIDDEN>
-;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
+;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
+;;; Copyright © 2020, 2021, 2023 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@HIDDEN>
 ;;; Copyright © 2021 Brendan Tildesley <mail@HIDDEN>
 ;;; Copyright © 2022 Simon Tournier <zimon.toutoune@HIDDEN>
@@ -111,8 +112,14 @@ (define-module (guix build utils)
             modify-phases
 
             with-atomic-file-replacement
+            %substitute-requires-matches?
             substitute
             substitute*
+            &substitute-error
+            substitute-error?
+            substitute-error-file
+            substitute-error-patterns
+
             dump-port
             set-file-time
             patch-shebang
@@ -971,24 +978,51 @@ (define (replace-char c1 c2 s)
                         c))
                   s)))
 
-(define (substitute file pattern+procs)
+(define-condition-type &substitute-error &error
+  substitute-error?
+  (file substitute-error-file)
+  (patterns substitute-error-patterns))
+
+(define %substitute-requires-matches?
+  (make-parameter #t))
+
+(define* (substitute file pattern+procs
+                     #:key (require-matches? (%substitute-requires-matches?)))
   "PATTERN+PROCS is a list of regexp/two-argument-procedure pairs.  For each
 line of FILE, and for each PATTERN that it matches, call the corresponding
 PROC as (PROC LINE MATCHES); PROC must return the line that will be written as
 a substitution of the original line.  Be careful about using '$' to match the
-end of a line; by itself it won't match the terminating newline of a line."
-  (let ((rx+proc  (map (match-lambda
-                        (((? regexp? pattern) . proc)
+end of a line; by itself it won't match the terminating newline of a line.
+
+By default, SUBSTITUTE will raise a &substitute-error condition if one of the
+patterns fails to match.  REQUIRE-MATCHES? can be set to false when lack of
+matches is acceptable (e.g. if you have multiple potential patterns not
+guaranteed to be found in FILE)."
+  (define (rx->pattern m)
+    (match m
+      ((? regexp? pattern)
+       "<unknown pattern (regexp)>")
+      ((? regexp*? pattern)
+       (regexp*-pattern pattern))
+      ((? string? pattern)
+       pattern)))
+
+  (let ((rx+proc (map (match-lambda
+                        (((or (? regexp? pattern) (? regexp*? pattern)) . proc)
                          (cons pattern proc))
                         ((pattern . proc)
-                         (cons (make-regexp pattern regexp/extended)
-                               proc)))
-                       pattern+procs)))
+                         (cons (make-regexp* pattern regexp/extended) proc)))
+                      pattern+procs)))
     (with-atomic-file-replacement file
       (lambda (in out)
-        (let loop ((line (read-line in 'concat)))
+        (let loop ((line (read-line in 'concat))
+                   (unmatched-regexps (map first rx+proc)))
           (if (eof-object? line)
-              #t
+              (when (and require-matches? (not (null? unmatched-regexps)))
+                (raise (condition
+                        (&substitute-error
+                         (file file)
+                         (patterns (map rx->pattern unmatched-regexps))))))
               ;; Work around the fact that Guile's regexp-exec does not handle
               ;; NUL characters (a limitation of the underlying GNU libc's
               ;; regexec) by temporarily replacing them by an unused private
@@ -998,19 +1032,23 @@ (define (substitute file pattern+procs)
                                     (unused-private-use-code-point line))
                                #\nul))
                      (line* (replace-char #\nul nul* line))
-                     (line1* (fold (lambda (r+p line)
-                                     (match r+p
-                                       ((regexp . proc)
-                                        (match (list-matches regexp line)
-                                          ((and m+ (_ _ ...))
-                                           (proc line m+))
-                                          (_ line)))))
-                                   line*
-                                   rx+proc))
+                     (results           ;line, unmatched-regexps
+                      (fold (lambda (r+p results)
+                              (let ((line (first results))
+                                    (unmatched (second results)))
+                                (match r+p
+                                  ((regexp . proc)
+                                   (match (list-matches* regexp line)
+                                     ((and m+ (_ _ ...))
+                                      (list (proc line m+)
+                                            (delq regexp unmatched)))
+                                     (_ (list line unmatched)))))))
+                            (list line* unmatched-regexps)
+                            rx+proc))
+                     (line1* (first results))
                      (line1 (replace-char nul* #\nul line1*)))
                 (display line1 out)
-                (loop (read-line in 'concat)))))))))
-
+                (loop (read-line in 'concat) (second results)))))))))
 
 (define-syntax let-matches
   ;; Helper macro for `substitute*'.
@@ -1048,9 +1086,19 @@ (define-syntax substitute*
 Alternatively, FILE may be a list of file names, in which case they are
 all subject to the substitutions.
 
+By default, SUBSTITUTE* will raise a &message condition if one of the patterns
+fails to match on one of the files; REQUIRE-MATCHES? may be set to false to
+avoid an error being raised in such condition.
+
 Be careful about using '$' to match the end of a line; by itself it won't
 match the terminating newline of a line."
     ((substitute* file ((regexp match-var ...) body ...) ...)
+     (substitute* file
+       ((regexp match-var ...) body ...) ...
+       #:require-matches? #t))
+    ((substitute* file
+       ((regexp match-var ...) body ...) ...
+       #:require-matches? require-matches?)
      (let ()
        (define (substitute-one-file file-name)
          (substitute
@@ -1074,7 +1122,8 @@ (define-syntax substitute*
                                       (begin body ...)
                                       (substring l o (match:start m))
                                       r))))))))
-                ...)))
+                ...)
+          #:require-matches? require-matches?))
 
        (match file
          ((files (... ...))
diff --git a/tests/build-utils.scm b/tests/build-utils.scm
index 3babf5d544..35c66faa3c 100644
--- a/tests/build-utils.scm
+++ b/tests/build-utils.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2015, 2016, 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@HIDDEN>
-;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
+;;; Copyright © 2021, 2023 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2021 Maxime Devos <maximedevos@HIDDEN>
 ;;; Copyright © 2021 Brendan Tildesley <mail@HIDDEN>
 ;;;
@@ -289,26 +289,52 @@ (define (arg-test bash-args)
 (test-assert "wrap-script, argument handling, bash --norc"
   (arg-test " --norc"))
 
-(test-equal "substitute*, text contains a NUL byte, UTF-8"
-  "c\0d"
-  (with-fluids ((%default-port-encoding "UTF-8")
-                (%default-port-conversion-strategy 'error))
-    ;; The GNU libc is locale sensitive.  Depending on the value of LANG, the
-    ;; test could fail with "string contains #\\nul character: ~S" or "cannot
-    ;; convert wide string to output locale".
-    (setlocale LC_ALL "en_US.UTF-8")
-    (call-with-temporary-output-file
-     (lambda (file port)
-       (format port "a\0b")
-       (flush-output-port port)
-
-       (substitute* file
-         (("a") "c")
-         (("b") "d"))
-
-       (with-input-from-file file
-         (lambda _
-           (get-string-all (current-input-port))))))))
+(define-syntax-rule (define-substitute*-test test-type name expected
+                      content clauses ...)
+  (test-type
+   name
+   expected
+   (with-fluids ((%default-port-encoding "UTF-8")
+                 (%default-port-conversion-strategy 'error))
+     ;; The GNU libc is locale sensitive.  Depending on the value of LANG,
+     ;; the test could fail with "string contains #\\nul character: ~S" or
+     ;; "cannot convert wide string to output locale".
+     (setlocale LC_ALL "en_US.UTF-8")
+     (call-with-temporary-output-file
+      (lambda (file port)
+        (format port content)
+        (flush-output-port port)
+
+        (substitute* file
+          clauses ...)
+
+        (with-input-from-file file
+          (lambda _
+            (get-string-all (current-input-port)))))))))
+
+(define-substitute*-test test-equal
+  "substitute*, text contains a NUL byte, UTF-8"
+  "c\0d"                              ;expected
+  "a\0b"                              ;content
+  (("a") "c")
+  (("b") "d"))
+
+(define-substitute*-test test-error "substitute*, no match error"
+  #t                                  ;expected
+  "a\0b"                              ;content
+  (("Oops!") "c"))
+
+(define-substitute*-test test-equal "substitute*, no match, ignored"
+  "abc"                                 ;expected
+  "abc"                                 ;content
+  (("Oops!") "c")
+  #:require-matches? #f)
+
+(define-substitute*-test test-error "substitute*, partial no match error"
+  #t                                  ;expected
+  "a\0b"                              ;content
+  (("a") "c"
+   ("Oops!") "c"))
 
 (test-equal "search-input-file: exception if not found"
   `((path)
-- 
2.41.0





Information forwarded to kuba@HIDDEN, maxim.cournoyer@HIDDEN, ludo@HIDDEN, guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 19 Oct 2023 23:55:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 19:55:39 2023
Received: from localhost ([127.0.0.1]:38224 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtcrW-0001cS-Ns
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 19:55:39 -0400
Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]:53435)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@HIDDEN>) id 1qtcrQ-0001c5-Ev
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 19:55:33 -0400
Received: by mail-yb1-xb2a.google.com with SMTP id
 3f1490d57ef6-d9c2420e417so260083276.2
 for <42146 <at> debbugs.gnu.org>; Thu, 19 Oct 2023 16:55:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1697759695; x=1698364495; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=L9kLZcRUZlfCXVUUHPUJL7lHrlzZ74gYL10hQlIy3O0=;
 b=TjBy8VO9eDtND+MhbhRbpbBxako95TrGBxHwFcdGHHS4LnZM9sEkJfleWV7AgQvKBC
 vJWEf2QKLEkmATTHB9lcq1J+sOpKMo7D9pd5Ev6HVFliYtT1LEo6CoGfMfpgbrZ+4Tff
 62UxcPcIudnzM7a78yCcnhaUlymfV2X2JByca8Lo/mnO919GHmK7AN0FbasgWaD2vn8e
 1wlBc9JodQl7XtHaKM+wlR9LZBceLZf4/4/pJtriHVSh0zguL7nKDWL7mUT0V7BROYga
 D7r5etrA0BSLxJGoozNkSkGPzWS0mT7+clGNiGNj0A5vkRCz9G7a95SMsplO0qY/LTFE
 R8FA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1697759695; x=1698364495;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from
 :to:cc:subject:date:message-id:reply-to;
 bh=L9kLZcRUZlfCXVUUHPUJL7lHrlzZ74gYL10hQlIy3O0=;
 b=SbpuvJlsBVK426Ncu7NyReBAXl5G8WyWDzjh7rMR4OG/lStP8k+2zYKlREHomO8V+1
 HT7D7rdqCSUnWFzx+BZgOC/qpwH3hsDYhWuVC7q15ic+NN/Y7c9eqy0KDG6rdE4b09S1
 /89Z0lmwbGdciWoNg19Gu4YgsNpRAa8UVh5Bo22B2O7DMEBSNS1m02/I2ugBinUfNk3q
 d+bcKvHVwgf1PedpP06BPeH7HNF7mixwioj9LjEHnnukYyNYzS40Yb7ew8aNQEB6qlFs
 zQB0c9PwbLR9f59qG6ZzTzEF8bDS20gvGWM3JDA/u4h0yDN7TfJ1EIbyB7li1NAkmxEw
 PG3A==
X-Gm-Message-State: AOJu0YwyQQRegc5QzelfIJ+4/dpQHwP2yv5VDKdnw4vZ2p25tq7sSyPG
 u0uoPh9asr9WkzO4CDjdiEggJUZZc/jm6g==
X-Google-Smtp-Source: AGHT+IFu3+yU+d0J3kp1Tu8835UPtlMfXCbkPMONduRw7O8ZPGgAnM19FMezz+qr93D9aYo+CnD36A==
X-Received: by 2002:a05:6902:136d:b0:d9a:3bf2:54a6 with SMTP id
 bt13-20020a056902136d00b00d9a3bf254a6mr254754ybb.46.1697759695337; 
 Thu, 19 Oct 2023 16:54:55 -0700 (PDT)
Received: from hurd (dsl-156-111.b2b2c.ca. [66.158.156.111])
 by smtp.gmail.com with ESMTPSA id
 fu8-20020a05622a5d8800b004181138e0c0sm188009qtb.31.2023.10.19.16.54.54
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 19 Oct 2023 16:54:54 -0700 (PDT)
From: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: bug#42146: [PATCH core-updates 1/?] build: substitute: Don't
 fail silently.
In-Reply-To: <87lebyxs4y.fsf_-_@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s?=
 =?utf-8?Q?=22's?= message of "Thu, 19 Oct 2023 22:40:45 +0200")
References: <20200630220913.14665-1-kuba@HIDDEN>
 <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
 <87lebyxs4y.fsf_-_@HIDDEN>
Date: Thu, 19 Oct 2023 19:54:53 -0400
Message-ID: <87pm1anp6a.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
Cc: Jakub =?utf-8?B?S8SFZHppb8WCa2E=?= <kuba@HIDDEN>,
 42146 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Ludo,

Ludovic Court=C3=A8s <ludo@HIDDEN> writes:

> Hi,
>
> Maxim Cournoyer <maxim.cournoyer@HIDDEN> skribis:
>
>> * etc/teams.scm.in (<regexp*>, make-regexp*, regexp*-exec): Move to...
>> * guix/build/utils.scm: ... here.
>> (list-matches*): New procedure.
>
>
> [...]
>
>> +++ b/guix/build/utils.scm
>
> [...]
>
>> +;;;
>> +;;; Extend regexp objects with a pattern field.
>> +;;;
>> +(define-record-type <regexp*>
>> +  (%make-regexp* pat flag rx)
>> +  regexp*?
>> +  (pat regexp*-pattern)                 ;the regexp pattern, a string
>> +  (flag regexp*-flag)                   ;regexp flags
>> +  (rx regexp*-rx))                      ;the compiled regexp object
>> +
>> +;;; Work around regexp implementation.
>> +;;; This record allows to track the regexp pattern and then display it.
>> +(define* (make-regexp* pat #:optional (flag regexp/extended))
>
> I=E2=80=99m skeptical about the concrete benefits.  I would not include i=
t in
> (guix build utils), or at least not in this patch series.
>
> (I tend to be super conservative about (guix build utils) because we
> rarely get a chance to change it.)

The original users are substitute* and the teams.scm script.  Since
substitute* is from (guix build utils), it makes sense to add it there
as well, since they are coupled.

The benefit is concrete: it makes it possible to show which regexp
pattern failed to match (its textual representation), instead of
something much less useful such as a generic placeholder such as
"<unknown> (regexp)".

It's in actual use if you look at the definition of substitute:

--8<---------------cut here---------------start------------->8---

  (let ((rx+proc (map (match-lambda
                        (((or (? regexp? pattern) (? regexp*? pattern)) . p=
roc)
                         (cons pattern proc))
                        ((pattern . proc)
                         (cons (make-regexp* pattern regexp/extended) proc)=
))
                      pattern+procs)))
--8<---------------cut here---------------end--------------->8---

The previous version followed a different approach, annotating the
rx+proc list with the raw pattern; I think the approach here is a bit
cleaner, and it should also enable users to pass pre-computed regexp*
objects to substitute* and have useful error messages produced.

--=20
Thanks,
Maxim




Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 19 Oct 2023 20:52:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 16:52:18 2023
Received: from localhost ([127.0.0.1]:37987 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qta0A-00041B-DV
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:52:18 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59154)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1qta08-00040y-9e
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:52:16 -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 <ludo@HIDDEN>)
 id 1qtZzb-0005V0-RC; Thu, 19 Oct 2023 16:51:43 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=bMYJvslEynCB9T5ZdVE0Wrj4VsSFqeYTNnpymSI5xP0=; b=K1mFWsPd9gEKGyl/y7zo
 LMAHGHq10GG4fEYcdtw4KGUJ4M8S5WKdvVoJIKsHp0bYqWwHqIBSUcAJiMgJSQzIiE4Bw1rrPedak
 XskicOK8aDYjlPgCpXh45V0Zp+FvaKRrRm8c4Vp+8EfQHon/IPGIjBiEmJvdI6MqiZw1TTEGm8a0u
 l9IQF0vqVG9DQU24EWeOKBeAf4DOTyrGFTV621nnpQ5Oow2lmuc/mSCW5gv25orkv+A/APcoieLOA
 q1awNcef4bTupL7CVP3psyLk/Jduzo99vtqA1kNXE+CC2hSMYCzF6UYoiKQvQT1PoAjyKFqMUi39a
 0pxq1q9xWJUDZg==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Subject: Re: bug#42146: [PATCH core-updates 1/?] build: substitute: Don't
 fail silently.
In-Reply-To: <28fd2bd2039b4a4c0fe8fdaf1adbfb5956f683d5.1697747385.git.maxim.cournoyer@HIDDEN>
 (Maxim Cournoyer's message of "Thu, 19 Oct 2023 16:33:34 -0400")
References: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
 <28fd2bd2039b4a4c0fe8fdaf1adbfb5956f683d5.1697747385.git.maxim.cournoyer@HIDDEN>
Date: Thu, 19 Oct 2023 22:51:40 +0200
Message-ID: <874jimxrmr.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 42146
Cc: Jakub =?utf-8?B?S8SFZHppb8WCa2E=?= <kuba@HIDDEN>,
 42146 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Maxim Cournoyer <maxim.cournoyer@HIDDEN> skribis:

> From: Jakub K=C4=85dzio=C5=82ka <kuba@HIDDEN>
>
> Matches are not required here, as not every file will use every
> variable.
>
> * guix/build/gnu-bootstrap.scm (bootstrap-configure): Pass
>   #:require-matches? #f to substitute*.
>
> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@HIDDEN>

To me these two special cases suggest we may discover other more cases
where it=E2=80=99s okay to not match and we=E2=80=99d think.  We=E2=80=99ll=
 need a dedicated
branch built on ci.guix to assess that.

Thanks for working on it!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 19 Oct 2023 20:50:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 16:50:25 2023
Received: from localhost ([127.0.0.1]:37982 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtZyK-0003yF-R5
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:50:25 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:38680)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1qtZyF-0003xz-Lc
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:50:22 -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 <ludo@HIDDEN>)
 id 1qtZxi-0004tl-PQ; Thu, 19 Oct 2023 16:49:46 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=zuWWY0EBa6XTUOyTJOGcuek5mx1N2NbbFt3fZW8glSg=; b=cqY4Eog/vabsZCVrfZrC
 Z1Nwl7xXWRiKfkEC8nIy4hYkJxvOmVNz+UljIG6GQ6fe8hgac42bKWLMFzea+UzEEO5aRLOc2arrE
 40bh3AXtjAphGWo/pUITBXvgibapg0I9cf1/QpdwNUFWEOIARHMfKN62LA2IW4WBLXfzw5LOHXsqr
 cpUHXTZ5iKhhNgAgztdPQVf/YCmmgFg5hK7VsTUECUzdI6OxcmuzIAHlQHhr5ph3nAbFKddgxnK7Z
 vtAyl9TBtaKxqYlyvuetfNLxpc//fXGDplQ30eW9QeiI+yoz4kTLVwrD0QHf5DsusNbujv1g1eas1
 M/1dQKhLABRa2g==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Subject: Re: bug#42146: [PATCH core-updates 1/?] build: substitute: Don't
 fail silently.
In-Reply-To: <cafb034c8454eff36ab6f8c40df6fc1699915923.1697747385.git.maxim.cournoyer@HIDDEN>
 (Maxim Cournoyer's message of "Thu, 19 Oct 2023 16:33:33 -0400")
References: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
 <cafb034c8454eff36ab6f8c40df6fc1699915923.1697747385.git.maxim.cournoyer@HIDDEN>
Date: Thu, 19 Oct 2023 22:49:44 +0200
Message-ID: <878r7yxrpz.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 42146
Cc: Jakub =?utf-8?B?S8SFZHppb8WCa2E=?= <kuba@HIDDEN>,
 42146 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Maxim Cournoyer <maxim.cournoyer@HIDDEN> skribis:

> From: Jakub K=C4=85dzio=C5=82ka <kuba@HIDDEN>
>
> * guix/build/utils.scm (substitute, substitute*)
> [require-matches?]: New argument.
> * tests/build-utils.scm ("substitute*"): New test group.
> ("substitute*, no match error")
> ("substitute*, partial no match error"): New tests.
>
> Co-authored-by: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
> Change-Id: I66ed33d72aa73cd35e5642521efec70bf756f86e

[...]

> -(define (substitute file pattern+procs)
> +(define* (substitute file pattern+procs #:key (require-matches? #t))
>    "PATTERN+PROCS is a list of regexp/two-argument-procedure pairs.  For =
each
>  line of FILE, and for each PATTERN that it matches, call the correspondi=
ng

As discussed on IRC recently, I=E2=80=99d suggest:

  #:key (require-matches? (%substitute-requires-matches?))

where:

  (define %substitute-requires-matches?
    (make-parameter #t))

That way it=E2=80=99ll be easier to change the default for entire builds if=
 we
need to.

> +              (when require-matches?
> +                (let ((failed-patterns (lset-difference
> +                                        string=3D?
> +                                        (delete-duplicates
> +                                         (map rx->pattern failed-matches=
))
> +                                        (delete-duplicates
> +                                         (map rx->pattern ok-matches)))))

That=E2=80=99s potentially costly.

Would it be enough to thread a list of unmatched regexps, and to
(delq rx unmatched) every time RX is matched?  (This is O(N) but N, the
number of regexps, is typically a handful.)

Then at the end, we=E2=80=99d check whether UNMATCHED is empty.

> +                  (when (not (null? failed-patterns))
> +                    (raise (make-condition failed-patterns)))))

SRFI-35 =E2=80=98make-condition=E2=80=99 expects different arguments.

Should probably be: (raise (condition (&substitute-error =E2=80=A6))).

> +    ((substitute* file #:require-matches? require-matches?
> +                  ((regexp match-var ...) body ...) ...)

Maybe rather:

   (substitute* file
                ((regexp match-var ...) body ...) ...
                #:require-matches? require-matches?)

That way we formatting remains unchanged.

> +(test-group "substitute*"

I=E2=80=99d avoid groups: they=E2=80=99re not super useful and the output w=
ith the
Automake driver is terrible.

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 19 Oct 2023 20:41:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 16:41:27 2023
Received: from localhost ([127.0.0.1]:37976 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtZpe-00016J-PQ
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:41:27 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:37940)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1qtZpZ-000162-Ma
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:41:25 -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 <ludo@HIDDEN>)
 id 1qtZp2-00005J-Nn; Thu, 19 Oct 2023 16:40:48 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=fVfnr0IPelKl3mq4+SXmIo7JR0GBYjPEYKfseEK3XMs=; b=aCuNaP0lqIjpyvHmmivk
 MQRMRHQkGO/KWvbE6cY7/QwP3j0kBC5ljrcJ/Rz57yUzS9DQtaa06s+9hU0ptMn/0KD0ACRdESVGb
 lSIOki+EYAItmaLr27K81QFx3RI3JblUO3gUyYwObFdy07Ac6gfS6lmZrp7VZfCVkdmSX5Bq8ivFS
 3wVu8ppUaloGRJkokICCA8i2+cn+zmOOieAJQdKQKxgWTPDM+4ayju/43ETMtlxMWbOjttwXPWBAD
 BbKlAwGwlMpVmgrrxN28Obyxt8dqRX5YpOqvM3z56se92wIR16s1+sjsWzPtLz+TTnRhc8Ic8sYaM
 8bckEgjJtBtlvA==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Subject: Re: bug#42146: [PATCH core-updates 1/?] build: substitute: Don't
 fail silently.
In-Reply-To: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
 (Maxim Cournoyer's message of "Thu, 19 Oct 2023 16:33:32 -0400")
References: <20200630220913.14665-1-kuba@HIDDEN>
 <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
Date: Thu, 19 Oct 2023 22:40:45 +0200
Message-ID: <87lebyxs4y.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 42146
Cc: Jakub =?utf-8?B?S8SFZHppb8WCa2E=?= <kuba@HIDDEN>,
 42146 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

Maxim Cournoyer <maxim.cournoyer@HIDDEN> skribis:

> * etc/teams.scm.in (<regexp*>, make-regexp*, regexp*-exec): Move to...
> * guix/build/utils.scm: ... here.
> (list-matches*): New procedure.


[...]

> +++ b/guix/build/utils.scm

[...]

> +;;;
> +;;; Extend regexp objects with a pattern field.
> +;;;
> +(define-record-type <regexp*>
> +  (%make-regexp* pat flag rx)
> +  regexp*?
> +  (pat regexp*-pattern)                 ;the regexp pattern, a string
> +  (flag regexp*-flag)                   ;regexp flags
> +  (rx regexp*-rx))                      ;the compiled regexp object
> +
> +;;; Work around regexp implementation.
> +;;; This record allows to track the regexp pattern and then display it.
> +(define* (make-regexp* pat #:optional (flag regexp/extended))

I=E2=80=99m skeptical about the concrete benefits.  I would not include it =
in
(guix build utils), or at least not in this patch series.

(I tend to be super conservative about (guix build utils) because we
rarely get a chance to change it.)

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 19 Oct 2023 20:34:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 16:34:49 2023
Received: from localhost ([127.0.0.1]:37946 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtZjF-0000vh-44
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:34:49 -0400
Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:46194)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@HIDDEN>) id 1qtZj9-0000v2-52
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:34:44 -0400
Received: by mail-qk1-x736.google.com with SMTP id
 af79cd13be357-7788fb06997so4984485a.0
 for <42146 <at> debbugs.gnu.org>; Thu, 19 Oct 2023 13:34:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1697747650; x=1698352450; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=r4Q9z/d9a8INLP5xbQe9cf87MBMZAubiof6Yyn2YFqk=;
 b=XU2qcXCic7CtC3U6rZZsrzgNdL6xmjp+0/8Fr3h05S4DHQSifeWWUySNaRSc5+Z3EZ
 o5e6+VJFvsFMBpSJhvkH+CsSamYQZZRu6XT0M6G2H/aV0oHuS0eYvXoNKnAAz5lhH09J
 O0tXpfx+2+hms9i4mafcEgOKdQ1tSiZwHoXK1K6w6diaQFXcbRW9V7IWrSBLfzmMLcNJ
 viRFwRclMi1BnA5Ocw1eLBU3hFxtWyH1ko2lGcYCvm32RgOQUzfZZ41/xlLq/gbX3oEO
 hfotn7Hz3TBmyEQr2qZ5KECiEt42cZMV/oHLvG6BgwLxgWpqis7J0z40Lz7J2lmd/fW4
 EFgA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1697747650; x=1698352450;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=r4Q9z/d9a8INLP5xbQe9cf87MBMZAubiof6Yyn2YFqk=;
 b=S5D4/S/Ffe6ipqqSGYNiuJVp//GteoixmBgasgHLckwYFHR7lFR0AUDNeLVBOZ+7vm
 RLWcSkQPm5JD26QD9CCbjm/bVqM+/VY8IlTzB17JcuzSmIPLpH27Q4Ga4k6JqHPlVtm4
 10d8V0Be6KIMOgt/MbvER1uqraXFmAjheHuIYTQicshU2/9oRR94MY8wMAeyF/35mPsz
 8sdoikNT68TeSARVa6BerxvTkv0qUj1ot2DNNDNtFw7ziwsfy65DfoifcC6iV83kg7Oz
 mtVSPoAzwY2agXUeIXI/zlAijiBo328RewWGGFmWoNWyME2kGhW0Rk/+MufWgZ9kVjn4
 pyyw==
X-Gm-Message-State: AOJu0Yzx7/+rmIv2yHDqV8ylv6Zpvw8DK8iWHgEGG43YlxYeas4S4WSz
 gV79w+5AxBIi/i1HCLIRPQJiepiOfI2waw==
X-Google-Smtp-Source: AGHT+IFAl3wHepBCuXv7hTlSDku/g7bxD+o60LKTzOyTWfkHQlZU7JJLfblDAc02FszRhsTDFCnjdA==
X-Received: by 2002:a05:620a:430f:b0:76e:f638:bcd9 with SMTP id
 u15-20020a05620a430f00b0076ef638bcd9mr3523055qko.38.1697747650613; 
 Thu, 19 Oct 2023 13:34:10 -0700 (PDT)
Received: from localhost.localdomain (dsl-156-111.b2b2c.ca. [66.158.156.111])
 by smtp.gmail.com with ESMTPSA id
 2-20020a05620a070200b0077413b342e9sm76591qkc.128.2023.10.19.13.34.09
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 19 Oct 2023 13:34:10 -0700 (PDT)
From: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH 3/3] build: bootstrap-configure: Allow lack of matches in
 substitute.
Date: Thu, 19 Oct 2023 16:33:34 -0400
Message-ID: <28fd2bd2039b4a4c0fe8fdaf1adbfb5956f683d5.1697747385.git.maxim.cournoyer@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
References: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Jakub Kądziołka <kuba@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
Cc: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <kuba@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

From: Jakub Kądziołka <kuba@HIDDEN>

Matches are not required here, as not every file will use every
variable.

* guix/build/gnu-bootstrap.scm (bootstrap-configure): Pass
  #:require-matches? #f to substitute*.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
---
 guix/build/gnu-bootstrap.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/guix/build/gnu-bootstrap.scm b/guix/build/gnu-bootstrap.scm
index b4257a3717..d044c8acd9 100644
--- a/guix/build/gnu-bootstrap.scm
+++ b/guix/build/gnu-bootstrap.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2020, 2022 Timothy Sample <samplet@HIDDEN>
+;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -51,6 +52,7 @@ (define (bootstrap-configure name version modules scripts)
                   (let ((target (string-drop-right template 3)))
                     (copy-file template target)
                     (substitute* target
+                      #:require-matches? #f
                       (("@PACKAGE_NAME@") name)
                       (("@VERSION@") version))))
                 (append-map (lambda (dir) (find-files dir "\\.in$"))
@@ -60,14 +62,14 @@ (define (bootstrap-configure name version modules scripts)
                   (let ((target (string-drop-right template 3)))
                     (copy-file template target)
                     (substitute* target
+                      #:require-matches? #f
                       (("@GUILE@") guile)
                       (("@MODDIR@") moddir)
                       (("@GODIR@") godir))
                     (chmod target #o755)))
                 (find-files scripts
                             (lambda (fn st)
-                              (string-suffix? ".in" fn))))
-      #t)))
+                              (string-suffix? ".in" fn)))))))
 
 (define (bootstrap-build modules)
   "Create a procedure that builds an early bootstrap package.  The
-- 
2.41.0





Information forwarded to kuba@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 19 Oct 2023 20:34:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 16:34:48 2023
Received: from localhost ([127.0.0.1]:37944 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtZjD-0000vU-8E
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:34:47 -0400
Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:47290)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@HIDDEN>) id 1qtZj6-0000uz-DZ
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:34:41 -0400
Received: by mail-qk1-x72d.google.com with SMTP id
 af79cd13be357-7788db95652so3878185a.2
 for <42146 <at> debbugs.gnu.org>; Thu, 19 Oct 2023 13:34:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1697747648; x=1698352448; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=oTAbCUEBY4/PaAlLb3JRnahAdJdeX/zaSLEJfY7+90g=;
 b=aigGrMq5FpRYclutciNokFrhbtz5FbX8/+vifefVTLPWmE6/OA5/tVoojMfaJcXZ2Z
 0hzO5oSgshZ5p4o2hS9/rksQRywXE7d4I3d8SODSiarDrLKn/3rEICH0Pjc9ndIg3QWF
 BN3UypVZSFu3Kfx1rPtHJY1DHNhG8rew6u1u68UeNp1R/yENLp0zyPu/jlePukzWmJHB
 Ag3rinz+5fn7QHn9mn5ZVpSLK//X9aVf1hx0vgrskD8itsVICYINn0Ok36PqoNHW7rkK
 XGrOhqXonWe/GrwpsT/B2KK+EiOzkPF/1hVJNGvURb9eggwx2NTerRgfxQWniKvLXrWT
 G98A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1697747648; x=1698352448;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=oTAbCUEBY4/PaAlLb3JRnahAdJdeX/zaSLEJfY7+90g=;
 b=IADZxhjW81S5sZXWI4KRaCu9Y7pSues3bHaW0ZtJrjeJRZszBHwDHNIFzLI5YF4h8W
 EFy6qCNR8+ElPAMt6yA/AI9bR+qUiTdrMNRMM3UNu5kLbOpPyuo4CaS851w9cnZ2+yxA
 qOWzTtoT5dcqdiS4+eCXLPg+z9ChpLRezZpwkNgb7nlNTJywQNNsf4cIpMPUCdJrIoDA
 wT79PgUYSww/sKDdt50u7lPDdO2hiy0HOawzhEPxigDIx5YqiaCbYOGS/5Ee+Al5DfE/
 9wDjpRJ5e2GFPQw8ADK2+B6KrFDyvvEkit99K+QjIAPKfIAOcplRAG+S6jzJ6/kOYKwx
 jWsw==
X-Gm-Message-State: AOJu0Yzz7GcXz3qcHVlpl1ACsfT/UMSRLZwWXGhIwWgF0AbFDgLoP9XK
 LIhVf8UWPJ+YYfHtRSMp+ELYu5LRg7J3ZA==
X-Google-Smtp-Source: AGHT+IH3r47NdrEpahDPXiMGSZCz+rO/hZa9dCzcOtNVbE0KEcgI/qFhbXrZPzm4LX87wc0K+K5MrA==
X-Received: by 2002:a05:620a:29c2:b0:775:903e:388c with SMTP id
 s2-20020a05620a29c200b00775903e388cmr3062568qkp.2.1697747647630; 
 Thu, 19 Oct 2023 13:34:07 -0700 (PDT)
Received: from localhost.localdomain (dsl-156-111.b2b2c.ca. [66.158.156.111])
 by smtp.gmail.com with ESMTPSA id
 2-20020a05620a070200b0077413b342e9sm76591qkc.128.2023.10.19.13.34.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 19 Oct 2023 13:34:07 -0700 (PDT)
From: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH 2/3] build: substitute: Error when no substitutions were done.
Date: Thu, 19 Oct 2023 16:33:33 -0400
Message-ID: <cafb034c8454eff36ab6f8c40df6fc1699915923.1697747385.git.maxim.cournoyer@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
References: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Jakub Kądziołka <kuba@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
Cc: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <kuba@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

From: Jakub Kądziołka <kuba@HIDDEN>

* guix/build/utils.scm (substitute, substitute*)
[require-matches?]: New argument.
* tests/build-utils.scm ("substitute*"): New test group.
("substitute*, no match error")
("substitute*, partial no match error"): New tests.

Co-authored-by: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Change-Id: I66ed33d72aa73cd35e5642521efec70bf756f86e
---
 guix/build/utils.scm  | 94 +++++++++++++++++++++++++++++++++----------
 tests/build-utils.scm | 63 +++++++++++++++++++----------
 2 files changed, 114 insertions(+), 43 deletions(-)

diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 2b3a8e278b..7bfb6560e1 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -6,7 +6,8 @@
 ;;; Copyright © 2018, 2022 Arun Isaac <arunisaac@HIDDEN>
 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@HIDDEN>
 ;;; Copyright © 2020 Efraim Flashner <efraim@HIDDEN>
-;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
+;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
+;;; Copyright © 2020, 2021, 2023 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@HIDDEN>
 ;;; Copyright © 2021 Brendan Tildesley <mail@HIDDEN>
 ;;; Copyright © 2022 Simon Tournier <zimon.toutoune@HIDDEN>
@@ -971,24 +972,53 @@ (define (replace-char c1 c2 s)
                         c))
                   s)))
 
-(define (substitute file pattern+procs)
+(define* (substitute file pattern+procs #:key (require-matches? #t))
   "PATTERN+PROCS is a list of regexp/two-argument-procedure pairs.  For each
 line of FILE, and for each PATTERN that it matches, call the corresponding
 PROC as (PROC LINE MATCHES); PROC must return the line that will be written as
 a substitution of the original line.  Be careful about using '$' to match the
-end of a line; by itself it won't match the terminating newline of a line."
-  (let ((rx+proc  (map (match-lambda
-                        (((? regexp? pattern) . proc)
+end of a line; by itself it won't match the terminating newline of a line.
+
+By default, SUBSTITUTE will raise a &message condition if one of the patterns
+fails to match.  REQUIRE-MATCHES? can be set to false when lack of matches is
+acceptable (e.g. if you have multiple potential patterns not guaranteed to be
+found in FILE)."
+  (define (rx->pattern m)
+    (match m
+      ((? regexp? pattern)
+       "<unknown pattern (regexp)>")
+      ((? regexp*? pattern)
+       (regexp*-pattern pattern))
+      ((? string? pattern)
+       pattern)))
+
+  (define (make-condition failed-matches)
+    (condition
+     (&message
+      (message (format #f "substitute: `~a': no match for patterns `~a'"
+                       file failed-matches)))))
+
+  (let ((rx+proc (map (match-lambda
+                        (((or (? regexp? pattern) (? regexp*? pattern)) . proc)
                          (cons pattern proc))
                         ((pattern . proc)
-                         (cons (make-regexp pattern regexp/extended)
-                               proc)))
-                       pattern+procs)))
+                         (cons (make-regexp* pattern regexp/extended) proc)))
+                      pattern+procs)))
     (with-atomic-file-replacement file
       (lambda (in out)
-        (let loop ((line (read-line in 'concat)))
+        (let loop ((line (read-line in 'concat))
+                   (ok-matches '())
+                   (failed-matches '()))
           (if (eof-object? line)
-              #t
+              (when require-matches?
+                (let ((failed-patterns (lset-difference
+                                        string=?
+                                        (delete-duplicates
+                                         (map rx->pattern failed-matches))
+                                        (delete-duplicates
+                                         (map rx->pattern ok-matches)))))
+                  (when (not (null? failed-patterns))
+                    (raise (make-condition failed-patterns)))))
               ;; Work around the fact that Guile's regexp-exec does not handle
               ;; NUL characters (a limitation of the underlying GNU libc's
               ;; regexec) by temporarily replacing them by an unused private
@@ -998,19 +1028,30 @@ (define (substitute file pattern+procs)
                                     (unused-private-use-code-point line))
                                #\nul))
                      (line* (replace-char #\nul nul* line))
-                     (line1* (fold (lambda (r+p line)
-                                     (match r+p
-                                       ((regexp . proc)
-                                        (match (list-matches regexp line)
-                                          ((and m+ (_ _ ...))
-                                           (proc line m+))
-                                          (_ line)))))
-                                   line*
-                                   rx+proc))
+                     (results           ;line, ok-matches and failed-matches
+                      (fold (lambda (r+p results)
+                              (let ((line (first results))
+                                    (ok-matches (second results))
+                                    (failed-matches (third results)))
+                                (match r+p
+                                  ((regexp . proc)
+                                   (match (list-matches* regexp line)
+                                     ((and m+ (_ _ ...))
+                                      (list (proc line m+)
+                                            (cons regexp ok-matches)
+                                            failed-matches))
+                                     (_
+                                      (list line
+                                            ok-matches
+                                            (cons regexp failed-matches))))))))
+                            (list line* '() '())
+                            rx+proc))
+                     (line1* (first results))
+                     (ok-matches (second results))
+                     (failed-matches (third results))
                      (line1 (replace-char nul* #\nul line1*)))
                 (display line1 out)
-                (loop (read-line in 'concat)))))))))
-
+                (loop (read-line in 'concat) ok-matches failed-matches))))))))
 
 (define-syntax let-matches
   ;; Helper macro for `substitute*'.
@@ -1048,9 +1089,17 @@ (define-syntax substitute*
 Alternatively, FILE may be a list of file names, in which case they are
 all subject to the substitutions.
 
+By default, SUBSTITUTE* will raise a &message condition if one of the patterns
+fails to match on one of the files; REQUIRE-MATCHES? may be set to false to
+avoid an error being raised in such condition.
+
 Be careful about using '$' to match the end of a line; by itself it won't
 match the terminating newline of a line."
     ((substitute* file ((regexp match-var ...) body ...) ...)
+     (substitute* file #:require-matches? #t
+                  ((regexp match-var ...) body ...) ...))
+    ((substitute* file #:require-matches? require-matches?
+                  ((regexp match-var ...) body ...) ...)
      (let ()
        (define (substitute-one-file file-name)
          (substitute
@@ -1074,7 +1123,8 @@ (define-syntax substitute*
                                       (begin body ...)
                                       (substring l o (match:start m))
                                       r))))))))
-                ...)))
+                ...)
+          #:require-matches? require-matches?))
 
        (match file
          ((files (... ...))
diff --git a/tests/build-utils.scm b/tests/build-utils.scm
index 3babf5d544..890fbca16f 100644
--- a/tests/build-utils.scm
+++ b/tests/build-utils.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2015, 2016, 2019, 2020 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@HIDDEN>
-;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
+;;; Copyright © 2021, 2023 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2021 Maxime Devos <maximedevos@HIDDEN>
 ;;; Copyright © 2021 Brendan Tildesley <mail@HIDDEN>
 ;;;
@@ -289,26 +289,47 @@ (define (arg-test bash-args)
 (test-assert "wrap-script, argument handling, bash --norc"
   (arg-test " --norc"))
 
-(test-equal "substitute*, text contains a NUL byte, UTF-8"
-  "c\0d"
-  (with-fluids ((%default-port-encoding "UTF-8")
-                (%default-port-conversion-strategy 'error))
-    ;; The GNU libc is locale sensitive.  Depending on the value of LANG, the
-    ;; test could fail with "string contains #\\nul character: ~S" or "cannot
-    ;; convert wide string to output locale".
-    (setlocale LC_ALL "en_US.UTF-8")
-    (call-with-temporary-output-file
-     (lambda (file port)
-       (format port "a\0b")
-       (flush-output-port port)
-
-       (substitute* file
-         (("a") "c")
-         (("b") "d"))
-
-       (with-input-from-file file
-         (lambda _
-           (get-string-all (current-input-port))))))))
+(test-group "substitute*"
+  (define-syntax-rule (define-substitute*-test test-type name expected
+                        content clauses ...)
+    (test-type
+     name
+     expected
+     (with-fluids ((%default-port-encoding "UTF-8")
+                   (%default-port-conversion-strategy 'error))
+       ;; The GNU libc is locale sensitive.  Depending on the value of LANG,
+       ;; the test could fail with "string contains #\\nul character: ~S" or
+       ;; "cannot convert wide string to output locale".
+       (setlocale LC_ALL "en_US.UTF-8")
+       (call-with-temporary-output-file
+        (lambda (file port)
+          (format port content)
+          (flush-output-port port)
+
+          (substitute* file
+            clauses ...)
+
+          (with-input-from-file file
+            (lambda _
+              (get-string-all (current-input-port)))))))))
+
+  (define-substitute*-test test-equal
+    "substitute*, text contains a NUL byte, UTF-8"
+    "c\0d"                              ;expected
+    "a\0b"                              ;content
+    (("a") "c")
+    (("b") "d"))
+
+  (define-substitute*-test test-error "substitute*, no match error"
+    #t                                  ;expected
+    "a\0b"                              ;content
+    (("Oops!") "c"))
+
+  (define-substitute*-test test-error "substitute*, partial no match error"
+    #t                                  ;expected
+    "a\0b"                              ;content
+    (("a") "c"
+     ("Oops!") "c")))
 
 (test-equal "search-input-file: exception if not found"
   `((path)
-- 
2.41.0





Information forwarded to kuba@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 19 Oct 2023 20:34:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 16:34:47 2023
Received: from localhost ([127.0.0.1]:37942 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtZj9-0000vI-AK
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:34:47 -0400
Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:53679)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@HIDDEN>) id 1qtZj3-0000uv-P6
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 16:34:41 -0400
Received: by mail-qk1-x72c.google.com with SMTP id
 af79cd13be357-7789cb322deso3477585a.3
 for <42146 <at> debbugs.gnu.org>; Thu, 19 Oct 2023 13:34:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1697747645; x=1698352445; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=b8visCM1R1nOmFaZmfOgo/UFjx68QHhn/qnzsKsQeAg=;
 b=ZN3ZytrOSkoPV3PTQaE1mAar2RlNnWmqgMs1eUJnLtPW5QYVB8f3z+ETfhqDnFw1DS
 XyavybpqF03vu1wUn37gRq17HNTkbrOjgAw4oyHai8tgBky7hY6NGNRQaA/QxtH0hIAW
 Pb0u8CKyr2zoBfMzP4MnLVK05A79UctLns1v85Ta/8/wkalN6l36ICOFAi7ESSKQon4+
 1Ae8JJTz3BU8D0tV1gLHkHWCJ1HetFbnWCCw56TCEjuCuy7/Hbdtjw62LL5lqX1PJ2Em
 T5U0x3yELnvQ1o/Z7GAqvIOeIP4v7BWHxMdrbd2lt6sY9z6JIlAoh3YHe0WyIL4bC4oO
 eWBw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1697747645; x=1698352445;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=b8visCM1R1nOmFaZmfOgo/UFjx68QHhn/qnzsKsQeAg=;
 b=ZxcAquP9GiFSEo55HE/e7UF9MDsvAS9ZPWpca4BgE2OTuZn++bxCM8Vz4pWkIgiu8n
 SCyNxBgNdbpxrkHJyZivfM2vWBjhk42Cg6BOvpQ5VcbK7Lv6DbTDMTCXwJu7JWjhcWPd
 Lr/9mdtMdzqjth6e+o4LJtDKp1QVlwkrZs8MPGYzSd1XrF/uqqcfE4iVMcbhD1y3Lrjb
 6Y9/YmGl0na0+4auI/al8y10TAzAOSvDKRcwLda6EB77r3PZ7ACOvRn0WcU6borfd1XS
 JwfcqC9PBFfIF5slrnZEnMm5GbbtnYtoS9tYFfWLUFgG1dtJM2rc5Kdk1RSRPuV7zzIh
 I87A==
X-Gm-Message-State: AOJu0Yy4UcYO5QrjiSDMvsyioUbWrb8JzRF4JdfVrpGJwbDOvFyxRhSO
 zG+bBTapLnbVAlTYyTfp3ccFG1eoEnfN8Q==
X-Google-Smtp-Source: AGHT+IFA9mzRE/o856F/91XgvZa7sQElpq+DUlYXjrLLxGzsRTInleEEv8Plk+fACFYJFEpXs4lzng==
X-Received: by 2002:a05:620a:4548:b0:76f:2899:3a96 with SMTP id
 u8-20020a05620a454800b0076f28993a96mr3923889qkp.0.1697747644695; 
 Thu, 19 Oct 2023 13:34:04 -0700 (PDT)
Received: from localhost.localdomain (dsl-156-111.b2b2c.ca. [66.158.156.111])
 by smtp.gmail.com with ESMTPSA id
 2-20020a05620a070200b0077413b342e9sm76591qkc.128.2023.10.19.13.34.03
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 19 Oct 2023 13:34:03 -0700 (PDT)
From: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH 1/3] build: Relocate <regexp*> record and associated
 procedures here.
Date: Thu, 19 Oct 2023 16:33:32 -0400
Message-ID: <ff182177822369c7d31698ecbf0cb5dcbca37644.1697747385.git.maxim.cournoyer@HIDDEN>
X-Mailer: git-send-email 2.41.0
MIME-Version: 1.0
X-Debbugs-Cc: Jakub Kądziołka <kuba@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
Cc: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* etc/teams.scm.in (<regexp*>, make-regexp*, regexp*-exec): Move to...
* guix/build/utils.scm: ... here.
(list-matches*): New procedure.

Change-Id: I566ac372f7d8ba08de94e19b54dcc68da2106a23
---
 etc/teams.scm.in     | 19 +------------------
 guix/build/utils.scm | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/etc/teams.scm.in b/etc/teams.scm.in
index 55242caad1..8af25b9802 100644
--- a/etc/teams.scm.in
+++ b/etc/teams.scm.in
@@ -34,29 +34,12 @@
              (srfi srfi-9)
              (srfi srfi-26)
              (ice-9 format)
-             (ice-9 regex)
              (ice-9 match)
              (ice-9 rdelim)
+             (guix build utils)
              (guix ui)
              (git))
 
-(define-record-type <regexp*>
-  (%make-regexp* pat flag rx)
-  regexp*?
-  (pat regexp*-pattern)
-  (flag regexp*-flag)
-  (rx regexp*-rx))
-
-;;; Work around regexp implementation.
-;;; This record allows to track the regexp pattern and then display it.
-(define* (make-regexp* pat #:optional (flag regexp/extended))
-  "Alternative to `make-regexp' producing annotated <regexp*> objects."
-  (%make-regexp* pat flag (make-regexp pat flag)))
-
-(define (regexp*-exec rx* str)
-  "Execute the RX* regexp, a <regexp*> object."
-  (regexp-exec (regexp*-rx rx*) str))
-
 (define-record-type <team>
   (make-team id name description members scope)
   team?
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 8e630ad586..2b3a8e278b 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@HIDDEN>
 ;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@HIDDEN>
 ;;; Copyright © 2021 Brendan Tildesley <mail@HIDDEN>
+;;; Copyright © 2022 Simon Tournier <zimon.toutoune@HIDDEN>
 ;;; Copyright © 2023 Carlo Zancanaro <carlo@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -28,6 +29,7 @@
 
 (define-module (guix build utils)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
@@ -55,6 +57,14 @@ (define-module (guix build utils)
             package-name->name+version
             parallel-job-count
 
+            make-regexp*
+            regexp*-exec
+            regexp*?
+            regexp*-pattern
+            regexp*-flag
+            regexp*-rx
+            list-matches*
+
             compressor
             tarball?
             %xz-parallel-args
@@ -163,6 +173,35 @@ (define-syntax-rule (define-constant name val)
    (module-replace! (current-module) '(setvbuf)))
   (else #f))
 
+
+;;;
+;;; Extend regexp objects with a pattern field.
+;;;
+(define-record-type <regexp*>
+  (%make-regexp* pat flag rx)
+  regexp*?
+  (pat regexp*-pattern)                 ;the regexp pattern, a string
+  (flag regexp*-flag)                   ;regexp flags
+  (rx regexp*-rx))                      ;the compiled regexp object
+
+;;; Work around regexp implementation.
+;;; This record allows to track the regexp pattern and then display it.
+(define* (make-regexp* pat #:optional (flag regexp/extended))
+  "Alternative to `make-regexp' producing annotated <regexp*> objects."
+  (%make-regexp* pat flag (make-regexp pat flag)))
+
+(define (regexp*-exec rx* str)
+  "Execute the RX* regexp, a <regexp*> object."
+  (regexp-exec (regexp*-rx rx*) str))
+
+(define* (list-matches* regexp str #:optional (flags regexp/extended))
+  "Like 'list-matches', but also accepting a regexp* as REGEXP."
+  (match regexp
+    ((or (? string?) (? regexp?))
+     (list-matches regexp str flags))
+    ((? regexp*?)
+     (list-matches (regexp*-rx regexp) str flags))))
+
 
 ;;;
 ;;; Compression helpers.

base-commit: d59653b7c9e43ebdbba20e2ca071429507f94c67
-- 
2.41.0





Information forwarded to kuba@HIDDEN, maxim.cournoyer@HIDDEN, guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 19 Oct 2023 13:15:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 19 09:15:28 2023
Received: from localhost ([127.0.0.1]:36091 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qtSs4-0003tF-0Z
	for submit <at> debbugs.gnu.org; Thu, 19 Oct 2023 09:15:28 -0400
Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]:57525)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@HIDDEN>) id 1qtSs2-0003sp-7b
 for 42146 <at> debbugs.gnu.org; Thu, 19 Oct 2023 09:15:27 -0400
Received: by mail-oa1-x2b.google.com with SMTP id
 586e51a60fabf-1dd71c0a41fso4888595fac.2
 for <42146 <at> debbugs.gnu.org>; Thu, 19 Oct 2023 06:14:59 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1697721293; x=1698326093; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=fT7QasneeUUw6v7KJk6SJzCliBfugeHsCwOiYHP2oDQ=;
 b=EdinGs8lqL2AlyjrSdgPRcihTzOemYek7x8taKYpqnhs2hIqk4TSmRLGnDAZWlGKnK
 fRGiedegN8ITPEmDbAoKVB8qN9D11A8iIXl7YGocl8ll2UMO1JEjPVmaC7ml8T38ZFs9
 06IS+nx6jy1x4PvlQGmwFe68bGVIerwil8zAzm0LB8N1mEv0YkHDn9nYo67XPKf4hh5T
 qkk3dleIimDuzixwcbO/mMO4XCwrTakunnERtv++TNr/DQhlcQr+bHmqgzABodaDf7xs
 eLX1Kvv+llPsR12cMQZpKKfTh8kQTMulqfeVWRZ5iZlZ9VLbqmc2eqMHy9cLMR5NuDPF
 4T2A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1697721293; x=1698326093;
 h=content-transfer-encoding:mime-version:user-agent:message-id:date
 :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from
 :to:cc:subject:date:message-id:reply-to;
 bh=fT7QasneeUUw6v7KJk6SJzCliBfugeHsCwOiYHP2oDQ=;
 b=cAv3vaiUP8cl6hJgy3ZF5D4gpRoKkijJ9/1xwEmmM5+MKyzmSLxqNjHF4cIaS9oHrS
 G+DPpFEpL2g9+0QumIhMm8GY/8zWEpOEqebxnd04w+cdhWVWatCPZTvNTHHi//KCgW0J
 9NIVf48bDLfInGoLAoU+DvczGZabbgv5aJ/k9dWIWU0zEIPWCd7kGbVwEhYt8IEyaXX/
 VjT9yz7CqBlUvamYS2v70m0iOJ/Gh999bU0AKoN4EOQ9hNRhXLC73duC7OP30yYpKeVh
 9qrxqKYMIGpl8Yz6U8vycYAsBzsuNlVGtjysLmNPBnxvKcm8VOyTaaw3UPOToGDqLMgN
 kJOg==
X-Gm-Message-State: AOJu0YwfFZZtzDE2/s4SBLkyy7Ohej3WFsgER+Ns1w32x+RQp+oO3ZKX
 74jrBg9YtkyrjQtXZsARsNTF0bkarJntLA==
X-Google-Smtp-Source: AGHT+IHgj3IX/Nn1l0ifoYjULnMdLmuqO1qkFbFN2E0H+Ypm9vJjTNcUZF3Ic3Lm8URZEdAs92wZEg==
X-Received: by 2002:a05:6870:a102:b0:1e9:b305:6831 with SMTP id
 m2-20020a056870a10200b001e9b3056831mr2516941oae.42.1697721292929; 
 Thu, 19 Oct 2023 06:14:52 -0700 (PDT)
Received: from hurd (dsl-156-111.b2b2c.ca. [66.158.156.111])
 by smtp.gmail.com with ESMTPSA id
 t7-20020ac86a07000000b004197d6d97c4sm718091qtr.24.2023.10.19.06.14.52
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 19 Oct 2023 06:14:52 -0700 (PDT)
From: Maxim Cournoyer <maxim.cournoyer@HIDDEN>
To: Jakub =?utf-8?B?S8SFZHppb8WCa2E=?= <kuba@HIDDEN>
Subject: Re: bug#42146: [PATCH core-updates 1/?] build: substitute: Don't
 fail silently.
In-Reply-To: <20200630225007.tw2rcfbmzh3wvthf@gravity> ("Jakub
 =?utf-8?B?S8SFZHppb8WCa2EiJ3M=?=
 message of "Wed, 1 Jul 2020 00:50:07 +0200")
References: <20200630220913.14665-1-kuba@HIDDEN>
 <handler.42146.B.159355497531278.ack <at> debbugs.gnu.org>
 <20200630225007.tw2rcfbmzh3wvthf@gravity>
Date: Thu, 19 Oct 2023 09:14:51 -0400
Message-ID: <87wmvioit0.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
Cc: 42146 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Jakub,

Sorry for the late reply; nice series!

Jakub K=C4=85dzio=C5=82ka <kuba@HIDDEN> writes:

> The error messages I'm getting from this are quite indirect - there are
> wrapped in quite a few layers. Is there a better way to report errors
> inside a build utility?
>
> ice-9/eval.scm:387:11: In procedure eval:
> ice-9/eval.scm:387:11: Throw to key `srfi-34' with args `(#<condition &me=
ssage [message: "substit ute: install.sh: pattern failed to match:  -xf"] 1=
1aa480>)'.
> builder for `/gnu/store/wdyzzh7rkg47hfp434w72ly9nay1yva1-mes-boot-0.22.dr=
v' failed with exit code 1

I don't think it's possible currently; I guess we'd have to serialize
the exceptions in the builder to recover them on the host to present
them in a nicer fashion.

--=20
Thanks,
Maxim




Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 1 Jul 2020 09:55:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 01 05:55:30 2020
Received: from localhost ([127.0.0.1]:52317 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jqZSk-0002Gs-1s
	for submit <at> debbugs.gnu.org; Wed, 01 Jul 2020 05:55:30 -0400
Received: from pat.zlotemysli.pl ([37.59.186.212]:37738)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kuba@HIDDEN>) id 1jqZSh-0002Gg-UR
 for 42146 <at> debbugs.gnu.org; Wed, 01 Jul 2020 05:55:28 -0400
Received: (qmail 19561 invoked by uid 1009); 1 Jul 2020 11:55:25 +0200
Received: from 188.123.215.55 (kuba@HIDDEN@188.123.215.55) by
 pat.zlotemysli.pl (envelope-from <kuba@HIDDEN>,
 uid 1002) with qmail-scanner-2.08st 
 (clamdscan: 0.98.6/25859. spamassassin: 3.4.0. perlscan: 2.08st.  
 Clear:RC:1(188.123.215.55):. 
 Processed in 0.034343 secs); 01 Jul 2020 09:55:25 -0000
Received: from unknown (HELO localhost.localdomain)
 (kuba@HIDDEN@188.123.215.55)
 by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 1 Jul 2020 11:55:25 +0200
From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <kuba@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH 6/6] gnu: glibc-mesboot0: Fixup the fixup-configure phase.
Date: Wed,  1 Jul 2020 11:55:23 +0200
Message-Id: <20200701095523.9501-1-kuba@HIDDEN>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Qmailux-2.08st: added fake Content-Type header
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/packages/commencement.scm (glibc-mesboot0)[fixup-configure]: Don't
  repeat substitution. Fix indentation.
---
This is an interesting cleanup commit. I believe this concludes a nice
sampling of the consequences of this patch, and thus subsequent fixups
are unlikely to benefit from a review. I will be pushing my work to

https://github.com/NieDzejkob/guix/tree/core-updates

 gnu/packages/commencement.scm | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 295a378d11..837f4e2ecc 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -1418,19 +1418,17 @@ ac_cv_c_float_format='IEEE (little-endian)'
              (format (current-error-port)
                      "running ./configure ~a\n" (string-join configure-flags))
              (apply invoke "./configure" configure-flags)))
-                  (add-after 'configure 'fixup-configure
-                    (lambda _
-                      (let* ((out (assoc-ref %outputs "out"))
-                             (bash (assoc-ref %build-inputs "bash"))
-                             (shell (string-append bash "/bin/bash")))
-                        (substitute* "config.make"
-                          (("INSTALL = scripts/") "INSTALL = $(..)./scripts/"))
-                        (substitute* "config.make"
-                          (("INSTALL = scripts/") "INSTALL = $(..)./scripts/")
-                          (("BASH = ") (string-append
-                                        "SHELL = " shell "
-         BASH = ")))
-                        #t))))))))
+         (add-after 'configure 'fixup-configure
+           (lambda _
+             (let* ((out (assoc-ref %outputs "out"))
+                    (bash (assoc-ref %build-inputs "bash"))
+                    (shell (string-append bash "/bin/bash")))
+               (substitute* "config.make"
+                 (("INSTALL = scripts/") "INSTALL = $(..)./scripts/")
+                 (("BASH = ") (string-append
+                               "SHELL = " shell "
+BASH = ")))
+               #t))))))))
 
 (define gcc-mesboot0
   (package
-- 
2.26.2





Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 1 Jul 2020 00:42:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 30 20:42:46 2020
Received: from localhost ([127.0.0.1]:52042 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jqQpq-0003V5-72
	for submit <at> debbugs.gnu.org; Tue, 30 Jun 2020 20:42:46 -0400
Received: from pat.zlotemysli.pl ([37.59.186.212]:60106)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kuba@HIDDEN>) id 1jqQpo-0003Ux-Gg
 for 42146 <at> debbugs.gnu.org; Tue, 30 Jun 2020 20:42:45 -0400
Received: (qmail 29638 invoked by uid 1009); 1 Jul 2020 02:42:43 +0200
Received: from 188.123.215.55 (kuba@HIDDEN@188.123.215.55) by
 pat.zlotemysli.pl (envelope-from <kuba@HIDDEN>,
 uid 1002) with qmail-scanner-2.08st 
 (clamdscan: 0.98.6/25858. spamassassin: 3.4.0. perlscan: 2.08st.  
 Clear:RC:1(188.123.215.55):. 
 Processed in 0.013567 secs); 01 Jul 2020 00:42:43 -0000
Received: from unknown (HELO localhost.localdomain)
 (kuba@HIDDEN@188.123.215.55)
 by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 1 Jul 2020 02:42:43 +0200
From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <kuba@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH 5/?] build-system/gnu: Allow lack of matches in substitution
 phases.
Date: Wed,  1 Jul 2020 02:42:42 +0200
Message-Id: <20200701004242.18245-1-kuba@HIDDEN>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/build/utils.scm (patch-makefile-SHELL, patch-/usr/bin/file),
  guix/build/gnu-build-system.scm (patch-dot-desktop-files):
  Allow lack of matches in substitute*.
---
 guix/build/gnu-build-system.scm | 3 ++-
 guix/build/utils.scm            | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 2e7dff2034..4b96761233 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2018 Mark H Weaver <mhw@HIDDEN>
 ;;; Copyright © 2020 Brendan Tildesley <mail@HIDDEN>
+;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -724,7 +725,7 @@ which cannot be found~%"
                      ;; '.desktop' files contain translations and are always
                      ;; UTF-8-encoded.
                      (with-fluids ((%default-port-encoding "UTF-8"))
-                       (substitute* files
+                       (substitute* files #:require-matches? #f
                          (("^Exec=([^/[:blank:]\r\n]*)(.*)$" _ binary rest)
                           (string-append "Exec=" (which binary) rest))
                          (("^TryExec=([^/[:blank:]\r\n]*)(.*)$" _ binary rest)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 1bfb774c60..a8218a7743 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -1005,7 +1005,7 @@ When KEEP-MTIME? is true, the atime/mtime of FILE are kept unchanged."
   (let ((st (stat file)))
     ;; Consider FILE is using an 8-bit encoding to avoid errors.
     (with-fluids ((%default-port-encoding #f))
-      (substitute* file
+      (substitute* file #:require-matches? #f
         (("^ *SHELL[[:blank:]]*:?=[[:blank:]]*([[:graph:]]*/)([[:graph:]]+)(.*)$"
           _ dir shell args)
          (let* ((old (string-append dir shell))
@@ -1033,7 +1033,7 @@ no replacement 'file' command, doing nothing~%")
       (let ((st (stat file)))
         ;; Consider FILE is using an 8-bit encoding to avoid errors.
         (with-fluids ((%default-port-encoding #f))
-          (substitute* file
+          (substitute* file #:require-matches? #f
             (("/usr/bin/file")
              (begin
                (format (current-error-port)
-- 
2.26.2





Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 1 Jul 2020 00:42:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 30 20:42:40 2020
Received: from localhost ([127.0.0.1]:52039 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jqQpj-0003Ul-UC
	for submit <at> debbugs.gnu.org; Tue, 30 Jun 2020 20:42:40 -0400
Received: from pat.zlotemysli.pl ([37.59.186.212]:60046)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kuba@HIDDEN>) id 1jqQph-0003Uc-Rq
 for 42146 <at> debbugs.gnu.org; Tue, 30 Jun 2020 20:42:38 -0400
Received: (qmail 29567 invoked by uid 1009); 1 Jul 2020 02:42:35 +0200
Received: from 188.123.215.55 (kuba@HIDDEN@188.123.215.55) by
 pat.zlotemysli.pl (envelope-from <kuba@HIDDEN>,
 uid 1002) with qmail-scanner-2.08st 
 (clamdscan: 0.98.6/25858. spamassassin: 3.4.0. perlscan: 2.08st.  
 Clear:RC:1(188.123.215.55):. 
 Processed in 0.042099 secs); 01 Jul 2020 00:42:35 -0000
Received: from unknown (HELO localhost.localdomain)
 (kuba@HIDDEN@188.123.215.55)
 by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 1 Jul 2020 02:42:35 +0200
From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <kuba@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH 4/?] gnu: mes-boot: Use verbosity settings integrated into
 buildsystem
Date: Wed,  1 Jul 2020 02:42:34 +0200
Message-Id: <20200701004234.18050-1-kuba@HIDDEN>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Qmailux-2.08st: added fake Content-Type header
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/packages/commencement.scm (mes-boot): Set the V environment
  variable. Don't substitute in the install script.
---
 gnu/packages/commencement.scm | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 1c7cf3d810..295a378d11 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -407,6 +407,7 @@ $MES -e '(mescc)' module/mescc.scm -- \"$@\"
                        (string-append
                         mes "/share/mes/module"
                         ":" dir "/nyacc-0.99.0/module"))
+               (setenv "V" "1")
                (invoke "gash" "configure.sh"
                        (string-append "--prefix=" out)
                        (string-append "--host=i686-linux-gnu")))))
@@ -416,11 +417,6 @@ $MES -e '(mescc)' module/mescc.scm -- \"$@\"
          (delete 'check)
          (replace 'install
            (lambda _
-             (substitute* "install.sh"  ; show some progress
-               ((" -xf") " -xvf")
-               (("^( *)((cp|mkdir|tar) [^']*[^\\])\n" all space cmd)
-                (string-append space "echo '" cmd "'\n"
-                               space cmd "\n")))
              (invoke "sh" "install.sh")
              ;; Keep ASCII output, for friendlier comparison and bisection
              (let* ((out (assoc-ref %outputs "out"))
-- 
2.26.2





Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 30 Jun 2020 22:50:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 30 18:50:14 2020
Received: from localhost ([127.0.0.1]:51939 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jqP4w-0000g9-HL
	for submit <at> debbugs.gnu.org; Tue, 30 Jun 2020 18:50:14 -0400
Received: from pat.zlotemysli.pl ([37.59.186.212]:37970)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kuba@HIDDEN>) id 1jqP4v-0000g1-9I
 for 42146 <at> debbugs.gnu.org; Tue, 30 Jun 2020 18:50:13 -0400
Received: (qmail 10513 invoked by uid 1009); 1 Jul 2020 00:50:11 +0200
Received: from 188.123.215.55 (kuba@HIDDEN@188.123.215.55) by
 pat.zlotemysli.pl (envelope-from <kuba@HIDDEN>,
 uid 1002) with qmail-scanner-2.08st 
 (clamdscan: 0.98.6/25858. spamassassin: 3.4.0. perlscan: 2.08st.  
 Clear:RC:1(188.123.215.55):. 
 Processed in 0.036375 secs); 30 Jun 2020 22:50:11 -0000
Received: from unknown (HELO gravity) (kuba@HIDDEN@188.123.215.55)
 by pat.zlotemysli.pl with SMTP; 1 Jul 2020 00:50:11 +0200
Date: Wed, 1 Jul 2020 00:50:07 +0200
From: Jakub =?utf-8?B?S8SFZHppb8WCa2E=?= <kuba@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: Re: [PATCH core-updates 1/?] build: substitute: Don't fail silently.
Message-ID: <20200630225007.tw2rcfbmzh3wvthf@gravity>
References: <20200630220913.14665-1-kuba@HIDDEN>
 <handler.42146.B.159355497531278.ack <at> debbugs.gnu.org>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="4yl43hkujyl5piqa"
Content-Disposition: inline
In-Reply-To: <handler.42146.B.159355497531278.ack <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--4yl43hkujyl5piqa
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

The error messages I'm getting from this are quite indirect - there are
wrapped in quite a few layers. Is there a better way to report errors
inside a build utility?

ice-9/eval.scm:387:11: In procedure eval:
ice-9/eval.scm:387:11: Throw to key `srfi-34' with args `(#<condition &mess=
age [message: "substit ute: install.sh: pattern failed to match:  -xf"] 11a=
a480>)'.
builder for `/gnu/store/wdyzzh7rkg47hfp434w72ly9nay1yva1-mes-boot-0.22.drv'=
 failed with exit code 1

Regards,
Jakub K=C4=85dzio=C5=82ka

--4yl43hkujyl5piqa
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEE5Xa/ss9usT31cTO54xWnWEYTFWQFAl77wZ8ACgkQ4xWnWEYT
FWRIhxAAhBBY1dtp5/7VfFJ2cKcDK8X1xTJucuTGpM5AflHMVarCBdba/7pofenb
/cpRR52LfhwQU2HMornopoRIeBnm7DR81vSE4A/V4XO7Z6+BhG2AXAU8biQ6Mzqu
1SH0ykadjyxZSOC+JZ4XfqSc/SDb79aIUh5O4Mw22xCir+2ed1zJcHrhjm4jOhMW
e3ZPoL1+WDhe26LYdhcjUXciBTf0TEhkb4ZCmHgdbe9cVaLq97gA25MsJRiV8Q1d
IoSgf7Fg5FUktl4xCZdMSQ/N3f5mkpS94P6X0EGZQRu3V2KaQH4Yut661W8X00Yr
F2OtlTu4RHivHk/sdkGWETb9W/EqAqquoSg+KENRzkbbASn2upS79/fG74kPooIq
ULNcSW0qCqbSUuELSBiRvP/G+AvSlrQ6w0Tfsur8KF2Rkh4f8m4hzCHkccUSP0FZ
DRsF1sjILlBDjjtb/dgm4uuWr7NOBUddp9s0DvCKpSdHVq9ms7Q9QNyRyZ7sEgzr
eqFkmF2Mv4IZWISy5K1XITWmL+ypctm8chceoQmwrhSU2YQ+2peiLykB7GxcymrB
UkkeULOJ2OZDE5Nl0Mgrz5WOxzN7AuH5C9FAE8JnNJ32mgZsgtPJ1GN4YpL4tmBv
KxwHdl55Rbc/PV3+oiVFnsZ6UOt/bL4wF9DqmPV25KXog63pNQ0=
=BRqx
-----END PGP SIGNATURE-----

--4yl43hkujyl5piqa--




Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 30 Jun 2020 22:11:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 30 18:11:38 2020
Received: from localhost ([127.0.0.1]:51909 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jqOTa-0008CU-4M
	for submit <at> debbugs.gnu.org; Tue, 30 Jun 2020 18:11:38 -0400
Received: from pat.zlotemysli.pl ([37.59.186.212]:46556)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kuba@HIDDEN>) id 1jqOTY-0008CL-7H
 for 42146 <at> debbugs.gnu.org; Tue, 30 Jun 2020 18:11:37 -0400
Received: (qmail 8847 invoked by uid 1009); 1 Jul 2020 00:11:35 +0200
Received: from 188.123.215.55 (kuba@HIDDEN@188.123.215.55) by
 pat.zlotemysli.pl (envelope-from <kuba@HIDDEN>,
 uid 1002) with qmail-scanner-2.08st 
 (clamdscan: 0.98.6/25858. spamassassin: 3.4.0. perlscan: 2.08st.  
 Clear:RC:1(188.123.215.55):. 
 Processed in 0.01319 secs); 30 Jun 2020 22:11:35 -0000
Received: from unknown (HELO localhost.localdomain)
 (kuba@HIDDEN@188.123.215.55)
 by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 1 Jul 2020 00:11:35 +0200
From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <kuba@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH 3/?] gnu: commencement: Build fix for %bootstrap-mes-rewired.
Date: Wed,  1 Jul 2020 00:11:34 +0200
Message-Id: <20200630221134.16350-1-kuba@HIDDEN>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Not every file has to refer to all dependencies.

* gnu/packages/commencement.scm (%bootstrap-mes-rewired)[builder]: Allow
  lack of matches in substitute*.
---
 gnu/packages/commencement.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index ef250e037b..1c7cf3d810 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2018, 2019, 2020 Jan (janneke) Nieuwenhuizen <janneke@HIDDEN>
 ;;; Copyright © 2019, 2020 Marius Bakke <mbakke@HIDDEN>
 ;;; Copyright © 2020 Timothy Sample <samplet@HIDDEN>
+;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -283,7 +284,7 @@ pure Scheme to Tar and decompression in one easy step.")
                           (mescc (string-append bin "/mescc"))
                           (module (string-append out "/share/mes/module")))
                      (define (rewire file)
-                       (substitute* file
+                       (substitute* file #:require-matches? #f
                          ((mes) out)
                          (("/gnu/store[^ ]+mes-minimal-[^/)}\"]*") out)
                          (("/gnu/store[^ ]+guile-[^/]*/bin/guile") guile)
-- 
2.26.2





Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at 42146 <at> debbugs.gnu.org:


Received: (at 42146) by debbugs.gnu.org; 30 Jun 2020 22:11:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 30 18:11:30 2020
Received: from localhost ([127.0.0.1]:51906 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jqOTR-0008C9-Qx
	for submit <at> debbugs.gnu.org; Tue, 30 Jun 2020 18:11:30 -0400
Received: from pat.zlotemysli.pl ([37.59.186.212]:46372)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kuba@HIDDEN>) id 1jqOTP-0008C0-DK
 for 42146 <at> debbugs.gnu.org; Tue, 30 Jun 2020 18:11:28 -0400
Received: (qmail 8685 invoked by uid 1009); 1 Jul 2020 00:11:25 +0200
Received: from 188.123.215.55 (kuba@HIDDEN@188.123.215.55) by
 pat.zlotemysli.pl (envelope-from <kuba@HIDDEN>,
 uid 1002) with qmail-scanner-2.08st 
 (clamdscan: 0.98.6/25858. spamassassin: 3.4.0. perlscan: 2.08st.  
 Clear:RC:1(188.123.215.55):. 
 Processed in 0.011385 secs); 30 Jun 2020 22:11:25 -0000
Received: from unknown (HELO localhost.localdomain)
 (kuba@HIDDEN@188.123.215.55)
 by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 1 Jul 2020 00:11:25 +0200
From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <kuba@HIDDEN>
To: 42146 <at> debbugs.gnu.org
Subject: [PATCH 2/?] build: bootstrap-configure: Allow lack of matches in
 substitute.
Date: Wed,  1 Jul 2020 00:11:21 +0200
Message-Id: <20200630221121.16086-1-kuba@HIDDEN>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42146
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Matches are not required here, as not every file will use every
variable.

* guix/build/gnu-bootstrap.scm (bootstrap-configure): Pass
  #:require-matches? #f to substitute*.
---
 guix/build/gnu-bootstrap.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/guix/build/gnu-bootstrap.scm b/guix/build/gnu-bootstrap.scm
index 1cb9dc5512..6ee520e301 100644
--- a/guix/build/gnu-bootstrap.scm
+++ b/guix/build/gnu-bootstrap.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2020 Timothy Sample <samplet@HIDDEN>
+;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -49,7 +50,7 @@ and object directories."
                   (format #t "Configuring ~a~%" template)
                   (let ((target (string-drop-right template 3)))
                     (copy-file template target)
-                    (substitute* target
+                    (substitute* target #:require-matches? #f
                       (("@VERSION@") version))))
                 (find-files modules
                             (lambda (fn st)
@@ -58,7 +59,7 @@ and object directories."
                   (format #t "Configuring ~a~%" template)
                   (let ((target (string-drop-right template 3)))
                     (copy-file template target)
-                    (substitute* target
+                    (substitute* target #:require-matches? #f
                       (("@GUILE@") guile)
                       (("@MODDIR@") moddir)
                       (("@GODIR@") godir))
-- 
2.26.2





Information forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 30 Jun 2020 22:09:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 30 18:09:35 2020
Received: from localhost ([127.0.0.1]:51889 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jqORa-00088Q-Ky
	for submit <at> debbugs.gnu.org; Tue, 30 Jun 2020 18:09:34 -0400
Received: from lists.gnu.org ([209.51.188.17]:57628)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kuba@HIDDEN>) id 1jqORY-00088H-4o
 for submit <at> debbugs.gnu.org; Tue, 30 Jun 2020 18:09:33 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:58504)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <kuba@HIDDEN>)
 id 1jqORY-00040g-00
 for guix-patches@HIDDEN; Tue, 30 Jun 2020 18:09:32 -0400
Received: from pat.zlotemysli.pl ([37.59.186.212]:34672)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <kuba@HIDDEN>) id 1jqORV-0000k5-QK
 for guix-patches@HIDDEN; Tue, 30 Jun 2020 18:09:31 -0400
Received: (qmail 6193 invoked by uid 1009); 1 Jul 2020 00:09:21 +0200
Received: from 188.123.215.55 (kuba@HIDDEN@188.123.215.55) by
 pat.zlotemysli.pl (envelope-from <kuba@HIDDEN>,
 uid 1002) with qmail-scanner-2.08st 
 (clamdscan: 0.98.6/25858. spamassassin: 3.4.0. perlscan: 2.08st.  
 Clear:RC:1(188.123.215.55):. 
 Processed in 0.018843 secs); 30 Jun 2020 22:09:21 -0000
Received: from unknown (HELO localhost.localdomain)
 (kuba@HIDDEN@188.123.215.55)
 by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 1 Jul 2020 00:09:20 +0200
From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <kuba@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH core-updates 1/?] build: substitute: Don't fail silently.
Date: Wed,  1 Jul 2020 00:09:13 +0200
Message-Id: <20200630220913.14665-1-kuba@HIDDEN>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Received-SPF: none client-ip=37.59.186.212; envelope-from=kuba@HIDDEN;
 helo=pat.zlotemysli.pl
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/30 18:09:21
X-ACL-Warn: Detected OS   = Linux 3.11 and newer
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001,
 SPF_NONE=0.001 autolearn=_AUTOLEARN
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
Cc: mbakke@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

* guix/build/utils.scm (substitute, substitute*)[require-matches?]: New
  argument.
---
Of course, this will require some changes in the build recipes. However,
many of the bugs I have seen before could've been prevented by this
behavior, so I believe it is worth it.

I am currently running 'guix build hello' with these changes; I will
send any follow-up fixes needed to this bug#.

 guix/build/utils.scm | 47 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index dc55c6745d..1bfb774c60 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2018 Arun Isaac <arunisaac@HIDDEN>
 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@HIDDEN>
 ;;; Copyright © 2020 Efraim Flashner <efraim@HIDDEN>
+;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -747,29 +748,42 @@ PROC's result is returned."
       (lambda (key . args)
         (false-if-exception (delete-file template))))))
 
-(define (substitute file pattern+procs)
+(define* (substitute file pattern+procs #:key (require-matches? #t))
   "PATTERN+PROCS is a list of regexp/two-argument-procedure pairs.  For each
 line of FILE, and for each PATTERN that it matches, call the corresponding
 PROC as (PROC LINE MATCHES); PROC must return the line that will be written as
 a substitution of the original line.  Be careful about using '$' to match the
-end of a line; by itself it won't match the terminating newline of a line."
-  (let ((rx+proc  (map (match-lambda
-                        (((? regexp? pattern) . proc)
-                         (cons pattern proc))
-                        ((pattern . proc)
-                         (cons (make-regexp pattern regexp/extended)
-                               proc)))
-                       pattern+procs)))
+end of a line; by itself it won't match the terminating newline of a line.
+
+By default, SUBSTITUTE will raise a &message condition if one of the patterns
+fails to match. If a lack of matches is acceptable, pass #:require-matches? #f
+to disable this check."
+  (let ((rx+proc (map (match-lambda
+                       (((? regexp? pattern) . proc)
+                        (cons* #f "<unknown>" pattern proc))
+                       ((pattern . proc)
+                        (cons* #f pattern (make-regexp pattern regexp/extended)
+                              proc)))
+                      pattern+procs)))
     (with-atomic-file-replacement file
       (lambda (in out)
         (let loop ((line (read-line in 'concat)))
           (if (eof-object? line)
-              #t
+              (when require-matches?
+                (for-each
+                  (match-lambda
+                    ((#f pat . _)
+                     (raise (condition
+                             (&message
+                              (message (format #f "substitute: ~a: pattern failed to match: ~a" file pat))))))
+                    ((#t . _) #t))
+                  rx+proc))
               (let ((line (fold (lambda (r+p line)
                                   (match r+p
-                                    ((regexp . proc)
+                                    ((_ _ regexp . proc)
                                      (match (list-matches regexp line)
                                        ((and m+ (_ _ ...))
+                                        (set-car! r+p #t)
                                         (proc line m+))
                                        (_ line)))))
                                 line
@@ -814,9 +828,17 @@ match substring.
 Alternatively, FILE may be a list of file names, in which case they are
 all subject to the substitutions.
 
+By default, SUBSTITUTE* will raise a &message condition if one of the patterns
+fails to match on one of the files. If a lack of matches is acceptable,
+add #:require-matches? #f after FILE to disable this check.
+
 Be careful about using '$' to match the end of a line; by itself it won't
 match the terminating newline of a line."
     ((substitute* file ((regexp match-var ...) body ...) ...)
+     (substitute* file #:require-matches? #t
+                  ((regexp match-var ...) body ...) ...))
+    ((substitute* file #:require-matches? require-matches?
+                  ((regexp match-var ...) body ...) ...)
      (let ()
        (define (substitute-one-file file-name)
          (substitute
@@ -840,7 +862,8 @@ match the terminating newline of a line."
                                       (begin body ...)
                                       (substring l o (match:start m))
                                       r))))))))
-                ...)))
+                ...)
+          #:require-matches? require-matches?))
 
        (match file
          ((files (... ...))
-- 
2.26.2





Acknowledgement sent to Jakub Kądziołka <kuba@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#42146; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 20 Oct 2023 15:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.