From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id MF2YEfPz3WQSbwEASxT56A (envelope-from ) for ; Thu, 17 Aug 2023 12:18:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id qLO2EPPz3WRRygAAG6o9tA (envelope-from ) for ; Thu, 17 Aug 2023 12:18:27 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 013DD59530 for ; Thu, 17 Aug 2023 12:18:27 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=Y7Uk123D; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1692267507; a=rsa-sha256; cv=none; b=mDjRWgQGToRd/39aes5Cvv+uNWvO6euqgzO/uSQQXk1hAGSW+N5jTSzhgCYTP5e5NnX+jQ oQ+XOeEIOxLAd3/jyjFHS641+LQ7HgaeHOgQnMUecmq9gU/DVCr8g9gYkPb6t7PXiHE5zl uxC4xkCe2ft/zbvOrCLdxbI5omap5WxgXzu4JsDt267hvwtjoO5SGZimWvXr2sIeuLweze 2lPiDwU6L0WM+8GsSvOpEJ3ZURiGP02y2qk0RbNOhgd+Pg4XkjqmI2pBCbfvEcphTRyRcy NIn76wD3Bg1HTaOmLf7a4w0WymxxFu8prMe+nMHSGS+TviP8JwrYZ5xN/Ix3QQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=Y7Uk123D; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1692267507; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Mnxw26De5vdZVXKFi5nZ2Y/yB10IKQ3L9iKRyr0hvjc=; b=nh14EbmYPx51sm32Y6+yeflFrlBjFPHhMS4wnkmPwXg7JPetsRxODxqvmqmJV2Zs0sNaop g4uaH+0szVTNDMAjl89VEBNrqcD7CkK2W93jspDkbzjghyoQDXBhAF1BvR+P5pKYRlKD2H qbeqKzG+7BAofpSMu2hxyU3gNbf1DaYkAZdM2OQWpRInuMKpdeEOCmamWr/bRVTByz1kJo vapT8zdTUJD0DXSWaXp4MEho5ytxiXWNMzlYMgmgJgb1+h5zcShEJdCVFAe6E4k7oJkCd3 jVr2vRleyCNi3BwJg1u3Ke0iDaH+mNhZ3YOnf9WNkMv7C4BsTdux0lLXSl/jTQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWa4u-00069d-LG; Thu, 17 Aug 2023 06:18:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWa4s-00068j-N4 for guix-patches@gnu.org; Thu, 17 Aug 2023 06:18:06 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWa4r-0003Sv-KS; Thu, 17 Aug 2023 06:18:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qWa4o-0001Ce-6f; Thu, 17 Aug 2023 06:18:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65229] [PATCH v2 1/2] ui: 'load*' accepts /dev/fd/N files pointing to a pipe. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Thu, 17 Aug 2023 10:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65229 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65229@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 65229-submit@debbugs.gnu.org id=B65229.16922674774607 (code B ref 65229); Thu, 17 Aug 2023 10:18:02 +0000 Received: (at 65229) by debbugs.gnu.org; 17 Aug 2023 10:17:57 +0000 Received: from localhost ([127.0.0.1]:42813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qWa4j-0001CE-3d for submit@debbugs.gnu.org; Thu, 17 Aug 2023 06:17:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qWa4b-0001Bk-Oi for 65229@debbugs.gnu.org; Thu, 17 Aug 2023 06:17:51 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWa4V-0003Hj-Lw; Thu, 17 Aug 2023 06:17: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:References:In-Reply-To:Date:Subject:To: From; bh=Mnxw26De5vdZVXKFi5nZ2Y/yB10IKQ3L9iKRyr0hvjc=; b=Y7Uk123DxmujXGeiYXws 1JpDz9dYSh2F5DCqOhprbNqCrcUMCKAUbVVWTLwsSjWKfnMDk+E4zSH7QvgqoQtdXL7ex5Rm49T3k skyXf+snA8nfDZ2R7rMNvRhg0loMsd5u5XWOcHE4oYSn61qvRfV8NcMDDOiOOhmkyl/HuCo7NW/QQ oa3ig4tv0oGaDQwVK0O9VDxp6LtTX7kZZThANSXpKqwk6RBh01tmfW85P+kAidGkYHw8AxTSaferZ kgnSTrcNMixlpn/6ImBuSjHgp9fkQvk0h/cwzU+fE223o5za1E05hlJOCxVc4j2Q/Zj7mh2fM3DoW 9sI7ncPhf/f+aQ==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Thu, 17 Aug 2023 12:17:28 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <875y5eyrl0.fsf@gnu.org> References: <875y5eyrl0.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 013DD59530 X-Migadu-Scanner: mx0.migadu.com X-Migadu-Spam-Score: -4.39 X-Spam-Score: -4.39 X-TUID: WBwzAu5ddNQ2 From: Ludovic Courtès This allows users to write Bash commands like: guix time-machine -C <(echo %default-channels) -- ... or: guix build -m <(echo '(specifications->manifest (list "guile"))') Previously, on GNU/Linux, they would fail with: error: failed to load '/dev/fd/63': No such file or directory * guix/ui.scm (try-canonicalize-path): New procedure. (load*): Use it. * tests/guix-build.sh: Test 'guix build -m' with a /dev/fd/N file. --- guix/ui.scm | 16 +++++++++++++++- tests/guix-build.sh | 9 ++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/guix/ui.scm b/guix/ui.scm index 47a118364a..6f2d4fe245 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -200,6 +200,20 @@ (define-syntax-rule (without-compiler-optimizations exp) (parameterize (((@ (system base compile) default-optimization-level) 1)) exp)) +(define (try-canonicalize-path file) + "Like 'canonicalize-path', but return FILE as-is if 'canonicalize-path' +throws. + +This is necessary for corner cases where 'canonicalize-path' fails. One +example is on Linux when a /dev/fd/N file denotes a pipe, represented as a +symlink to a non-existent file like 'pipe:[1234]', as in this example: + + sh -c 'stat $(readlink -f /dev/fd/1)' | cat" + (catch 'system-error + (lambda () + (canonicalize-path file)) + (const file))) + (define* (load* file user-module #:key (on-error 'nothing-special)) "Load the user provided Scheme source code FILE." @@ -230,7 +244,7 @@ (define* (load* file user-module ;; 'primitive-load', so that FILE is compiled, which then allows ;; us to provide better error reporting with source line numbers. (without-compiler-optimizations - (load (canonicalize-path file)))) + (load (try-canonicalize-path file)))) (const #f)))))) (lambda _ ;; XXX: Errors are reported from the pre-unwind handler below, but diff --git a/tests/guix-build.sh b/tests/guix-build.sh index 317c58ac42..4eab0e38b6 100644 --- a/tests/guix-build.sh +++ b/tests/guix-build.sh @@ -1,5 +1,5 @@ # GNU Guix --- Functional package management for GNU -# Copyright © 2012-2014, 2016-2022 Ludovic Courtès +# Copyright © 2012-2014, 2016-2023 Ludovic Courtès # Copyright © 2020 Marius Bakke # Copyright © 2021 Chris Marusich # @@ -397,6 +397,13 @@ guix build -d -m "$module_dir/manifest.scm" \ rm "$module_dir"/*.scm +if [ -n "$BASH_VERSION" ] +then + # Check whether we can load from a /dev/fd/N denoting a pipe, using this + # handy Bash-specific construct. + guix build -m <(echo '(specifications->manifest (list "guile"))') -n +fi + # Using 'GUIX_BUILD_OPTIONS'. GUIX_BUILD_OPTIONS="--dry-run --no-grafts" export GUIX_BUILD_OPTIONS base-commit: 1bd44b425b79e9da160b33a9b19d01973b44772e -- 2.41.0