From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Oct 2022 03:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16668421537175 (code B ref -1); Thu, 27 Oct 2022 03:43:01 +0000 Received: (at submit) by debbugs.gnu.org; 27 Oct 2022 03:42:33 +0000 Received: from localhost ([127.0.0.1]:55688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontmc-0001rQ-Fj for submit@debbugs.gnu.org; Wed, 26 Oct 2022 23:42:33 -0400 Received: from lists.gnu.org ([209.51.188.17]:41788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontmP-0001r7-CX for submit@debbugs.gnu.org; Wed, 26 Oct 2022 23:42:16 -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 1ontmP-00036k-4U for guix-patches@gnu.org; Wed, 26 Oct 2022 23:42:05 -0400 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ontmJ-0007bM-TG for guix-patches@gnu.org; Wed, 26 Oct 2022 23:42:04 -0400 Received: by mail-qv1-xf2a.google.com with SMTP id n18so202112qvt.11 for ; Wed, 26 Oct 2022 20:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=D8mWfN0XzLz08gJwAzSvf2zqwuBOISMFIGApHbN2lVE=; b=HPvvQF64m+WzMvEDQAP7QxQh3EqjkLkCDTPWzUt+Hru2JS1tn7659mUIgwsavFl7Xw o5hO7AkFJ7Sw++GM8QAhMXO4AXuANVIb/SMZlN7HK8ce+5zB6lqKsibeaBKNBu8yffp4 YnzjpJV7De0wum5dl6zF+zWbHFgtvs2vMjeNUBJs55r7tV7N3n/d3EwA3fBOJ8crhBCl zQb9IO6jhOgsfCSZDTEtkomJdJGNxjiYn08rONuuiu9UkUhUfkfYTFE3rLO+n+3upfjW VvtRgqVIyo6i0CB0faaysixDe3XiV1tt1jk3OYiU8JWKeSab2EI6ST9N4xpZRfiTv3CJ Nz/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=D8mWfN0XzLz08gJwAzSvf2zqwuBOISMFIGApHbN2lVE=; b=CJnMim9Dh5c/NhEiZkVJnq+U/x7lyswNPVUzqR8Wy3zMY7iLGk0sH+2nppzGG2Z6wV zUgECfCPYfWlNNbxajzX+09Oj3qR/u+hl0aeR97O34NbWbRYRnBgnrtdHeMzUcnDUrvw 2rtiQ5CArNCZS7BUUEXaXj+a2/dR1K/jp6cBVMVSSSTWmGK2N4b9Turrwm7+9gWiu/ik bWY5URu8nJde7hXTFSixayg3wxPNijuVrzisWA1Kj5Q28FSZfGaFuQn99v4/Ep+C8kMf a9ZRAB1RKIKVLOJ5rKQV8tZiN06FaGSkCFjg2TfFhWikO8+pGIjWDZBizmtBhwYtUlb0 /r2Q== X-Gm-Message-State: ACrzQf0RPUdN1SGavya/pTrxjbfS7fk7haqtjEApDyDP+H9747fP8L7v xqN5+tmw7yCo8eQQeip0wDJkDQZi/W8= X-Google-Smtp-Source: AMsMyM5mDozLWdPM7BmUrhzoXKbJqvf2FgGBI/2M0YkXY92mHnQMMsymjB4LxECzUo8CaiOK7hMfKQ== X-Received: by 2002:a05:6214:c6d:b0:4b1:c751:ac7 with SMTP id t13-20020a0562140c6d00b004b1c7510ac7mr40879503qvj.96.1666842116805; Wed, 26 Oct 2022 20:41:56 -0700 (PDT) Received: from localhost.localdomain (dsl-152-21.b2b2c.ca. [66.158.152.21]) by smtp.gmail.com with ESMTPSA id f11-20020a05620a280b00b006eee3a09ff3sm265260qkp.69.2022.10.26.20.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 20:41:56 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 26 Oct 2022 23:41:54 -0400 Message-Id: <20221027034154.28435-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qv1-xf2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Hi, I've wanted this enough times now to finally get around implementing it :-). My main use case for it will be creating a /usr/bin/env symlink in 'guix shell' environments for portability with the #!/usr/bin/env shebang. While at it, I've improved error reporting and made it fail early when a symlink would point to a nonexistent file (dangling symlink). The test suite passes, and I've run the basic system test as well as the 'btrfs-root-os' one successfully. Thanks, Maxim Cournoyer (5): Makefile.am: Sort EXTRA_DIST entries. tests: Add a tests/utils.sh support file. install: Validate symlink target in evaluate-populate-directive. guix: shell: Add '--symlink' option. shell: Detect --symlink spec problems early. Makefile.am | 55 ++++--- doc/guix.texi | 9 +- gnu/build/install.scm | 78 ++++++--- guix/scripts/environment.scm | 298 +++++++++++++++++++---------------- guix/scripts/pack.scm | 208 ++++++++++++------------ guix/scripts/shell.scm | 77 ++++----- tests/guix-pack.sh | 2 +- tests/guix-shell.sh | 21 +++ tests/shell-utils.scm | 29 ++++ tests/utils.sh | 33 ++++ 10 files changed, 483 insertions(+), 327 deletions(-) create mode 100644 tests/shell-utils.scm create mode 100644 tests/utils.sh -- 2.37.3 From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 1/5] Makefile.am: Sort EXTRA_DIST entries. References: <20221027034154.28435-1-maxim.cournoyer@gmail.com> In-Reply-To: <20221027034154.28435-1-maxim.cournoyer@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Oct 2022 03:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16668426828170 (code B ref 58812); Thu, 27 Oct 2022 03:52:01 +0000 Received: (at 58812) by debbugs.gnu.org; 27 Oct 2022 03:51:22 +0000 Received: from localhost ([127.0.0.1]:55699 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvN-00027i-Re for submit@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:22 -0400 Received: from mail-qv1-f48.google.com ([209.85.219.48]:45958) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvK-00027R-PY for 58812@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:20 -0400 Received: by mail-qv1-f48.google.com with SMTP id j6so209737qvn.12 for <58812@debbugs.gnu.org>; Wed, 26 Oct 2022 20:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=r+QVyN6/PbHAP2xhF5z++AxkdcMVbiOuQBSnoBPpV30=; b=kOfFcHMKZat15qJaoBnxQnTFS59AccPZUrcZenyNXPOkuQ7quLLMnA+TCANem/kSSk VN3YjS/eqHBOq01lK7ykckVaSJSy93X6IUXIEwnwvICQoYnxCOdhb8vnBzOgZssfRZ70 pOrJqCFQxilLuqOf3C2Rq4GsEhv46QPn4LyXwkHjiNH3c66wI7AQSq2ZBsmU9TgC/uF7 UjaB/M9zXYz3IC8TNNCgwg46Mocl+/yNtj9DgSx6FKKUg06E056KI77Zq5cEmo3V73NO +qvxhompFmGtXTJXAT+kww1Xc7gYZ2InooysVCYLCTvcVo6zrudcH8iHp1jHle4H+yE3 qqug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=r+QVyN6/PbHAP2xhF5z++AxkdcMVbiOuQBSnoBPpV30=; b=W7uxaym3wMuly7YsPMRnZ1D2iPf59rysGSyYrgyJ6Cr0MM5TusmwVXy9kDimxN782x tLrA0JSmELMSOGpoSdswzsR32Pcu2QtSC23v+b6I9wJ1HAtzy6OH8Txj+m6lo2BcGMqP 91uMVcVpvb0X5SsWSrqbuQIRD7TEQgwPqlvbnFM4L8gJ/PWSySv6SCimTGLHOe7boiU/ HFXfVQ+YwDu+YyUlh6p6UGhmHgc0Tigd/QC2xCtJo6ziOyQ3APL0ts5J1MF401Baws3P N9+VrzGvl4rJDmudKZnSrMmmsmAckIDkj8oDjGwnby/NVsLnT0g1FjYK/xFWo5y3VCCJ ey7g== X-Gm-Message-State: ACrzQf0DA1kdD9iRn1k/0EoRqBTdJweemt1taqXrQlyJtSeF8hKG1Qty g3nl0QjYwQk21Mf7Bg+pHxnknWz59c8= X-Google-Smtp-Source: AMsMyM5wu36xwuJ1Lb2fViZe9Np7qKeedUaZZJ3YktxTL+5vTs5TLWdW1fsMN6pXhIHWVIeWn5NM7w== X-Received: by 2002:ad4:5ca7:0:b0:4bb:97ea:27b5 with SMTP id q7-20020ad45ca7000000b004bb97ea27b5mr4584939qvh.104.1666842672944; Wed, 26 Oct 2022 20:51:12 -0700 (PDT) Received: from localhost.localdomain (dsl-152-21.b2b2c.ca. [66.158.152.21]) by smtp.gmail.com with ESMTPSA id x1-20020a05620a448100b006ec771d8f89sm255488qkp.112.2022.10.26.20.51.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 20:51:12 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 26 Oct 2022 23:50:56 -0400 Message-Id: <20221027035100.28852-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.1 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.9 (/) * Makefile.am (EXTRA_DIST): Sort. --- Makefile.am | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Makefile.am b/Makefile.am index 22dcc43f99..6cc7c0c4a0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -658,49 +658,49 @@ dist_fishcompletion_DATA = etc/completion/fish/guix.fish nodist_selinux_policy_DATA = etc/guix-daemon.cil EXTRA_DIST += \ - HACKING \ - ROADMAP \ - TODO \ - CODE-OF-CONDUCT \ .dir-locals.el \ .guix-authorizations \ .guix-channel \ - scripts/guix.in \ - etc/disarchive-manifest.scm \ - etc/guix-install.sh \ - etc/news.scm \ - etc/release-manifest.scm \ - etc/source-manifest.scm \ - etc/system-tests.scm \ - etc/time-travel-manifest.scm \ - etc/historical-authorizations \ + CODE-OF-CONDUCT \ + HACKING \ + ROADMAP \ + TODO \ + bootstrap \ build-aux/build-self.scm \ - build-aux/compile-all.scm \ - build-aux/cuirass/hurd-manifest.scm \ - build-aux/check-final-inputs-self-contained.scm \ build-aux/check-channel-news.scm \ + build-aux/check-final-inputs-self-contained.scm \ + build-aux/compile-all.scm \ build-aux/compile-as-derivation.scm \ + build-aux/config.rpath \ build-aux/convert-xref.scm \ + build-aux/cuirass/hurd-manifest.scm \ build-aux/generate-authors.scm \ build-aux/test-driver.scm \ - build-aux/update-guix-package.scm \ build-aux/update-NEWS.scm \ - tests/test.drv \ + build-aux/update-guix-package.scm \ + doc/build.scm \ + etc/disarchive-manifest.scm \ + etc/guix-install.sh \ + etc/historical-authorizations \ + etc/news.scm \ + etc/release-manifest.scm \ + etc/source-manifest.scm \ + etc/system-tests.scm \ + etc/time-travel-manifest.scm \ + scripts/guix.in \ tests/cve-sample.json \ - tests/keys/signing-key.pub \ - tests/keys/signing-key.sec \ tests/keys/civodul.pub \ - tests/keys/rsa.pub \ tests/keys/dsa.pub \ - tests/keys/ed25519.pub \ - tests/keys/ed25519.sec \ tests/keys/ed25519-2.pub \ tests/keys/ed25519-2.sec \ tests/keys/ed25519-3.pub \ tests/keys/ed25519-3.sec \ - build-aux/config.rpath \ - bootstrap \ - doc/build.scm \ + tests/keys/ed25519.pub \ + tests/keys/ed25519.sec \ + tests/keys/rsa.pub \ + tests/keys/signing-key.pub \ + tests/keys/signing-key.sec \ + tests/test.drv \ $(TESTS) if !BUILD_DAEMON_OFFLOAD -- 2.37.3 From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 2/5] tests: Add a tests/utils.sh support file. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Oct 2022 03:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16668426878187 (code B ref 58812); Thu, 27 Oct 2022 03:52:02 +0000 Received: (at 58812) by debbugs.gnu.org; 27 Oct 2022 03:51:27 +0000 Received: from localhost ([127.0.0.1]:55702 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvS-00027z-Cz for submit@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:26 -0400 Received: from mail-qt1-f174.google.com ([209.85.160.174]:41863) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvP-00027W-7N for 58812@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:24 -0400 Received: by mail-qt1-f174.google.com with SMTP id c23so314049qtw.8 for <58812@debbugs.gnu.org>; Wed, 26 Oct 2022 20:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=mL2gSaxFm+dcFDnNEZn/yihf6iSJmqDld5LPoFpl9Yg=; b=WL9Mx2rmp9NXC9q+Ax1iJ1Y1hu6mr0KAB/qLt6JXeuFkA1FSxWIHbxbnsBk0lAdWb5 94CAvvTmRhbpcn0hBTO39bZQvtzTSmdRGtXlDsxFzRnK/XjXOTAOCufRjpfKzR70ZkXa 8s70gnRcY4VKbENfdXWrm1lAppanAtWpHcHU1IgdgrSoi7IpxWLfHAzS1Q1E7yhCoTvT RP1+UErVk7ckb2sAhhbA4qaxfhigQjjAuKFSM5q3t7+eRz44b1bZdZfPXX5V3M8otnwe RlgU18z3onmZ1cHDN3XgJ6nMeAdnNxsMRWLOj8dwCi1DVnTdtdt0+JR3R5ueoJ5Ytu/s 0wbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=mL2gSaxFm+dcFDnNEZn/yihf6iSJmqDld5LPoFpl9Yg=; b=QPODv6ivEqK0+3ejayvgNi6RX/MUjDSqCfJXmdI3iz/nR4m2BkVZwgyrFV+wqX8cuO xPOBkvnSwFAsc/XdpFGZ9c15b9bP7hU8EwTPemGBK2tjq6vmyuIZdVPdlD9q9DJ0z423 Dq5UcTvPVgthgJt0SZIe0qQ/5W+YpslZEvhidt7I8nB7AQcHKrh8Yh4pp+0BKZSIzbi6 kTcuYgIwXV5LbdazWlh/PS2Z+4TNk7h5mR74hPGVtBRyjhYF4plG8q9iZphPWSurRjoX CEetTyKRRuYBVCcXRXnzdyx8jO+LDBTnb+f/F/Sst4Np2CRm9Fwi393HY8RWvglP1fEi J90Q== X-Gm-Message-State: ACrzQf0vpuyDWSZEiYMwSCJlmwiNXWs+Qlhrqo7lgQIR8TdnNlHhlz2p hFbF3nk5JRdyyON+8a5vuLE+vii2G/Q= X-Google-Smtp-Source: AMsMyM7S/XyodqgNQYfPLhlOt/12Fo/cubSgycghtzPz5mC4FH+7etMStHXilblomOzT8VAo79yWlw== X-Received: by 2002:ac8:7e84:0:b0:39d:fd1:5a1d with SMTP id w4-20020ac87e84000000b0039d0fd15a1dmr30753751qtj.169.1666842676561; Wed, 26 Oct 2022 20:51:16 -0700 (PDT) Received: from localhost.localdomain (dsl-152-21.b2b2c.ca. [66.158.152.21]) by smtp.gmail.com with ESMTPSA id x1-20020a05620a448100b006ec771d8f89sm255488qkp.112.2022.10.26.20.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 20:51:16 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 26 Oct 2022 23:50:57 -0400 Message-Id: <20221027035100.28852-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221027035100.28852-1-maxim.cournoyer@gmail.com> References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) The purpose of this file will be to accumulate support shell functions for the shell-authored tests. * tests/shell-utils.scm: New file. * tests/utils.sh: Likewise. * Makefile.am (EXTRA_DIST): Register them. --- Makefile.am | 3 +++ tests/shell-utils.scm | 29 +++++++++++++++++++++++++++++ tests/utils.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 tests/shell-utils.scm create mode 100644 tests/utils.sh diff --git a/Makefile.am b/Makefile.am index 6cc7c0c4a0..14cbdcb011 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,6 +16,7 @@ # Copyright © 2019 Efraim Flashner # Copyright © 2021 Chris Marusich # Copyright © 2021 Andrew Tropin +# Copyright © 2021, 2022 Maxim Cournoyer # # This file is part of GNU Guix. # @@ -700,7 +701,9 @@ EXTRA_DIST += \ tests/keys/rsa.pub \ tests/keys/signing-key.pub \ tests/keys/signing-key.sec \ + tests/shell-utils.scm \ tests/test.drv \ + tests/utils.sh \ $(TESTS) if !BUILD_DAEMON_OFFLOAD diff --git a/tests/shell-utils.scm b/tests/shell-utils.scm new file mode 100644 index 0000000000..3ae9a414cd --- /dev/null +++ b/tests/shell-utils.scm @@ -0,0 +1,29 @@ +;; GNU Guix --- Functional package management for GNU +;; Copyright © 2022 Maxim Cournoyer +;; +;; This file is part of GNU Guix. +;; +;; GNU Guix is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3 of the License, or (at +;; your option) any later version. +;; +;; GNU Guix is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Guix. If not, see . +;; +;; Commentary: +;; +;; This file contains procedures that support the shell functions defined in +;; tests/utils.sh. +(use-modules (gnu build linux-container)) + +(define (container-support?) + (unless (and (user-namespace-supported?) + (unprivileged-user-namespace-supported?) + (setgroups-supported?)) + (exit 1))) diff --git a/tests/utils.sh b/tests/utils.sh new file mode 100644 index 0000000000..ba17f0de15 --- /dev/null +++ b/tests/utils.sh @@ -0,0 +1,33 @@ +# GNU Guix --- Functional package management for GNU +# Copyright © 2022 Maxim Cournoyer +# +# This file is part of GNU Guix. +# +# GNU Guix is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# GNU Guix is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Guix. If not, see . +# +# Commentary: +# +# This file provides utility shell functions that can be used in the shell +# test scripts. The file is intended to be sourced as a shell library. + +BASEDIR=$(dirname "$0") + +HAS_CONTAINER_SUPPORT= +has_container_support() { + if [ -z "$HAS_CONTAINER_SUPPORT" ]; then + guile -l "$BASEDIR/shell-utils.scm" -c '(container-support?)' + HAS_CONTAINER_SUPPORT=$? + fi + return "$HAS_CONTAINER_SUPPORT" +} -- 2.37.3 From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 3/5] install: Validate symlink target in evaluate-populate-directive. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Oct 2022 03:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16668426938208 (code B ref 58812); Thu, 27 Oct 2022 03:52:02 +0000 Received: (at 58812) by debbugs.gnu.org; 27 Oct 2022 03:51:33 +0000 Received: from localhost ([127.0.0.1]:55705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvY-00028K-UQ for submit@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:33 -0400 Received: from mail-qt1-f169.google.com ([209.85.160.169]:45775) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvX-00027y-Et for 58812@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:32 -0400 Received: by mail-qt1-f169.google.com with SMTP id x3so301684qtj.12 for <58812@debbugs.gnu.org>; Wed, 26 Oct 2022 20:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=lBkcrXstesL/RYcBdJo1quwLH1W3JOZ/ebtnOaJ5hnA=; b=HbVKAMNnEv1jYGZg/E3/OmgRuheAVsklxR0zKZw5pvwV/WTRHugqNghRWBxafc4Gdt 8f0weOchKjwLUu8hyTi2BTbE2j+nRqZHG/1NLdwFkpnoQF7w6lDnOE55E5E6diQA8xuR KRyzvIIXjqNoPBnzyJKbLNB5nsrzgqzmHof5jDbhRl0y+IuDyEXW27pwLKtw+armSiL5 dH5RbxZaJ2utBGPzsiXPgTCGfW3C2mLT7cL4adMNa51ZLwxfJEwV9aYrLnyAudRmrTgn KdvHBZX2vAUn1hoH3FBwsi240cqWrWmuFf2GgaltftNM6gT42FIwk29MPr8chVsu9j/w Xkmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=lBkcrXstesL/RYcBdJo1quwLH1W3JOZ/ebtnOaJ5hnA=; b=pl+2yK4eARYNOwLUg1V/N1/rNr2qIKtUUs3KnfBTas3kEFpg5UGjahmGMXY8MAFvC6 F0r+GIVn9Ijbc4MYkNiMU6gcn1PBN0RV6PXDtp1Pqg8t0toBEBJoWi1+DWJRjWVnwfIE McXkPAKX0vWYNYs/seCifU8xRlxPH1RMzDxugx/7SIbSUClnSA+eOvpTVPDCoqTN9SBv yuHSkhX7uRZHCMaafvdsBJ3rFWM5+BkB+BwILqU2NBc6tJISi0x+9YQW5zkaHCOPzD6/ teVnonxGNGq5xfLagw3cSGW2sJvJAzctURBL7ftdyI4nJiSoHPKGPCTKFpP+UU3U/KLu i3bA== X-Gm-Message-State: ACrzQf3Iqj78y1NhUTv+6vD9LJ+7lW4C6E/uSB5pmPAmNiGcTknoOcsY zW4hIztaxdCAZgRBc+hbababW3Lf128= X-Google-Smtp-Source: AMsMyM5kviHnp/nHdY7YhkXb4eQqfKvE6v2znuY6182uuRdSEfMdy8spS1iEjqrZz1VpSCzS/Jw1yQ== X-Received: by 2002:a05:622a:512:b0:39a:d23a:431a with SMTP id l18-20020a05622a051200b0039ad23a431amr39392656qtx.370.1666842685640; Wed, 26 Oct 2022 20:51:25 -0700 (PDT) Received: from localhost.localdomain (dsl-152-21.b2b2c.ca. [66.158.152.21]) by smtp.gmail.com with ESMTPSA id x1-20020a05620a448100b006ec771d8f89sm255488qkp.112.2022.10.26.20.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 20:51:25 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 26 Oct 2022 23:50:58 -0400 Message-Id: <20221027035100.28852-3-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221027035100.28852-1-maxim.cournoyer@gmail.com> References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/build/install.scm (evaluate-populate-directive): By default, error when the target of a symlink doesn't exist. Always ensure TARGET ends with "/". (populate-root-file-system): Call evaluate-populate-directive with #:error-on-dangling-symlink #t and add comment. --- gnu/build/install.scm | 60 ++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/gnu/build/install.scm b/gnu/build/install.scm index f5c8407b89..15cc29b2c8 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2016 Chris Marusich +;;; Copyright © 2022 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -56,19 +57,24 @@ (define (install-boot-config bootcfg bootcfg-location mount-point) (define* (evaluate-populate-directive directive target #:key (default-gid 0) - (default-uid 0)) + (default-uid 0) + (error-on-dangling-symlink? #t)) "Evaluate DIRECTIVE, an sexp describing a file or directory to create under directory TARGET. DEFAULT-UID and DEFAULT-GID are the default UID and GID in the context of the caller. If the directive matches those defaults then, -'chown' won't be run." +'chown' won't be run. When ERROR-ON-DANGLING-SYMLINK? is true, abort with an +error when a dangling symlink would be created." + (define target* (if (string-suffix? "/" target) + target + (string-append target "/"))) (let loop ((directive directive)) (catch 'system-error (lambda () (match directive (('directory name) - (mkdir-p (string-append target name))) + (mkdir-p (string-append target* name))) (('directory name uid gid) - (let ((dir (string-append target name))) + (let ((dir (string-append target* name))) (mkdir-p dir) ;; If called from a context without "root" permissions, "chown" ;; to root will fail. In that case, do not try to run "chown" @@ -78,27 +84,38 @@ (define* (evaluate-populate-directive directive target (chown dir uid gid)))) (('directory name uid gid mode) (loop `(directory ,name ,uid ,gid)) - (chmod (string-append target name) mode)) + (chmod (string-append target* name) mode)) (('file name) - (call-with-output-file (string-append target name) + (call-with-output-file (string-append target* name) (const #t))) (('file name (? string? content)) - (call-with-output-file (string-append target name) + (call-with-output-file (string-append target* name) (lambda (port) (display content port)))) ((new '-> old) - (let try () - (catch 'system-error - (lambda () - (symlink old (string-append target new))) - (lambda args - ;; When doing 'guix system init' on the current '/', some - ;; symlinks may already exists. Override them. - (if (= EEXIST (system-error-errno args)) - (begin - (delete-file (string-append target new)) - (try)) - (apply throw args)))))))) + (let ((new* (string-append target* new))) + (let try () + (catch 'system-error + (lambda () + (when error-on-dangling-symlink? + ;; When the symbolic link points to a relative path, + ;; checking if its target exists must be done relative to + ;; the link location. + (with-directory-excursion (if (string-prefix? "/" old) + (getcwd) + (dirname new*)) ;relative + (unless (file-exists? old) + (error (format #f "symlink `~a' points to nonexistent \ +file `~a'" new* old))))) + (symlink old new*)) + (lambda args + ;; When doing 'guix system init' on the current '/', some + ;; symlinks may already exists. Override them. + (if (= EEXIST (system-error-errno args)) + (begin + (delete-file new*) + (try)) + (apply throw args))))))))) (lambda args ;; Usually we can only get here when installing to an existing root, ;; as with 'guix system init foo.scm /'. @@ -142,7 +159,10 @@ (define* (populate-root-file-system system target includes /etc, /var, /run, /bin/sh, etc., and all the symlinks to SYSTEM. EXTRAS is a list of directives appended to the built-in directives to populate TARGET." - (for-each (cut evaluate-populate-directive <> target) + ;; It's expected that some symbolic link targets do not exist yet, so do not + ;; error on dangling links. + (for-each (cut evaluate-populate-directive <> target + #:error-on-dangling-symlink? #f) (append (directives (%store-directory)) extras)) ;; Add system generation 1. -- 2.37.3 From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 4/5] guix: shell: Add '--symlink' option. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Oct 2022 03:52:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16668426988232 (code B ref 58812); Thu, 27 Oct 2022 03:52:03 +0000 Received: (at 58812) by debbugs.gnu.org; 27 Oct 2022 03:51:38 +0000 Received: from localhost ([127.0.0.1]:55709 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvd-00028h-Cz for submit@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:38 -0400 Received: from mail-qk1-f180.google.com ([209.85.222.180]:35464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontva-000289-0q for 58812@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:34 -0400 Received: by mail-qk1-f180.google.com with SMTP id t25so59069qkm.2 for <58812@debbugs.gnu.org>; Wed, 26 Oct 2022 20:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=29aVTpeUdjJsL8lVL89s8hfCGp0QFSMpucAGwZp64Yg=; b=VtKk0+vPD9AXP47OBxX8BXnoCANd2enXxUKyMGpvvcX2itpLVbKiOciiQjb2PtK6+C WHwWmqQMeXspfvrdpwrXI6hGQYNUTK1cllEmr4JipHbUW1uiMjUAFiJTcBmXhVNd5rho /VTb2T+v8K/dwQmx07zHOw7SGhwSsZ9ckcnbiR6gKWfbvZ/DuSfPKXYVuKzX+DM7kEPH GEZYnehQphjR8H2rQxG2jNl3SJNv0LBiPoJiGUJ3KD1uD3i6gk9A/+s748mdYIdv/Go0 Bm6CAnufo8fubUFpYH1LxtMQ80F3zDA+057lQyUlS3/Fh73e8BXqRMBKRebIXf2S9LDV ggsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=29aVTpeUdjJsL8lVL89s8hfCGp0QFSMpucAGwZp64Yg=; b=SkExV2tOeTfzprKKd6di4mFZY3pB/44jgae0yuyqXE3iKHnnLQ2ojDMEfrqXG27ch4 Ei1CDIWlx1ejxgzZyAPTnT8zBgJs6T5Uq09sM7TM37kTsTFwWt4cF9siIgZAaaLeKFl/ twFHiS456oqRUsTp7Dtvf7Vf8f7nECZdfptV19GhlKb5ky9Dd2IO4HhxwrMy7Ur4FJMX NpxmNWOdp20QLeeVbzV3QxKADnxKONCX8N5LbXxU+UGHO1NEj+K81ctGHIqYi1wneVkc PjjHOHW9O4wjLPnTZioLbW9gFQ/sDG9U4lkC7qHNToe3JIUxKHDDCHU+h68wCLnLjaEH 8Pwg== X-Gm-Message-State: ACrzQf3zugw4Y29VNq6LGO40zf/JFJebqkrb4AAfEaNPk1HemaE2qvom vc15t2r7yDmYJcXfqPlXFPtFN98pnUA= X-Google-Smtp-Source: AMsMyM6epFMwJjqBJnoA3oBCvzoSEYCSodz4hhWzRflMmhD40N8I5nICZpMlgs9R6r9hOlyRDVP5xg== X-Received: by 2002:a05:620a:6c5:b0:6f1:99b:a2b6 with SMTP id 5-20020a05620a06c500b006f1099ba2b6mr19626036qky.299.1666842688127; Wed, 26 Oct 2022 20:51:28 -0700 (PDT) Received: from localhost.localdomain (dsl-152-21.b2b2c.ca. [66.158.152.21]) by smtp.gmail.com with ESMTPSA id x1-20020a05620a448100b006ec771d8f89sm255488qkp.112.2022.10.26.20.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 20:51:27 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 26 Oct 2022 23:50:59 -0400 Message-Id: <20221027035100.28852-4-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221027035100.28852-1-maxim.cournoyer@gmail.com> References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/scripts/pack.scm (%options): Extract symlink parsing logic to... (symlink-spec-option-parser): ... here. (self-contained-tarball/builder): Extract symlink->directives logic to... * gnu/build/install.scm (make-symlink->directives): ... here. Add a comment mentioning why a relative file name is used for the link target. * guix/scripts/environment.scm (show-environment-options-help): Document new --symlink option. (%default-options): Add default value for symlinks. (%options): Register new symlink option. (launch-environment/container): Add #:symlinks argument and extend doc. Create symlinks using evaluate-populate-directive and make-symlink->directives. (guix-environment*): Pass symlinks arguments to launch-environment/container. * doc/guix.texi (Invoking guix shell): Document it. * tests/guix-shell.sh: Test it. --- doc/guix.texi | 9 +++++- gnu/build/install.scm | 18 ++++++++++++ guix/scripts/environment.scm | 38 +++++++++++++++++------- guix/scripts/pack.scm | 57 +++++++++++++++--------------------- tests/guix-shell.sh | 17 +++++++++++ 5 files changed, 94 insertions(+), 45 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 2f7ab61aec..4bd3c18223 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -49,7 +49,7 @@ Copyright @copyright{} 2017 humanitiesNerd@* Copyright @copyright{} 2017, 2021 Christine Lemmer-Webber@* Copyright @copyright{} 2017, 2018, 2019, 2020, 2021, 2022 Marius Bakke@* Copyright @copyright{} 2017, 2019, 2020, 2022 Hartmut Goebel@* -Copyright @copyright{} 2017, 2019, 2020, 2021 Maxim Cournoyer@* +Copyright @copyright{} 2017, 2019, 2020, 2021, 2022 Maxim Cournoyer@* Copyright @copyright{} 2017–2022 Tobias Geerinckx-Rice@* Copyright @copyright{} 2017 George Clemmer@* Copyright @copyright{} 2017 Andy Wingo@* @@ -6230,6 +6230,12 @@ directory: guix shell --container --expose=$HOME=/exchange guile -- guile @end example +@cindex symbolic links, guix shell +@item --symlink=@var{spec} +@itemx -S @var{spec} +For containers, create the symbolic links specified by @var{spec}, as +documented in @ref{pack-symlink-option}. + @cindex file system hierarchy standard (FHS) @cindex FHS (file system hierarchy standard) @item --emulate-fhs @@ -7022,6 +7028,7 @@ Compress the resulting tarball using @var{tool}---one of @code{gzip}, @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression. +@anchor{pack-symlink-option} @item --symlink=@var{spec} @itemx -S @var{spec} Add the symlinks specified by @var{spec} to the pack. This option can diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 15cc29b2c8..8cf772f3ea 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -19,6 +19,7 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu build install) + #:use-module ((guix build union) #:select (relative-file-name)) #:use-module (guix build syscalls) #:use-module (guix build utils) #:use-module (guix build store-copy) @@ -26,6 +27,7 @@ (define-module (gnu build install) #:use-module (ice-9 match) #:export (install-boot-config evaluate-populate-directive + make-symlink->directives populate-root-file-system install-database-and-gc-roots populate-single-profile-directory @@ -124,6 +126,22 @@ (define target* (if (string-suffix? "/" target) directive) (apply throw args))))) +(define (make-symlink->directives directory) + "Return a procedure that turn symlinks specs into directives that target +DIRECTORY." + (match-lambda + ((source '-> target) + (let ((target (string-append directory "/" target)) + (parent (dirname source))) + ;; Never add a 'directory' directive for "/" so as to preserve its + ;; ownership and avoid adding the same entries multiple times. + `(,@(if (string=? parent "/") + '() + `((directory ,parent))) + ;; Note: a relative file name is used for compatibility with + ;; relocatable packs. + (,source -> ,(relative-file-name parent target))))))) + (define (directives store) "Return a list of directives to populate the root file system that will host STORE." diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index de9bc8f98d..bd95329c5c 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -33,8 +33,10 @@ (define-module (guix scripts environment) #:use-module ((guix gexp) #:select (lower-object)) #:use-module (guix scripts) #:use-module (guix scripts build) + #:use-module ((guix scripts pack) #:select (symlink-spec-option-parser)) #:use-module (guix transformations) #:autoload (ice-9 ftw) (scandir) + #:use-module (gnu build install) #:autoload (gnu build linux-container) (call-with-container %namespaces user-namespace-supported? unprivileged-user-namespace-supported? @@ -120,6 +122,9 @@ (define (show-environment-options-help) --expose=SPEC for containers, expose read-only host file system according to SPEC")) (display (G_ " + -S, --symlink=SPEC for containers, add symlinks to the profile according + to SPEC, e.g. \"/usr/bin/env=bin/env\".")) + (display (G_ " -v, --verbosity=LEVEL use the given verbosity LEVEL")) (display (G_ " --bootstrap use bootstrap binaries to build the environment"))) @@ -157,6 +162,7 @@ (define (show-help) (define %default-options `((system . ,(%current-system)) (substitutes? . #t) + (symlinks . ()) (offload? . #t) (graft? . #t) (print-build-trace? . #t) @@ -256,6 +262,7 @@ (define %options (alist-cons 'file-system-mapping (specification->file-system-mapping arg #f) result))) + (option '(#\S "symlink") #t #f symlink-spec-option-parser) (option '(#\r "root") #t #f (lambda (opt name arg result) (alist-cons 'gc-root arg result))) @@ -672,7 +679,7 @@ (define* (launch-environment/fork command profile manifest (define* (launch-environment/container #:key command bash user user-mappings profile manifest link-profile? network? map-cwd? emulate-fhs? (setup-hook #f) - (white-list '())) + (symlinks '()) (white-list '())) "Run COMMAND within a container that features the software in PROFILE. Environment variables are set according to the search paths of MANIFEST. The global shell is BASH, a file name for a GNU Bash binary in the store. When @@ -690,6 +697,9 @@ (define* (launch-environment/container #:key command bash user user-mappings LINK-PROFILE? creates a symbolic link from ~/.guix-profile to the environment profile. +SYMLINKS must be a list of (SOURCE -> TARGET) tuples denoting symlinks to be +added to the container. + Preserve environment variables whose name matches the one of the regexps in WHILE-LIST." (define (optional-mapping->fs mapping) @@ -797,6 +807,10 @@ (define fhs-mappings (mkdir-p home-dir) (setenv "HOME" home-dir) + ;; Create symlinks. + (for-each (cut evaluate-populate-directive <> ".") + (append-map (make-symlink->directives profile) symlinks)) + ;; Call an additional setup procedure, if provided. (when setup-hook (setup-hook profile)) @@ -970,6 +984,7 @@ (define (guix-environment* opts) (let* ((pure? (assoc-ref opts 'pure)) (container? (assoc-ref opts 'container?)) (link-prof? (assoc-ref opts 'link-profile?)) + (symlinks (assoc-ref opts 'symlinks)) (network? (assoc-ref opts 'network?)) (no-cwd? (assoc-ref opts 'no-cwd?)) (emulate-fhs? (assoc-ref opts 'emulate-fhs?)) @@ -1010,15 +1025,17 @@ (define-syntax-rule (with-store/maybe store exp ...) (when container? (assert-container-features)) - (when (and (not container?) link-prof?) - (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) - (when (and (not container?) user) - (leave (G_ "'--user' cannot be used without '--container'~%"))) - (when (and (not container?) no-cwd?) - (leave (G_ "--no-cwd cannot be used without '--container'~%"))) - (when (and (not container?) emulate-fhs?) - (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) - + (when (not container?) + (when link-prof? + (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) + (when user + (leave (G_ "'--user' cannot be used without '--container'~%"))) + (when no-cwd? + (leave (G_ "--no-cwd cannot be used without '--container'~%"))) + (when emulate-fhs? + (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) + (when (pair? symlinks) + (leave (G_ "'--symlink' cannot be used without '--container~%'")))) (with-store/maybe store (with-status-verbosity (assoc-ref opts 'verbosity) @@ -1099,6 +1116,7 @@ (define manifest #:network? network? #:map-cwd? (not no-cwd?) #:emulate-fhs? emulate-fhs? + #:symlinks symlinks #:setup-hook (and emulate-fhs? setup-fhs)))) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 06849e4761..e3bddc4274 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -61,7 +61,9 @@ (define-module (guix scripts pack) #:use-module (srfi srfi-26) #:use-module (srfi srfi-37) #:use-module (ice-9 match) - #:export (self-contained-tarball + #:export (symlink-spec-option-parser + + self-contained-tarball debian-archive docker-image squashfs-image @@ -160,6 +162,21 @@ (define str (string-join names "-")) ((_) str) ((names ... _) (loop names)))))) +(define (symlink-spec-option-parser opt name arg result) + "A SRFI-37 option parser for the --symlink option." + ;; Note: Using 'string-split' allows us to handle empty + ;; TARGET (as in "/opt/guile=", meaning that /opt/guile is + ;; a symlink to the profile) correctly. + (match (string-split arg (char-set #\=)) + ((source target) + (let ((symlinks (assoc-ref result 'symlinks))) + (alist-cons 'symlinks + `((,source -> ,target) ,@symlinks) + (alist-delete 'symlinks result eq?)))) + (x + (leave (G_ "~a: invalid symlink specification~%") + arg)))) + ;;; ;;; Tarball format. @@ -204,30 +221,15 @@ (define (import-module? module) (use-modules (guix build pack) (guix build store-copy) (guix build utils) - ((guix build union) #:select (relative-file-name)) (gnu build install) (srfi srfi-1) - (srfi srfi-26) - (ice-9 match)) + (srfi srfi-26)) (define %root "root") - (define symlink->directives - ;; Return "populate directives" to make the given symlink and its - ;; parent directories. - (match-lambda - ((source '-> target) - (let ((target (string-append #$profile "/" target)) - (parent (dirname source))) - ;; Never add a 'directory' directive for "/" so as to - ;; preserve its ownership when extracting the archive (see - ;; below), and also because this would lead to adding the - ;; same entries twice in the tarball. - `(,@(if (string=? parent "/") - '() - `((directory ,parent))) - (,source - -> ,(relative-file-name parent target))))))) + ;; Return "populate directives" to make the given symlink and its + ;; parent directories. + (define symlink->directives (make-symlink->directives #$profile)) (define directives ;; Fully-qualified symlinks. @@ -1208,20 +1210,7 @@ (define %options (lambda (opt name arg result) (alist-cons 'compressor (lookup-compressor arg) result))) - (option '(#\S "symlink") #t #f - (lambda (opt name arg result) - ;; Note: Using 'string-split' allows us to handle empty - ;; TARGET (as in "/opt/guile=", meaning that /opt/guile is - ;; a symlink to the profile) correctly. - (match (string-split arg (char-set #\=)) - ((source target) - (let ((symlinks (assoc-ref result 'symlinks))) - (alist-cons 'symlinks - `((,source -> ,target) ,@symlinks) - (alist-delete 'symlinks result eq?)))) - (x - (leave (G_ "~a: invalid symlink specification~%") - arg))))) + (option '(#\S "symlink") #t #f symlink-spec-option-parser) (option '("save-provenance") #f #f (lambda (opt name arg result) (alist-cons 'save-provenance? #t result))) diff --git a/tests/guix-shell.sh b/tests/guix-shell.sh index 9a6b055264..32dd997fe7 100644 --- a/tests/guix-shell.sh +++ b/tests/guix-shell.sh @@ -20,6 +20,8 @@ # Test the 'guix shell' alias. # +. tests/utils.sh + guix shell --version configdir="t-guix-shell-config-$$" @@ -32,6 +34,21 @@ export XDG_CONFIG_HOME guix shell --bootstrap --pure guile-bootstrap -- guile --version +# '--symlink' can only be used with --container. +! guix shell --bootstrap guile-bootstrap -S /dummy=bin/guile + +if has_container_support; then + # '--symlink' works. + echo "TESTING SYMLINK IN CONTAINER" + guix shell --bootstrap guile-bootstrap --container \ + --symlink=/usr/bin/guile=bin/guile -- \ + /usr/bin/guile --version + + # A bad symlink spec causes the command to fail. + ! guix shell --bootstrap -CS bin/guile=/usr/bin/guile guile-bootstrap \ + -- exit +fi + # '--ad-hoc' is a thing of the past. ! guix shell --ad-hoc guile-bootstrap -- 2.37.3 From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 5/5] shell: Detect --symlink spec problems early. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Oct 2022 03:52:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16668427028243 (code B ref 58812); Thu, 27 Oct 2022 03:52:03 +0000 Received: (at 58812) by debbugs.gnu.org; 27 Oct 2022 03:51:42 +0000 Received: from localhost ([127.0.0.1]:55711 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvh-00028s-Ab for submit@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:42 -0400 Received: from mail-qk1-f176.google.com ([209.85.222.176]:46838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvb-00028C-T6 for 58812@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:37 -0400 Received: by mail-qk1-f176.google.com with SMTP id z30so34610qkz.13 for <58812@debbugs.gnu.org>; Wed, 26 Oct 2022 20:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=A1ut3YEaGjGeXf1OIwfqmBwfVEkyF0UR5QNsemaZYaI=; b=iTMlHyLulotGLwQsRLsp+O4hz4TiQ35aiksbxfPlTe+0nXNuk6gYJIo8rVmKJKmr8z xad3tfCN2d8pq77yWzkDD5mwLsHvB1vxrlnFoFSpEb4pCEVhnO6FOsomVpF2Nk7sif2I vyRM+0lyssFsuHq12zpHif2uXg2YZngSUJ7TgBwoX1FKjvJEqelq+bbrfi+L3ok6xSbu Ck8xDDadyFDMLBtsARIrctjcXhxCGi8JYw+XaZBNlmm0GgFKxeKxnfpEg7KQa1q+AA7y eajJ/6lGyT7POKZ0XQ8XHwZaemwdVrDUpk8qSo8OVGcyd18Ghv/2C6N5CrKv5FBVqmeA xfhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=A1ut3YEaGjGeXf1OIwfqmBwfVEkyF0UR5QNsemaZYaI=; b=48aaysVevFgvwOPqncoPfPRs5DRQZm1nTp+0gvO6HfrWHoRQKX+EOEOr2/26/CVJKy KDCSEGBNLyD1qgijioz88cJ9QhXYE5zrIaIxyH2N0AmH10Sr+KOmE9rGZlUq38tV77nK +f6+V2ze4jm+fhDE8YRirjRl24soSadGULUeTyI6dO6VGocAz5zrwrwFedL1eTg7UPfM 4oFz6cGBw+UfEZHvT1yVPFoGybTs8UhfcsgU0GgMSigS30djhDiwFQA0i3ztZHxDGWCU Iv/V+R7CY4PvlfV0oSmxnzttdJ2tSMoRt4ju88jyHCVa0z9tbFN2ukoN2asSuwTHJwya 8d9w== X-Gm-Message-State: ACrzQf2ZeqUHvEr/uTYB+G+lnN/8NmjZyqwgIOWAWUIbxIG2eHBkU7EG rYnsNl8R7+OaAp6w5HUqnrVvXV6YkMg= X-Google-Smtp-Source: AMsMyM6i62fbJWS0PSUcJLi7VJxfNjPBRx31HQ+4VEVVF5dZ16CvMUq8A8S/GJMI72x4nXzaVhYvZQ== X-Received: by 2002:a05:620a:4454:b0:6ee:764b:b7fc with SMTP id w20-20020a05620a445400b006ee764bb7fcmr32752980qkp.619.1666842689928; Wed, 26 Oct 2022 20:51:29 -0700 (PDT) Received: from localhost.localdomain (dsl-152-21.b2b2c.ca. [66.158.152.21]) by smtp.gmail.com with ESMTPSA id x1-20020a05620a448100b006ec771d8f89sm255488qkp.112.2022.10.26.20.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 20:51:29 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 26 Oct 2022 23:51:00 -0400 Message-Id: <20221027035100.28852-5-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221027035100.28852-1-maxim.cournoyer@gmail.com> References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/scripts/pack.scm (symlink-spec-option-parser): Remove extraneous char-set. Raise an exception when the target is an absolute file name. (guix-pack): Move with-error-handler earlier. * guix/scripts/shell.scm (guix-shell): Likewise. * guix/scripts/environment.scm (guix-environment): Wrap the whole guix-environment* call with the with-error-handling handler. * tests/guix-shell.sh: Add test. * tests/guix-pack.sh: Adjust symlink spec. --- guix/scripts/environment.scm | 294 +++++++++++++++++------------------ guix/scripts/pack.scm | 155 ++++++++++-------- guix/scripts/shell.scm | 77 ++++----- tests/guix-pack.sh | 2 +- tests/guix-shell.sh | 6 +- 5 files changed, 278 insertions(+), 256 deletions(-) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index bd95329c5c..0906b48508 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -975,158 +975,158 @@ (define-command (guix-environment . args) (category development) (synopsis "spawn one-off software environments (deprecated)") - (guix-environment* (parse-args args))) + (with-error-handling + (guix-environment* (parse-args args)))) (define (guix-environment* opts) "Run the 'guix environment' command on OPTS, an alist resulting for command-line option processing with 'parse-command-line'." - (with-error-handling - (let* ((pure? (assoc-ref opts 'pure)) - (container? (assoc-ref opts 'container?)) - (link-prof? (assoc-ref opts 'link-profile?)) - (symlinks (assoc-ref opts 'symlinks)) - (network? (assoc-ref opts 'network?)) - (no-cwd? (assoc-ref opts 'no-cwd?)) - (emulate-fhs? (assoc-ref opts 'emulate-fhs?)) - (user (assoc-ref opts 'user)) - (bootstrap? (assoc-ref opts 'bootstrap?)) - (system (assoc-ref opts 'system)) - (profile (assoc-ref opts 'profile)) - (command (or (assoc-ref opts 'exec) - ;; Spawn a shell if the user didn't specify - ;; anything in particular. - (if container? - ;; The user's shell is likely not available - ;; within the container. - '("/bin/sh") - (list %default-shell)))) - (mappings (pick-all opts 'file-system-mapping)) - (white-list (pick-all opts 'inherit-regexp))) - - (define store-needed? - ;; Whether connecting to the daemon is needed. - (or container? (not profile))) - - (define-syntax-rule (with-store/maybe store exp ...) - ;; Evaluate EXP... with STORE bound to a connection, unless - ;; STORE-NEEDED? is false, in which case STORE is bound to #f. - (let ((proc (lambda (store) exp ...))) - (if store-needed? - (with-store s - (set-build-options-from-command-line s opts) - (with-build-handler (build-notifier #:use-substitutes? - (assoc-ref opts 'substitutes?) - #:verbosity - (assoc-ref opts 'verbosity) - #:dry-run? - (assoc-ref opts 'dry-run?)) - (proc s))) - (proc #f)))) - - (when container? (assert-container-features)) - - (when (not container?) - (when link-prof? - (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) - (when user - (leave (G_ "'--user' cannot be used without '--container'~%"))) - (when no-cwd? - (leave (G_ "--no-cwd cannot be used without '--container'~%"))) - (when emulate-fhs? - (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) - (when (pair? symlinks) - (leave (G_ "'--symlink' cannot be used without '--container~%'")))) - - (with-store/maybe store - (with-status-verbosity (assoc-ref opts 'verbosity) - (define manifest-from-opts - (options/resolve-packages store opts)) - - (define manifest - (if profile - (profile-manifest profile) - manifest-from-opts)) - - (when (and profile - (> (length (manifest-entries manifest-from-opts)) 0)) - (leave (G_ "'--profile' cannot be used with package options~%"))) - - (when (null? (manifest-entries manifest)) - (warning (G_ "no packages specified; creating an empty environment~%"))) - - ;; Use the bootstrap Guile when requested. - (parameterize ((%graft? (assoc-ref opts 'graft?)) - (%guile-for-build - (and store-needed? - (package-derivation - store - (if bootstrap? - %bootstrap-guile - (default-guile)))))) - (run-with-store store - ;; Containers need a Bourne shell at /bin/sh. - (mlet* %store-monad ((bash (environment-bash container? - bootstrap? - system)) - (prof-drv (if profile - (return #f) - (manifest->derivation - manifest system bootstrap?))) - (profile -> (if profile - (readlink* profile) - (derivation->output-path prof-drv))) - (gc-root -> (assoc-ref opts 'gc-root))) - - ;; First build the inputs. This is necessary even for - ;; --search-paths. Additionally, we might need to build bash for - ;; a container. - (mbegin %store-monad - (mwhen store-needed? - (built-derivations (append - (if prof-drv (list prof-drv) '()) - (if (derivation? bash) (list bash) '())))) - (mwhen gc-root - (register-gc-root profile gc-root)) - - (mwhen (assoc-ref opts 'check?) - (return - (if container? - (warning (G_ "'--check' is unnecessary \ + (let* ((pure? (assoc-ref opts 'pure)) + (container? (assoc-ref opts 'container?)) + (link-prof? (assoc-ref opts 'link-profile?)) + (symlinks (assoc-ref opts 'symlinks)) + (network? (assoc-ref opts 'network?)) + (no-cwd? (assoc-ref opts 'no-cwd?)) + (emulate-fhs? (assoc-ref opts 'emulate-fhs?)) + (user (assoc-ref opts 'user)) + (bootstrap? (assoc-ref opts 'bootstrap?)) + (system (assoc-ref opts 'system)) + (profile (assoc-ref opts 'profile)) + (command (or (assoc-ref opts 'exec) + ;; Spawn a shell if the user didn't specify + ;; anything in particular. + (if container? + ;; The user's shell is likely not available + ;; within the container. + '("/bin/sh") + (list %default-shell)))) + (mappings (pick-all opts 'file-system-mapping)) + (white-list (pick-all opts 'inherit-regexp))) + + (define store-needed? + ;; Whether connecting to the daemon is needed. + (or container? (not profile))) + + (define-syntax-rule (with-store/maybe store exp ...) + ;; Evaluate EXP... with STORE bound to a connection, unless + ;; STORE-NEEDED? is false, in which case STORE is bound to #f. + (let ((proc (lambda (store) exp ...))) + (if store-needed? + (with-store s + (set-build-options-from-command-line s opts) + (with-build-handler (build-notifier #:use-substitutes? + (assoc-ref opts 'substitutes?) + #:verbosity + (assoc-ref opts 'verbosity) + #:dry-run? + (assoc-ref opts 'dry-run?)) + (proc s))) + (proc #f)))) + + (when container? (assert-container-features)) + + (when (not container?) + (when link-prof? + (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) + (when user + (leave (G_ "'--user' cannot be used without '--container'~%"))) + (when no-cwd? + (leave (G_ "--no-cwd cannot be used without '--container'~%"))) + (when emulate-fhs? + (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) + (when (pair? symlinks) + (leave (G_ "'--symlink' cannot be used without '--container~%'")))) + + (with-store/maybe store + (with-status-verbosity (assoc-ref opts 'verbosity) + (define manifest-from-opts + (options/resolve-packages store opts)) + + (define manifest + (if profile + (profile-manifest profile) + manifest-from-opts)) + + (when (and profile + (> (length (manifest-entries manifest-from-opts)) 0)) + (leave (G_ "'--profile' cannot be used with package options~%"))) + + (when (null? (manifest-entries manifest)) + (warning (G_ "no packages specified; creating an empty environment~%"))) + + ;; Use the bootstrap Guile when requested. + (parameterize ((%graft? (assoc-ref opts 'graft?)) + (%guile-for-build + (and store-needed? + (package-derivation + store + (if bootstrap? + %bootstrap-guile + (default-guile)))))) + (run-with-store store + ;; Containers need a Bourne shell at /bin/sh. + (mlet* %store-monad ((bash (environment-bash container? + bootstrap? + system)) + (prof-drv (if profile + (return #f) + (manifest->derivation + manifest system bootstrap?))) + (profile -> (if profile + (readlink* profile) + (derivation->output-path prof-drv))) + (gc-root -> (assoc-ref opts 'gc-root))) + + ;; First build the inputs. This is necessary even for + ;; --search-paths. Additionally, we might need to build bash for + ;; a container. + (mbegin %store-monad + (mwhen store-needed? + (built-derivations (append + (if prof-drv (list prof-drv) '()) + (if (derivation? bash) (list bash) '())))) + (mwhen gc-root + (register-gc-root profile gc-root)) + + (mwhen (assoc-ref opts 'check?) + (return + (if container? + (warning (G_ "'--check' is unnecessary \ when using '--container'; doing nothing~%")) - (validate-child-shell-environment profile manifest)))) - - (cond - ((assoc-ref opts 'search-paths) - (show-search-paths profile manifest #:pure? pure?) - (return #t)) - (container? - (let ((bash-binary - (if bootstrap? - (derivation->output-path bash) - (string-append (derivation->output-path bash) - "/bin/sh")))) - (launch-environment/container #:command command - #:bash bash-binary - #:user user - #:user-mappings mappings - #:profile profile - #:manifest manifest - #:white-list white-list - #:link-profile? link-prof? - #:network? network? - #:map-cwd? (not no-cwd?) - #:emulate-fhs? emulate-fhs? - #:symlinks symlinks - #:setup-hook - (and emulate-fhs? - setup-fhs)))) - - (else - (return - (exit/status - (launch-environment/fork command profile manifest - #:white-list white-list - #:pure? pure?)))))))))))))) + (validate-child-shell-environment profile manifest)))) + + (cond + ((assoc-ref opts 'search-paths) + (show-search-paths profile manifest #:pure? pure?) + (return #t)) + (container? + (let ((bash-binary + (if bootstrap? + (derivation->output-path bash) + (string-append (derivation->output-path bash) + "/bin/sh")))) + (launch-environment/container #:command command + #:bash bash-binary + #:user user + #:user-mappings mappings + #:profile profile + #:manifest manifest + #:white-list white-list + #:link-profile? link-prof? + #:network? network? + #:map-cwd? (not no-cwd?) + #:emulate-fhs? emulate-fhs? + #:symlinks symlinks + #:setup-hook + (and emulate-fhs? + setup-fhs)))) + + (else + (return + (exit/status + (launch-environment/fork command profile manifest + #:white-list white-list + #:pure? pure?))))))))))))) ;;; Local Variables: ;;; eval: (put 'with-store/maybe 'scheme-indent-function 1) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index e3bddc4274..a101900736 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -42,6 +42,7 @@ (define-module (guix scripts pack) #:use-module (guix profiles) #:use-module (guix describe) #:use-module (guix derivations) + #:use-module (guix diagnostics) #:use-module (guix search-paths) #:use-module (guix build-system gnu) #:use-module (guix scripts build) @@ -59,6 +60,7 @@ (define-module (guix scripts pack) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-35) #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:export (symlink-spec-option-parser @@ -163,12 +165,27 @@ (define str (string-join names "-")) ((names ... _) (loop names)))))) (define (symlink-spec-option-parser opt name arg result) - "A SRFI-37 option parser for the --symlink option." + "A SRFI-37 option parser for the --symlink option. The symlink spec accepts +the link file name as its left-hand side value and its target as its +right-hand side value. The target must be a relative link." ;; Note: Using 'string-split' allows us to handle empty ;; TARGET (as in "/opt/guile=", meaning that /opt/guile is ;; a symlink to the profile) correctly. - (match (string-split arg (char-set #\=)) + (match (string-split arg #\=) ((source target) + (when (string-prefix? "/" target) + (raise-exception + (make-compound-condition + (formatted-message (G_ "symlink target is absolute: '~a'~%") target) + (condition + (&fix-hint (hint (format #f (G_ "The target of the symlink must be +relative rather than absolute, as it is relative to the profile created. +Perhaps the source and target components of the symlink spec were inverted? +Below is a valid example, where the @file{/usr/bin/env} symbolic link is to +target the profile's @file{bin/env} file: +@example +--symlink=/usr/bin/env=bin/env +@end example")))))))) (let ((symlinks (assoc-ref result 'symlinks))) (alist-cons 'symlinks `((,source -> ,target) ,@symlinks) @@ -1310,74 +1327,74 @@ (define-command (guix-pack . args) (category development) (synopsis "create application bundles") - (define opts - (parse-command-line args %options (list %default-options))) - - (define maybe-package-argument - ;; Given an option pair, return a package, a package/output tuple, or #f. - (match-lambda - (('argument . spec) - (call-with-values - (lambda () - (specification->package+output spec)) - list)) - (('expression . exp) - (read/eval-package-expression exp)) - (x #f))) - - (define (manifest-from-args store opts) - (let* ((transform (options->transformation opts)) - (packages (map (match-lambda - (((? package? package) output) - (list (transform package) output)) - ((? package? package) - (list (transform package) "out"))) - (reverse - (filter-map maybe-package-argument opts)))) - (manifests (filter-map (match-lambda - (('manifest . file) file) - (_ #f)) - opts))) - (define with-provenance - (if (assoc-ref opts 'save-provenance?) - (lambda (manifest) - (map-manifest-entries - (lambda (entry) - (let ((entry (manifest-entry-with-provenance entry))) - (unless (assq 'provenance (manifest-entry-properties entry)) - (warning (G_ "could not determine provenance of package ~a~%") - (manifest-entry-name entry))) - entry)) - manifest)) - identity)) - - (with-provenance - (cond - ((and (not (null? manifests)) (not (null? packages))) - (leave (G_ "both a manifest and a package list were given~%"))) - ((not (null? manifests)) - (concatenate-manifests - (map (lambda (file) - (let ((user-module (make-user-module - '((guix profiles) (gnu))))) - (load* file user-module))) - manifests))) - (else - (packages->manifest packages)))))) - - (define (process-file-arg opts name) - ;; Validate that the file exists and return it as a object, - ;; else #f. - (let ((value (assoc-ref opts name))) - (match value - ((and (? string?) (not (? file-exists?))) - (leave (G_ "file provided with option ~a does not exist: ~a~%") - (string-append "--" (symbol->string name)) value)) - ((? string?) - (local-file value)) - (#f #f)))) - (with-error-handling + (define opts + (parse-command-line args %options (list %default-options))) + + (define maybe-package-argument + ;; Given an option pair, return a package, a package/output tuple, or #f. + (match-lambda + (('argument . spec) + (call-with-values + (lambda () + (specification->package+output spec)) + list)) + (('expression . exp) + (read/eval-package-expression exp)) + (x #f))) + + (define (manifest-from-args store opts) + (let* ((transform (options->transformation opts)) + (packages (map (match-lambda + (((? package? package) output) + (list (transform package) output)) + ((? package? package) + (list (transform package) "out"))) + (reverse + (filter-map maybe-package-argument opts)))) + (manifests (filter-map (match-lambda + (('manifest . file) file) + (_ #f)) + opts))) + (define with-provenance + (if (assoc-ref opts 'save-provenance?) + (lambda (manifest) + (map-manifest-entries + (lambda (entry) + (let ((entry (manifest-entry-with-provenance entry))) + (unless (assq 'provenance (manifest-entry-properties entry)) + (warning (G_ "could not determine provenance of package ~a~%") + (manifest-entry-name entry))) + entry)) + manifest)) + identity)) + + (with-provenance + (cond + ((and (not (null? manifests)) (not (null? packages))) + (leave (G_ "both a manifest and a package list were given~%"))) + ((not (null? manifests)) + (concatenate-manifests + (map (lambda (file) + (let ((user-module (make-user-module + '((guix profiles) (gnu))))) + (load* file user-module))) + manifests))) + (else + (packages->manifest packages)))))) + + (define (process-file-arg opts name) + ;; Validate that the file exists and return it as a object, + ;; else #f. + (let ((value (assoc-ref opts name))) + (match value + ((and (? string?) (not (? file-exists?))) + (leave (G_ "file provided with option ~a does not exist: ~a~%") + (string-append "--" (symbol->string name)) value)) + ((? string?) + (local-file value)) + (#f #f)))) + (with-store store (with-status-verbosity (assoc-ref opts 'verbosity) ;; Set the build options before we do anything else. diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm index a2836629ad..7708ce62a9 100644 --- a/guix/scripts/shell.scm +++ b/guix/scripts/shell.scm @@ -533,43 +533,44 @@ (define-command (guix-shell . args) (category development) (synopsis "spawn one-off software environments") - (define (cache-entries directory) - (filter-map (match-lambda - ((or "." "..") #f) - (file (string-append directory "/" file))) - (or (scandir directory) '()))) - - (define* (entry-expiration file) - ;; Return the time at which FILE, a cached profile, is considered expired. - (match (false-if-exception (lstat file)) - (#f 0) ;FILE may have been deleted in the meantime - (st (+ (stat:atime st) (* 60 60 24 7))))) - - (define opts - (parse-args args)) - - (define interactive? - (not (assoc-ref opts 'exec))) - - (if (assoc-ref opts 'check?) - (record-hint 'shell-check) - (when (and interactive? - (not (hint-given? 'shell-check)) - (not (assoc-ref opts 'container?)) - (not (assoc-ref opts 'search-paths))) - (display-hint (G_ "Consider passing the @option{--check} option once + (with-error-handling + (define (cache-entries directory) + (filter-map (match-lambda + ((or "." "..") #f) + (file (string-append directory "/" file))) + (or (scandir directory) '()))) + + (define* (entry-expiration file) + ;; Return the time at which FILE, a cached profile, is considered expired. + (match (false-if-exception (lstat file)) + (#f 0) ;FILE may have been deleted in the meantime + (st (+ (stat:atime st) (* 60 60 24 7))))) + + (define opts + (parse-args args)) + + (define interactive? + (not (assoc-ref opts 'exec))) + + (if (assoc-ref opts 'check?) + (record-hint 'shell-check) + (when (and interactive? + (not (hint-given? 'shell-check)) + (not (assoc-ref opts 'container?)) + (not (assoc-ref opts 'search-paths))) + (display-hint (G_ "Consider passing the @option{--check} option once to make sure your shell does not clobber environment variables."))) ) - ;; Clean the cache in EXIT-HOOK so that (1) it happens after potential use - ;; of cached profiles, and (2) cleanup actually happens, even when - ;; 'guix-environment*' calls 'exit'. - (add-hook! exit-hook - (lambda _ - (maybe-remove-expired-cache-entries - (%profile-cache-directory) - cache-entries - #:entry-expiration entry-expiration))) - - (if (assoc-ref opts 'export-manifest?) - (export-manifest opts (current-output-port)) - (guix-environment* opts))) + ;; Clean the cache in EXIT-HOOK so that (1) it happens after potential use + ;; of cached profiles, and (2) cleanup actually happens, even when + ;; 'guix-environment*' calls 'exit'. + (add-hook! exit-hook + (lambda _ + (maybe-remove-expired-cache-entries + (%profile-cache-directory) + cache-entries + #:entry-expiration entry-expiration))) + + (if (assoc-ref opts 'export-manifest?) + (export-manifest opts (current-output-port)) + (guix-environment* opts)))) diff --git a/tests/guix-pack.sh b/tests/guix-pack.sh index f19a0f754e..6fc9e3723b 100644 --- a/tests/guix-pack.sh +++ b/tests/guix-pack.sh @@ -103,7 +103,7 @@ fi guix pack --dry-run --bootstrap -f docker guile-bootstrap # Build a Docker image with a symlink. -guix pack --dry-run --bootstrap -f docker -S /opt/gnu=/ guile-bootstrap +guix pack --dry-run --bootstrap -f docker -S /opt/gnu= guile-bootstrap # Build a tarball pack of cross-compiled software. Use coreutils because # guile-bootstrap is not intended to be cross-compiled. diff --git a/tests/guix-shell.sh b/tests/guix-shell.sh index 32dd997fe7..70dd852009 100644 --- a/tests/guix-shell.sh +++ b/tests/guix-shell.sh @@ -44,9 +44,13 @@ if has_container_support; then --symlink=/usr/bin/guile=bin/guile -- \ /usr/bin/guile --version - # A bad symlink spec causes the command to fail. + # An invalid symlink spec causes the command to fail. ! guix shell --bootstrap -CS bin/guile=/usr/bin/guile guile-bootstrap \ -- exit + + # A dangling symlink causes the command to fail. + ! guix shell --bootstrap -CS /usr/bin/python=bin/python guile-bootstrap \ + -- exit fi # '--ad-hoc' is a thing of the past. -- 2.37.3 From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Nov 2022 20:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16680275368413 (code B ref 58812); Wed, 09 Nov 2022 20:59:01 +0000 Received: (at 58812) by debbugs.gnu.org; 9 Nov 2022 20:58:56 +0000 Received: from localhost ([127.0.0.1]:41047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oss9w-0002Bb-7z for submit@debbugs.gnu.org; Wed, 09 Nov 2022 15:58:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oss9u-0002BP-AR for 58812@debbugs.gnu.org; Wed, 09 Nov 2022 15:58:54 -0500 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 1oss9p-0005bd-2S; Wed, 09 Nov 2022 15:58:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=4lVaG61ilgTvnmfhujTMp7mZT4+w/Pn4s2PpbKyzIQQ=; b=hllCSPMWW2LDIZCAgM/I VQpDFjyDnbw3YX0vCYRSQR6ZL4JHKcDJg8FJCyhECOtkYryCFay39JFEXJiW124DQ5odCU8fUYdjT sCVZ0aHscjhROxp1reuh7hwcGN5kRqKH5UAjc7kFXIbgTx6BbjQSRHnJjAsjxVp0fM3iddGISU1xg SiGDr7ZBCE0DdwD0yDEYT0Q7AlH2q3jLVgardOHlViHhol8y/Hl5gruccKEg9EIPETh74psaBqd9+ EPxMqegYhe3KdexwGCN+/fGu+0ftBINlPvHGfqiB/lLm1bhBxkPkjIdjZT4wbEGt9oj/5g8tAtGp3 RJZjyCy7sNSNLg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oss9n-0001TZ-N0; Wed, 09 Nov 2022 15:58:48 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-4-maxim.cournoyer@gmail.com> Date: Wed, 09 Nov 2022 21:58:45 +0100 In-Reply-To: <20221027035100.28852-4-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Wed, 26 Oct 2022 23:50:59 -0400") Message-ID: <87r0ybonei.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, That looks like a useful improvement! Some comments below. Maxim Cournoyer skribis: > +@item --symlink=3D@var{spec} > +@itemx -S @var{spec} > +For containers, create the symbolic links specified by @var{spec}, as > +documented in @ref{pack-symlink-option}. We should refrain from using @ref in sentences (info "(texinfo) @ref"). Instead, I=E2=80=99d write: documented for @command{guix pack} (@pxref{pack-symlink-option}). > (define-module (gnu build install) > + #:use-module ((guix build union) #:select (relative-file-name)) > #:use-module (guix build syscalls) > #:use-module (guix build utils) > #:use-module (guix build store-copy) > @@ -26,6 +27,7 @@ (define-module (gnu build install) > #:use-module (ice-9 match) > #:export (install-boot-config > evaluate-populate-directive > + make-symlink->directives > populate-root-file-system > install-database-and-gc-roots > populate-single-profile-directory > @@ -124,6 +126,22 @@ (define target* (if (string-suffix? "/" target) > directive) > (apply throw args))))) >=20=20 > +(define (make-symlink->directives directory) > + "Return a procedure that turn symlinks specs into directives that targ= et > +DIRECTORY." > + (match-lambda > + ((source '-> target) > + (let ((target (string-append directory "/" target)) > + (parent (dirname source))) > + ;; Never add a 'directory' directive for "/" so as to preserve its > + ;; ownership and avoid adding the same entries multiple times. > + `(,@(if (string=3D? parent "/") > + '() > + `((directory ,parent))) > + ;; Note: a relative file name is used for compatibility with > + ;; relocatable packs. > + (,source -> ,(relative-file-name parent target))))))) I think it=E2=80=99s a case where I would refrain from factorizing because = this procedure, as shown by the comments and the use of =E2=80=98relative-file-n= ame=E2=80=99, is specifically tailored for the needs to =E2=80=98guix pack -f tarball=E2= =80=99. I=E2=80=99d prefer to have a similar but independently maintained variant of this procedure in (guix scripts environment) to avoid difficulties down the road. > +++ b/guix/scripts/environment.scm > @@ -33,8 +33,10 @@ (define-module (guix scripts environment) > #:use-module ((guix gexp) #:select (lower-object)) > #:use-module (guix scripts) > #:use-module (guix scripts build) > + #:use-module ((guix scripts pack) #:select (symlink-spec-option-parser= )) You can turn this into #:autoload so we don=E2=80=99t pay the price when not using =E2=80=98--symlink=E2=80=99. > +++ b/tests/guix-shell.sh > @@ -20,6 +20,8 @@ > # Test the 'guix shell' alias. > # >=20=20 > +. tests/utils.sh > + > guix shell --version >=20=20 > configdir=3D"t-guix-shell-config-$$" > @@ -32,6 +34,21 @@ export XDG_CONFIG_HOME >=20=20 > guix shell --bootstrap --pure guile-bootstrap -- guile --version >=20=20 > +# '--symlink' can only be used with --container. > +! guix shell --bootstrap guile-bootstrap -S /dummy=3Dbin/guile > + > +if has_container_support; then > + # '--symlink' works. > + echo "TESTING SYMLINK IN CONTAINER" > + guix shell --bootstrap guile-bootstrap --container \ > + --symlink=3D/usr/bin/guile=3Dbin/guile -- \ > + /usr/bin/guile --version This should go to =E2=80=98tests/guix-environment-container.sh=E2=80=99, wh= ich has all the container-related tests. Thanks, Ludo=E2=80=99. From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Nov 2022 21:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16680279899185 (code B ref 58812); Wed, 09 Nov 2022 21:07:02 +0000 Received: (at 58812) by debbugs.gnu.org; 9 Nov 2022 21:06:29 +0000 Received: from localhost ([127.0.0.1]:41060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ossHF-0002O5-9w for submit@debbugs.gnu.org; Wed, 09 Nov 2022 16:06:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36226) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ossHC-0002Nr-3d for 58812@debbugs.gnu.org; Wed, 09 Nov 2022 16:06:27 -0500 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 1ossH6-0005Cp-TB; Wed, 09 Nov 2022 16:06:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=xdmQ9rTv8g8+R7xitWKpx9Th6/JxLQyL9ezzcowbuxI=; b=ogJHSlxkqACJeSwMInYB OmPd7+umGI9AqhLtsmn8h7DRfgafALJga+20dxaTtQGtdS+9ede7wL9PIDgA2+qoVq3k2jypruus3 VX8Z5F+iiWYaIW2lJ9+3fLJqSDJdjWcZUbnyEp71Sv/bCnS56oN9geIIre+P+6chu5Y2faHkGkznP JV/GvLXIHkjZNEes4yHIUJYgzVKT6V5bwWFmDSyNoaN3kRwNX7hj3EefpTYkZghUzmuQTZsNQ1oqd ELYmXdYJFuqLrltftfpU87NyiWURH5IoME+xdYUKGm0CgXKHRX8xPoovMZcbx9sdBLpTus518r9Es wVNUjRgbyU9uug==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ossH5-0005fR-GM; Wed, 09 Nov 2022 16:06:20 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> Date: Wed, 09 Nov 2022 22:06:16 +0100 In-Reply-To: <20221027035100.28852-3-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Wed, 26 Oct 2022 23:50:58 -0400") Message-ID: <87leojon1z.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Maxim Cournoyer skribis: > * gnu/build/install.scm (evaluate-populate-directive): By default, error = when > the target of a symlink doesn't exist. Always ensure TARGET ends with "/= ". > (populate-root-file-system): Call evaluate-populate-directive with > #:error-on-dangling-symlink #t and add comment. [...] > + (define target* (if (string-suffix? "/" target) > + target > + (string-append target "/"))) Maybe make it: (let ((target (if =E2=80=A6))) =E2=80=A6) so there=E2=80=99s only one =E2=80=98target=E2=80=99 in scope (and no =E2= =80=98target*=E2=80=99); otherwise it=E2=80=99s easy to forget the =E2=80=98*=E2=80=99 and refer to wrong one. > + (let ((new* (string-append target* new))) Likewise. > + (when error-on-dangling-symlink? > + ;; When the symbolic link points to a relative path, > + ;; checking if its target exists must be done relat= ive to > + ;; the link location. > + (with-directory-excursion (if (string-prefix? "/" o= ld) > + (getcwd) > + (dirname new*)) ;rela= tive > + (unless (file-exists? old) > + (error (format #f "symlink `~a' points to nonex= istent \ > +file `~a'" new* old))))) > + (symlink old new*)) I would avoid the directory excursion when unnecessary: (unless (if (string-prefix? "/" old) (file-exists? old) (with-directory-excursion (dirname new) (file-exists? old))) =E2=80=A6) (We could use =E2=80=98lstat=E2=80=99 instead of =E2=80=98file-exists?=E2= =80=99 if we want to allow symlinks to dangling symlinks=E2=80=A6) Ludo=E2=80=99. From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Nov 2022 21:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16680280589295 (code B ref 58812); Wed, 09 Nov 2022 21:08:01 +0000 Received: (at 58812) by debbugs.gnu.org; 9 Nov 2022 21:07:38 +0000 Received: from localhost ([127.0.0.1]:41065 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ossIL-0002Pr-No for submit@debbugs.gnu.org; Wed, 09 Nov 2022 16:07:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36916) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ossIK-0002Pe-92 for 58812@debbugs.gnu.org; Wed, 09 Nov 2022 16:07:36 -0500 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 1ossIF-0005N3-37; Wed, 09 Nov 2022 16:07:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=VNzRBkOwdvJC/DcpQ6aRJL8L44MfAuWOtBnwz7smJ4M=; b=a0uoWx7YYEyVVk3Lk8Jp GzuUv7Mw26KW8KGXxsp+gLH2FlMFmBRm4LATQvCIG2zJXRZyMoSqrDAwJhWVNeAYrwyeD3QR6UsEB qRe2MbWjypt1EcM26TVbAWDxn4bmLQD9JJFCNdiYfpKZzGpQQEhOq7/gLWhMNbLYz2SEBIXOIq8Z6 4aSFMa5ws+IWjyXcQRfJrkc9XAbMdde9JEkc43xjI7+oaFi08fUUb1XK/wFnLAA995JqAseT3yd8N OFGucooMO6poRpd7mpRUsya/bsk1uN+36yRnvVXxUGAl4bBmYpd6xWqKPAc2BMUhS2AoK3N7cKf66 9hAshbVZbnGmVw==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ossIE-0005ii-Mh; Wed, 09 Nov 2022 16:07:30 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-2-maxim.cournoyer@gmail.com> Date: Wed, 09 Nov 2022 22:07:29 +0100 In-Reply-To: <20221027035100.28852-2-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Wed, 26 Oct 2022 23:50:57 -0400") Message-ID: <87h6z7omzy.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Maxim Cournoyer skribis: > The purpose of this file will be to accumulate support shell functions fo= r the > shell-authored tests. > > * tests/shell-utils.scm: New file. > * tests/utils.sh: Likewise. > * Makefile.am (EXTRA_DIST): Register them. Maybe we can discuss this one separately since it=E2=80=99s no longer stric= tly necessary if we move tests to =E2=80=98tests/guix-environment-container.sh= =E2=80=99? Ludo=E2=80=99. From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 03:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166804984812381 (code B ref 58812); Thu, 10 Nov 2022 03:11:02 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 03:10:48 +0000 Received: from localhost ([127.0.0.1]:41508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osxxn-0003Dc-Qq for submit@debbugs.gnu.org; Wed, 09 Nov 2022 22:10:48 -0500 Received: from mail-qt1-f170.google.com ([209.85.160.170]:43580) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osxxm-0003DQ-AW for 58812@debbugs.gnu.org; Wed, 09 Nov 2022 22:10:46 -0500 Received: by mail-qt1-f170.google.com with SMTP id a27so327420qtw.10 for <58812@debbugs.gnu.org>; Wed, 09 Nov 2022 19:10:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=gFhpnLHygsw9Jxxct5LBxMucG6Itgdd3ZDonwCDctw0=; b=R40W61H9Z/Nn88+jKIF84mehoDQnnocXXY3307MkDHIx14znZC7Umr8BqsqfBZhDA0 6bcv7OTNfnhirXAiicz9n7NnAkfhCvJD+LwzYJcCtojAe9uLRWmw3xlCl3FP2j17xChY nN1cZ7uVUShErbC/RfFhtbnKYI8jnEBZ8E1qrffbw8+2zx3iMb+F4HfO0uymyYdCbPuC pKyiu5EP3Bq+u4lmFs9xDPnurUF00IYCkkM0d64ak11rZq1OU+YFdDA+uvps/FTUevyC OzN/0jWy7bEHEXT6yaOuvEoY2ZJUumTrcPZ0ow+vZCcqXGQfy02pf3b3PVdCeO9ky+SB EFsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=gFhpnLHygsw9Jxxct5LBxMucG6Itgdd3ZDonwCDctw0=; b=vOSnF6ayLN0+/3dpU6wGhL4iFNlaifnNg7LlcNp7YtaPl7ETXbsaeQbFBT+NsyoOwn yZTxqy8T/nmQsQXc1RhbUOR6H9qj7DQ2b/94axZi9leIEtYU6Tqmcbh2oRFjeld6B9NH FZ5R1EmahWqYuQeLdQYEbPpzEEWGowFIoTZUls582A7PAtF9/MUdPW5Lc1fr7QVQ1irT jnWOyad6H7wh7Ay3gGR8u6XAtB0KIHII4c5YKLVYTIu3lHgcNf/UWTQf5bog6vlLZFri JYEQcuVsQ5oc1cTlgKvXESarswyyKcCCJZVCnmW/M6x49DJUYZaHnqgWTkWwPm+H7Bvn YlPg== X-Gm-Message-State: ACrzQf1a+YHJ2KAb8kYNggbP2ZQx08d6xesbUkJIJziRenHba0YLO7AY gynSc9au8aTp0eQ5hs0Kxvz1VK/xHXU= X-Google-Smtp-Source: AMsMyM6xe0tQiwdJ92Sl7pGM+24AL3/uLQ1Z9RZt9xL8bNpIlp1Nu5VHgzBPcmol1M+VeBL8jgHv5g== X-Received: by 2002:a05:622a:1902:b0:39c:efc6:b3cf with SMTP id w2-20020a05622a190200b0039cefc6b3cfmr49440149qtc.527.1668049840401; Wed, 09 Nov 2022 19:10:40 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id w27-20020a05620a0e9b00b006ee949b8051sm11818544qkm.51.2022.11.09.19.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 19:10:39 -0800 (PST) From: Maxim Cournoyer References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-4-maxim.cournoyer@gmail.com> <87r0ybonei.fsf_-_@gnu.org> Date: Wed, 09 Nov 2022 22:10:38 -0500 In-Reply-To: <87r0ybonei.fsf_-_@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Wed, 09 Nov 2022 21:58:45 +0100") Message-ID: <87fsery05t.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Ludo! Ludovic Court=C3=A8s writes: > Hi, > > That looks like a useful improvement! Some comments below. Thanks! > Maxim Cournoyer skribis: > >> +@item --symlink=3D@var{spec} >> +@itemx -S @var{spec} >> +For containers, create the symbolic links specified by @var{spec}, as >> +documented in @ref{pack-symlink-option}. > > We should refrain from using @ref in sentences (info "(texinfo) @ref"). > Instead, I=E2=80=99d write: > > documented for @command{guix pack} (@pxref{pack-symlink-option}). I've heard that from you before, but is there a reason against? I like to know the rationale for doing things a certain way, lest I forget :-). >From info '(texinfo) @ref': --8<---------------cut here---------------start------------->8--- 6.6 '@ref' =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D '@ref' is nearly the same as '@xref' except that it does not generate a 'See' in the printed output, just the reference itself. This makes it useful as the last part of a sentence. For example, For more information, @pxref{This}, and @ref{That}. produces in Info: For more information, *note This::, and *note That::. --8<---------------cut here---------------end--------------->8--- >> (define-module (gnu build install) >> + #:use-module ((guix build union) #:select (relative-file-name)) >> #:use-module (guix build syscalls) >> #:use-module (guix build utils) >> #:use-module (guix build store-copy) >> @@ -26,6 +27,7 @@ (define-module (gnu build install) >> #:use-module (ice-9 match) >> #:export (install-boot-config >> evaluate-populate-directive >> + make-symlink->directives >> populate-root-file-system >> install-database-and-gc-roots >> populate-single-profile-directory >> @@ -124,6 +126,22 @@ (define target* (if (string-suffix? "/" target) >> directive) >> (apply throw args))))) >> >> +(define (make-symlink->directives directory) >> + "Return a procedure that turn symlinks specs into directives that tar= get >> +DIRECTORY." >> + (match-lambda >> + ((source '-> target) >> + (let ((target (string-append directory "/" target)) >> + (parent (dirname source))) >> + ;; Never add a 'directory' directive for "/" so as to preserve i= ts >> + ;; ownership and avoid adding the same entries multiple times. >> + `(,@(if (string=3D? parent "/") >> + '() >> + `((directory ,parent))) >> + ;; Note: a relative file name is used for compatibility with >> + ;; relocatable packs. >> + (,source -> ,(relative-file-name parent target))))))) > > I think it=E2=80=99s a case where I would refrain from factorizing becaus= e this > procedure, as shown by the comments and the use of =E2=80=98relative-file= -name=E2=80=99, > is specifically tailored for the needs to =E2=80=98guix pack -f tarball= =E2=80=99. > > I=E2=80=99d prefer to have a similar but independently maintained variant= of > this procedure in (guix scripts environment) to avoid difficulties down > the road. I considered to duplicate it, but I opted to reuse it in the end because I care that the behavior is exactly the same between the two actions (guix shell --symlink vs guix pack --symlink). If the way we handle this is to be changed in the future, I'd want both to be changed at once, so they remain consistent. Does this make sense? >> +++ b/guix/scripts/environment.scm >> @@ -33,8 +33,10 @@ (define-module (guix scripts environment) >> #:use-module ((guix gexp) #:select (lower-object)) >> #:use-module (guix scripts) >> #:use-module (guix scripts build) >> + #:use-module ((guix scripts pack) #:select (symlink-spec-option-parse= r)) > > You can turn this into #:autoload so we don=E2=80=99t pay the price when = not > using =E2=80=98--symlink=E2=80=99. Done! Could Guile simply always use lazy loading (autoload by default)? Otherwise, when is it OK to use autoload and when is it not? >> +++ b/tests/guix-shell.sh >> @@ -20,6 +20,8 @@ >> # Test the 'guix shell' alias. >> # >> >> +. tests/utils.sh >> + >> guix shell --version >> >> configdir=3D"t-guix-shell-config-$$" >> @@ -32,6 +34,21 @@ export XDG_CONFIG_HOME >> >> guix shell --bootstrap --pure guile-bootstrap -- guile --version >> >> +# '--symlink' can only be used with --container. >> +! guix shell --bootstrap guile-bootstrap -S /dummy=3Dbin/guile >> + >> +if has_container_support; then >> + # '--symlink' works. >> + echo "TESTING SYMLINK IN CONTAINER" >> + guix shell --bootstrap guile-bootstrap --container \ >> + --symlink=3D/usr/bin/guile=3Dbin/guile -- \ >> + /usr/bin/guile --version > > This should go to =E2=80=98tests/guix-environment-container.sh=E2=80=99, = which has all > the container-related tests. Done, for the "has_container_support" conditional tests. Thanks for taking a peek! Maxim From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 03:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166805147614971 (code B ref 58812); Thu, 10 Nov 2022 03:38:02 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 03:37:56 +0000 Received: from localhost ([127.0.0.1]:41536 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osyO3-0003tP-LP for submit@debbugs.gnu.org; Wed, 09 Nov 2022 22:37:55 -0500 Received: from mail-qv1-f41.google.com ([209.85.219.41]:43758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osyO1-0003tC-U0 for 58812@debbugs.gnu.org; Wed, 09 Nov 2022 22:37:54 -0500 Received: by mail-qv1-f41.google.com with SMTP id c8so624495qvn.10 for <58812@debbugs.gnu.org>; Wed, 09 Nov 2022 19:37:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=wScroshOceDh1u4oPcLjbsF0sxENs65vlMlss7qGC+E=; b=JEBiQo+xwnULrJVmQW3pAx9N2VwumH4corCGfK+bIG4GRT6/hlzdx1hlH7k0fwM3ri s8B81a14DH1vSRrMCA6FckYSGGMdGFHNw6q+uL29KFNuGMKqf87inuXTlybHRfJA9uM9 7rInRJQKJFdfBsxSuea+Rmcu8WDj2ST387QJV4oGcdCXh2itPkCJy8RyM8BGw55eqbIc 7dpsL5/8mDSylHC6JNz98wwasJvt1/0KZ1A5lmrHAUVfQZYPyWuXqa7IZxXmwxg/DnJm TkbYGtbLItMQXquQAHEfyvq9v6jKiI6xUuZXiZo3rsKtkNNXfGJaaorclr2VyHOEBr4F QpKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wScroshOceDh1u4oPcLjbsF0sxENs65vlMlss7qGC+E=; b=tPeyw+oejjLz/INPpb49OvIytDz6CeU9Y3Fv47T3ndRPudAzBWNXrFkEc5ipz71LwR sF7PfarRNdH3V+J8kz3MEuz+dJPiYwW5sqOc70xBwcshNNvbwuZoBvrEK3kQmdVcAQrK brFnQyJv0yKUbxl2zgQlKnSeTnpo96e5HTG9Cz0sQyfoB6ezqR7wem3ESRiH3jKfRizo CgqxldcCMyNCZksYlWl9hGWIKlwIPbFuMsNxr2WhWPLxt4vSNSW3KoHsBP9XFWVgw7qZ uc6ulaxeufVQduzvlJAYEJCt2twM5aZDizLYyM0UNoBgsQWuNE2biKZlsVQQ1tbWGEB0 qxlg== X-Gm-Message-State: ACrzQf0RPu/NJV4Y8z8OM31xfzHcZbIAZXP2qsOqLYSn0+3115HBjULb Ibn33egu/ha2s4JQClyJJY8Z0XWSe6M= X-Google-Smtp-Source: AMsMyM46ZTUXDHXyn9jNKqaGr+QMK0tffTOEk+QMBe2B0o1yMH+vJAhprv9l8tb7E/Qt1wgKWA/Z6w== X-Received: by 2002:a05:6214:c27:b0:4bb:7a35:b344 with SMTP id a7-20020a0562140c2700b004bb7a35b344mr58661512qvd.29.1668051467935; Wed, 09 Nov 2022 19:37:47 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id t12-20020a37ea0c000000b006bb82221013sm12201440qkj.0.2022.11.09.19.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 19:37:47 -0800 (PST) From: Maxim Cournoyer References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> Date: Wed, 09 Nov 2022 22:37:46 -0500 In-Reply-To: <87leojon1z.fsf_-_@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Wed, 09 Nov 2022 22:06:16 +0100") Message-ID: <877d03xywl.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi again, Ludovic Court=C3=A8s writes: > Maxim Cournoyer skribis: > >> * gnu/build/install.scm (evaluate-populate-directive): By default, error= when >> the target of a symlink doesn't exist. Always ensure TARGET ends with "= /". >> (populate-root-file-system): Call evaluate-populate-directive with >> #:error-on-dangling-symlink #t and add comment. > > [...] > >> + (define target* (if (string-suffix? "/" target) >> + target >> + (string-append target "/"))) > > Maybe make it: > > (let ((target (if =E2=80=A6))) > =E2=80=A6) > > so there=E2=80=99s only one =E2=80=98target=E2=80=99 in scope (and no =E2= =80=98target*=E2=80=99); otherwise it=E2=80=99s > easy to forget the =E2=80=98*=E2=80=99 and refer to wrong one. It's a pattern I've used at other places; I find it more hygienic to not shadow existing variables; it signal to the reader "be careful, this is not the same as the argument-bound one, though they are closely related". >> + (when error-on-dangling-symlink? >> + ;; When the symbolic link points to a relative pat= h, >> + ;; checking if its target exists must be done rela= tive to >> + ;; the link location. >> + (with-directory-excursion (if (string-prefix? "/" = old) >> + (getcwd) >> + (dirname new*)) ;rel= ative >> + (unless (file-exists? old) >> + (error (format #f "symlink `~a' points to none= xistent \ >> +file `~a'" new* old))))) >> + (symlink old new*)) > > I would avoid the directory excursion when unnecessary: > > (unless (if (string-prefix? "/" old) > (file-exists? old) > (with-directory-excursion (dirname new) > (file-exists? old))) > =E2=80=A6) Done: --8<---------------cut here---------------start------------->8--- modified gnu/build/install.scm @@ -99,14 +99,14 @@ (define target* (if (string-suffix? "/" target) (lambda () (when error-on-dangling-symlink? ;; When the symbolic link points to a relative path, - ;; checking if its target exists must be done relativ= e to - ;; the link location. - (with-directory-excursion (if (string-prefix? "/" old) - (getcwd) - (dirname new*)) ;relati= ve - (unless (file-exists? old) - (error (format #f "symlink `~a' points to nonexis= tent \ -file `~a'" new* old))))) + ;; checking if its target exists must be done relativ= ely + ;; to the link location. + (unless (if (string-prefix? "/" old) + (file-exists? old) + (with-directory-excursion (dirname new*) + (file-exists? old))) + (error (format #f "symlink `~a' points to nonexiste= nt \ +file `~a'" new* old)))) (symlink old new*)) --8<---------------cut here---------------end--------------->8--- > (We could use =E2=80=98lstat=E2=80=99 instead of =E2=80=98file-exists?=E2= =80=99 if we want to allow > symlinks to dangling symlinks=E2=80=A6) It seems better to leave it as-is; the odd use case of symlinking to a dangling symlink can be accomplished via "#:error-on-dangling-symlink #f" :-). --=20 Thanks, Maxim From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 03:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166805153615076 (code B ref 58812); Thu, 10 Nov 2022 03:39:01 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 03:38:56 +0000 Received: from localhost ([127.0.0.1]:41540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osyP2-0003v6-3d for submit@debbugs.gnu.org; Wed, 09 Nov 2022 22:38:56 -0500 Received: from mail-qv1-f52.google.com ([209.85.219.52]:33649) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osyOz-0003up-QT for 58812@debbugs.gnu.org; Wed, 09 Nov 2022 22:38:54 -0500 Received: by mail-qv1-f52.google.com with SMTP id ml12so683437qvb.0 for <58812@debbugs.gnu.org>; Wed, 09 Nov 2022 19:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qJc6Nrn3bq3ywLhoAPpEy0RSwABInjJn1gotunyi2HE=; b=YGGIhq28ttjBUQ1HIahd8xdsAphcEpN8UqZCqyujWNTWk7YeWbJhhZXxrv46Xb8dwv VJl3f+GAESGdf9+2thxWijQPTkEaFqiFwNpEBuVQZUYIbwGx97Sxa10YtbOGpLI832yb 2k7gypUSYbkN52WaJG7eWGAwVpoM1ct0sanbWigMn4/KR/u0DuyGmxLACQJuibPyMe4w bF+E3n2s1BTCnppbXpHuUow5h6ft9meTrFAZfo/3rJ1KX/XxjIK7+PxWUfcfmdWyWhvX keVv6M8ZZDXkGvroDEgVfp4wBu1IKpiBbikGIiqTSvrBPcztLFs+byRRlWGkLqRSaoBn ob0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qJc6Nrn3bq3ywLhoAPpEy0RSwABInjJn1gotunyi2HE=; b=E682R7UwvhL2BMfSTJaYlRZG24onbi8SASHRcFe2ye1swnoyuFmYOu4LwAxvC3Q0wT OgaSIJIr24r525PBS4jccMPbzp8BuY9OKFKE186/iVqLeo6Q0x16SpHFfe/sWqzv8evj +kqTBWcp8xIFJyI4QJcqfiiFkL649Ug4uiwgnQhxmIhOuapvIljdkHIKKU59yxjRqz2G lkJcAJ4rX8J2wcjUhRUYxk6Y9j9JBcUbP5CkXzV7ohYT5MZNAmktdzSwFMAhgyNmGTb1 S0BQjdawmeRrfGOGhR4vkZD55IT9uxTLgtlNzv+DY+tBu/TE3TjYhNr9Grp8ijxZBpBT RrAg== X-Gm-Message-State: ACrzQf3HIHBwdztOVZgokyJm5D9rHF6v0qKFLoC0tFlBjIGTjZvQNaJ0 r6tEI6duP3BDi8WuDMY/2VfOWwTDA74= X-Google-Smtp-Source: AMsMyM71p8GNKhrO5eRSN17WSMyAzoRAK0IUsDGLc4QnTVi0bo8Ju9yJ5scF/mdkCn30cd2tRmvRDw== X-Received: by 2002:a05:6214:3b0d:b0:4bc:129b:d778 with SMTP id nm13-20020a0562143b0d00b004bc129bd778mr1148935qvb.92.1668051528160; Wed, 09 Nov 2022 19:38:48 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id i6-20020a05620a248600b006ecfb2c86d3sm12527026qkn.130.2022.11.09.19.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 19:38:47 -0800 (PST) From: Maxim Cournoyer In-Reply-To: <87h6z7omzy.fsf_-_@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Wed, 09 Nov 2022 22:07:29 +0100") References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-2-maxim.cournoyer@gmail.com> <87h6z7omzy.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) Date: Wed, 09 Nov 2022 22:38:47 -0500 Message-ID: <871qqbxyuw.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Ludovic Court=C3=A8s writes: > Maxim Cournoyer skribis: > >> The purpose of this file will be to accumulate support shell functions f= or the >> shell-authored tests. >> >> * tests/shell-utils.scm: New file. >> * tests/utils.sh: Likewise. >> * Makefile.am (EXTRA_DIST): Register them. > > Maybe we can discuss this one separately since it=E2=80=99s no longer str= ictly > necessary if we move tests to =E2=80=98tests/guix-environment-container.s= h=E2=80=99? Since it's not immediately necessary, I've dropped the commit for now. We can resurrect it or something similar if/when the need arises. --=20 Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 10 08:43:21 2022 Received: (at control) by debbugs.gnu.org; 10 Nov 2022 13:43:22 +0000 Received: from localhost ([127.0.0.1]:42291 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot7px-0002jn-M4 for submit@debbugs.gnu.org; Thu, 10 Nov 2022 08:43:21 -0500 Received: from mail-qv1-f42.google.com ([209.85.219.42]:43953) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot7pw-0002jb-3H for control@debbugs.gnu.org; Thu, 10 Nov 2022 08:43:20 -0500 Received: by mail-qv1-f42.google.com with SMTP id c8so1353180qvn.10 for ; Thu, 10 Nov 2022 05:43:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:from:to:message-id:date:from:to:cc:subject:date:message-id :reply-to; bh=zxD9xhBFIoOBax9tCeYsKMzgotmtmhdoVcNi0lEFyxM=; b=bpZp9BnecBjyMagNGmHCg/RTKcdtwZXsYHDL07BpVDRBDE5VRieMD3yN/TLsTZANrZ luSvg0yXPnqS3hKSd5n4oVo5wS2iJTIw9c2cf/KXTZdyhDkNztQGPz3dL7i7G3V7Kz4V 1MzVTj1R14S6GwmGenmmKUGX9h+ZZ/0iG5bKcYUGFS3XX8RnxrWeAg6PWt3dj7ga/hAy zy5Hi5TAEsaZE9+2c0qfKXQ7/MLxE7ymx2HvqJQxDiucpPPALWjBlVJHjihetXI6NRk3 6VzWEZRJRZwuDIiiRZ5Z1RL0UFJ4j9tJxxRiA5p697hhsLMvAKsMiwmAR277yHF/6OO/ u4lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:to:message-id:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zxD9xhBFIoOBax9tCeYsKMzgotmtmhdoVcNi0lEFyxM=; b=qYwEgmSmY5mYYhw0Nbt8uDiZJZXy/qtQV9K5i5qoT3XKAUMSF/CIe9vBT3tmlZz7uR h73gTO123GdhOS0Pik2mCxO/B07AQSK3jGrj8puyLorSOpGZweCjEudr4oAfni0OV90H rWeC5cjr8XyBiNTfWy31kamJRGiKeQZ8PnxVz6uETd8XHfDogH+AjT9G7FnMw/pikrwZ X3EGTWYIZUhrtHQh0+6mYab8IV8xYBX40QBAIUWVvH6f/0++T9msQq4YOEiSoekpJYSq dEh8xrNAyWum3vDuEZvVjZ7nz/GLolW2chAGYiihuVlnaSDv/nVam9D8jTooNUeryjnO 53iQ== X-Gm-Message-State: ACrzQf1uuDz0xbNNSl19UG+iGxRARAzVSFVSrLTPBR7/1iulZvYuJfnv oYzuX0/oM2/TmHdSORJhWm/1erIklq4= X-Google-Smtp-Source: AMsMyM5IXVysB1wwV2TAejvFSW18glvyghByjLe2yrIbX0ldTS8C4JMiuqzh4bv5a0rrDtZy9vsIpg== X-Received: by 2002:ad4:5eca:0:b0:4ba:535a:6d45 with SMTP id jm10-20020ad45eca000000b004ba535a6d45mr58952419qvb.56.1668087794494; Thu, 10 Nov 2022 05:43:14 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id j11-20020a05620a410b00b006ce40fbb8f6sm13046337qko.21.2022.11.10.05.43.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 05:43:14 -0800 (PST) Date: Thu, 10 Nov 2022 08:43:13 -0500 Message-Id: <87tu37vsb2.fsf@gmail.com> To: control@debbugs.gnu.org From: Maxim Cournoyer Subject: control message for bug #59164 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) forcemerge 59164 58812 quit From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 14:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166808985222458 (code B ref 58812); Thu, 10 Nov 2022 14:18:01 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 14:17:32 +0000 Received: from localhost ([127.0.0.1]:42348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot8Mz-0005q5-Cj for submit@debbugs.gnu.org; Thu, 10 Nov 2022 09:17:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot8Mu-0005po-8l for 58812@debbugs.gnu.org; Thu, 10 Nov 2022 09:17:28 -0500 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 1ot8Mp-0008Ec-2o; Thu, 10 Nov 2022 09:17:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=kfGvwKSt2aBUcmg02GMYmSuqlXayzNOV+DB3Ebd9KLk=; b=ntvv5fjSuV4EarLEPV2p kfUg6vEVAU5cnr9YVWeA5K9ekXkeSSEOxL6FjryteOSYKId8qGvfnfamQv42NNb/CX59LEGSnZNd5 X+r0XuGM+1TbZXe2yc0ZLYhvFUu9PeNsw54vfVoGJsCa8ia1wcxT2M2xEz97ezTJh/Ph6vx9Y94pl GtZhqtQHF5JI8nKEh9A2UgJDAqkVDDh8CJZ68n3SiLc4BbzwbGnsAav5Dti2/1YPf1bGqt4wq5XBn Zo4HVnAvb2BVTGLZ8oegCAIYGtH1Sev9NXYCjMRPTw5KvdjwjCAPLxMRy3My6M/H1pIWSOu2ZVDZy ZB5mZUcb6LMjOg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ot8Mo-0000GW-Mq; Thu, 10 Nov 2022 09:17:18 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-4-maxim.cournoyer@gmail.com> <87r0ybonei.fsf_-_@gnu.org> <87fsery05t.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: =?UTF-8?Q?D=C3=A9cadi?= 20 Brumaire an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour de la Herse X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 10 Nov 2022 15:17:17 +0100 In-Reply-To: <87fsery05t.fsf@gmail.com> (Maxim Cournoyer's message of "Wed, 09 Nov 2022 22:10:38 -0500") Message-ID: <87sfiqhp1u.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Maxim! Maxim Cournoyer skribis: >> We should refrain from using @ref in sentences (info "(texinfo) @ref"). >> Instead, I=E2=80=99d write: >> >> documented for @command{guix pack} (@pxref{pack-symlink-option}). > > I've heard that from you before, but is there a reason against? I like > to know the rationale for doing things a certain way, lest I forget :-). > From info '(texinfo) @ref': It=E2=80=99s right below the bit you quoted: The '@ref' command can tempt writers to express themselves in a manner that is suitable for a printed manual but looks awkward in the Info format. Bear in mind that your audience could be using both the printed and the Info format. For example: [=E2=80=A6] >>> +(define (make-symlink->directives directory) >>> + "Return a procedure that turn symlinks specs into directives that ta= rget >>> +DIRECTORY." >>> + (match-lambda >>> + ((source '-> target) >>> + (let ((target (string-append directory "/" target)) >>> + (parent (dirname source))) >>> + ;; Never add a 'directory' directive for "/" so as to preserve = its >>> + ;; ownership and avoid adding the same entries multiple times. >>> + `(,@(if (string=3D? parent "/") >>> + '() >>> + `((directory ,parent))) >>> + ;; Note: a relative file name is used for compatibility with >>> + ;; relocatable packs. >>> + (,source -> ,(relative-file-name parent target))))))) >> >> I think it=E2=80=99s a case where I would refrain from factorizing becau= se this >> procedure, as shown by the comments and the use of =E2=80=98relative-fil= e-name=E2=80=99, >> is specifically tailored for the needs to =E2=80=98guix pack -f tarball= =E2=80=99. >> >> I=E2=80=99d prefer to have a similar but independently maintained varian= t of >> this procedure in (guix scripts environment) to avoid difficulties down >> the road. > > I considered to duplicate it, but I opted to reuse it in the end because > I care that the behavior is exactly the same between the two actions > (guix shell --symlink vs guix pack --symlink). If the way we handle > this is to be changed in the future, I'd want both to be changed at > once, so they remain consistent. Does this make sense? They don=E2=80=99t have to be consistent. Use of =E2=80=98relative-file-na= me=E2=80=99 here for example is dictated by the needs of relocatable packs. It doesn=E2=80=99t = have to be this way here. I think it=E2=80=99s best to keep separate copies here (they likely won=E2= =80=99t be exactly the same). >>> +++ b/guix/scripts/environment.scm >>> @@ -33,8 +33,10 @@ (define-module (guix scripts environment) >>> #:use-module ((guix gexp) #:select (lower-object)) >>> #:use-module (guix scripts) >>> #:use-module (guix scripts build) >>> + #:use-module ((guix scripts pack) #:select (symlink-spec-option-pars= er)) >> >> You can turn this into #:autoload so we don=E2=80=99t pay the price when= not >> using =E2=80=98--symlink=E2=80=99. > > Done! Could Guile simply always use lazy loading (autoload by default)? #:select could be synonymous with #:autoload, if that=E2=80=99s what you me= an, but in general Guile cannot know whether autoloading is semantically equivalent to eagerly loading: there might be side-effects happening when the top-level of the module runs. > Otherwise, when is it OK to use autoload and when is it not? #:autoload exists as a way to amortize initialization costs and make sure only necessary functionality gets loaded, thereby reducing CPU and memory usage. Only the module user can tell whether #:autoload is appropriate. In general you=E2=80=99d use it for optional functionality that has a non-negligible memory footprint or that would noticeably degrade startup time. Ludo=E2=80=99. From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 14:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166809178425597 (code B ref 58812); Thu, 10 Nov 2022 14:50:01 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 14:49:44 +0000 Received: from localhost ([127.0.0.1]:42382 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot8sB-0006ek-F6 for submit@debbugs.gnu.org; Thu, 10 Nov 2022 09:49:43 -0500 Received: from mail-qk1-f181.google.com ([209.85.222.181]:35411) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot8s9-0006eW-LW for 58812@debbugs.gnu.org; Thu, 10 Nov 2022 09:49:42 -0500 Received: by mail-qk1-f181.google.com with SMTP id p18so1200607qkg.2 for <58812@debbugs.gnu.org>; Thu, 10 Nov 2022 06:49:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=h676HXPoHraPq3wL/psFnkd+VkgM/jfnbm5Tuqbo9kI=; b=VyC5rSvaZeIOCnQc8tldFAd0z3n1RZy3sEAn/JiwHmfXMrJfWX32o/7De1sxvMwZG/ VLLdKPKvlj4gUbeegFELVEzV4HvfnCNwqnQYjTIT2FBIzYnR3KlMuujQBkk2dk1vFUhZ JjaZBk0iN4eb/55elyYZ4hqJtpDfxPaLHsu/dFZx/miwb6cDnWIK4PUeheSm4q8SVKPw r/FneyTTvpckqVvzgdrRP7DXi7YZQWhO2lqFeqodDAzLKPmiV92hMYMTUI+RYofNJ+c3 AhlAn1mDdzn/sQdicSg6n5It/H5cT4cj+BGpDmCEyzKXweFvUOMIqeV1/KFapyBVbkzL Wc6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=h676HXPoHraPq3wL/psFnkd+VkgM/jfnbm5Tuqbo9kI=; b=SMcqeJajMezDMpQe0j3w7Fi/XLB1wuf6IYolNNFOP3xusHJT7K/wyahGg0bfIKY67D 7gd5Tw5duTYiHhH6o1LCyVFTcTG6uA5NyfTScyj9xGgmBOd2gi4B3ZQWCgcXqsMCcEqM bUsjN2HHlPqF/XJBmYDiKuX/BHivSGtYXPrPq00+L4vei7iCgjMd/IkgbAtSfpjwU8r1 wzFLzM32cx4Vhc1vgdrpsmpIgsitN/93eVjsY/Bnpsjq1vu0I3E4dFEcca263rslpUF0 OtD4Oiu+bZDbr0xQ4UtYFKvfRMEwmq/X1F9OzzmuN+XFnUU2IrmRr3G3qrOryIE5DjRo 9KtA== X-Gm-Message-State: ACrzQf0c23RSZu0uis8MnXDVUc2YkVcoYTUjEE51OSbLGdHyzdyiUjZ9 nGpI19pwA2f1WhT+xO9cpJmZ3EJceoI= X-Google-Smtp-Source: AMsMyM7k4HSZ0puO7Z7r56VydYhAfaFMr6zUuGZW369SGIwq47LKsr9MGn9XjQBQ5CkaWSC8cDY5BQ== X-Received: by 2002:a05:620a:c4a:b0:6cf:8135:e81d with SMTP id u10-20020a05620a0c4a00b006cf8135e81dmr46039066qki.280.1668091775686; Thu, 10 Nov 2022 06:49:35 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id y22-20020a05620a44d600b006f9c2be0b4bsm13302680qkp.135.2022.11.10.06.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 06:49:35 -0800 (PST) From: Maxim Cournoyer References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-4-maxim.cournoyer@gmail.com> <87r0ybonei.fsf_-_@gnu.org> <87fsery05t.fsf@gmail.com> <87sfiqhp1u.fsf@gnu.org> Date: Thu, 10 Nov 2022 09:49:34 -0500 In-Reply-To: <87sfiqhp1u.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Thu, 10 Nov 2022 15:17:17 +0100") Message-ID: <87k042x3sx.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Ludo! Ludovic Court=C3=A8s writes: > Hi Maxim! > > Maxim Cournoyer skribis: > >>> We should refrain from using @ref in sentences (info "(texinfo) @ref"). >>> Instead, I=E2=80=99d write: >>> >>> documented for @command{guix pack} (@pxref{pack-symlink-option}). >> >> I've heard that from you before, but is there a reason against? I like >> to know the rationale for doing things a certain way, lest I forget :-). >> From info '(texinfo) @ref': > > It=E2=80=99s right below the bit you quoted: > > The '@ref' command can tempt writers to express themselves in a > manner that is suitable for a printed manual but looks awkward in the > Info format. Bear in mind that your audience could be using both the > printed and the Info format. For example: [=E2=80=A6] Yes, and I don't get it :-) --8<---------------cut here---------------start------------->8--- The '@ref' command can tempt writers to express themselves in a manner that is suitable for a printed manual but looks awkward in the Info format. Bear in mind that your audience could be using both the printed and the Info format. For example: Sea surges are described in @ref{Hurricanes}. looks ok in the printed output: Sea surges are described in Section 6.7 [Hurricanes], page 72. but is awkward to read in Info, "note" being a verb: Sea surges are described in *note Hurricanes::. --8<---------------cut here---------------end--------------->8--- I don't see a "note" in the final sentence that should make it awkward? It's lacking a "see " prefix though, which could help to make things a bit clearer, I guess. It looks the same in info as in the pxref example given above: --8<---------------cut here---------------start------------->8--- For example, For more information, @pxref{This}, and @ref{That}. produces in Info: For more information, *note This::, and *note That::. --8<---------------cut here---------------end--------------->8--- I'm also unsure where the "see" comes before That:: above. Is it a mistake in the manual? >>>> +(define (make-symlink->directives directory) >>>> + "Return a procedure that turn symlinks specs into directives that t= arget >>>> +DIRECTORY." >>>> + (match-lambda >>>> + ((source '-> target) >>>> + (let ((target (string-append directory "/" target)) >>>> + (parent (dirname source))) >>>> + ;; Never add a 'directory' directive for "/" so as to preserve= its >>>> + ;; ownership and avoid adding the same entries multiple times. >>>> + `(,@(if (string=3D? parent "/") >>>> + '() >>>> + `((directory ,parent))) >>>> + ;; Note: a relative file name is used for compatibility with >>>> + ;; relocatable packs. >>>> + (,source -> ,(relative-file-name parent target))))))) >>> >>> I think it=E2=80=99s a case where I would refrain from factorizing beca= use this >>> procedure, as shown by the comments and the use of =E2=80=98relative-fi= le-name=E2=80=99, >>> is specifically tailored for the needs to =E2=80=98guix pack -f tarball= =E2=80=99. >>> >>> I=E2=80=99d prefer to have a similar but independently maintained varia= nt of >>> this procedure in (guix scripts environment) to avoid difficulties down >>> the road. >> >> I considered to duplicate it, but I opted to reuse it in the end because >> I care that the behavior is exactly the same between the two actions >> (guix shell --symlink vs guix pack --symlink). If the way we handle >> this is to be changed in the future, I'd want both to be changed at >> once, so they remain consistent. Does this make sense? > > They don=E2=80=99t have to be consistent. Use of =E2=80=98relative-file-= name=E2=80=99 here for > example is dictated by the needs of relocatable packs. It doesn=E2=80=99= t have > to be this way here. > > I think it=E2=80=99s best to keep separate copies here (they likely won= =E2=80=99t be > exactly the same). OK, I see you point about relative-file-name not being needed. I'll make the change. >>>> +++ b/guix/scripts/environment.scm >>>> @@ -33,8 +33,10 @@ (define-module (guix scripts environment) >>>> #:use-module ((guix gexp) #:select (lower-object)) >>>> #:use-module (guix scripts) >>>> #:use-module (guix scripts build) >>>> + #:use-module ((guix scripts pack) #:select (symlink-spec-option-par= ser)) >>> >>> You can turn this into #:autoload so we don=E2=80=99t pay the price whe= n not >>> using =E2=80=98--symlink=E2=80=99. >> >> Done! Could Guile simply always use lazy loading (autoload by default)? > > #:select could be synonymous with #:autoload, if that=E2=80=99s what you = mean, > but in general Guile cannot know whether autoloading is semantically > equivalent to eagerly loading: there might be side-effects happening > when the top-level of the module runs. Perhaps there could be a strict execution mode where it is assumed that side effects are not used when modules run? That seems a seldom used feature anyway, and could enable making lazy loading of modules the default. >> Otherwise, when is it OK to use autoload and when is it not? > > #:autoload exists as a way to amortize initialization costs and make > sure only necessary functionality gets loaded, thereby reducing CPU and > memory usage. > > Only the module user can tell whether #:autoload is appropriate. In > general you=E2=80=99d use it for optional functionality that has a > non-negligible memory footprint or that would noticeably degrade startup > time. > > Ludo=E2=80=99. Thank you for the explanations and review! I'll send a v3 shortly. -- Maxim From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 15:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166809339429583 (code B ref 58812); Thu, 10 Nov 2022 15:17:02 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 15:16:34 +0000 Received: from localhost ([127.0.0.1]:43966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot9IA-0007h5-5E for submit@debbugs.gnu.org; Thu, 10 Nov 2022 10:16:34 -0500 Received: from mail-qt1-f182.google.com ([209.85.160.182]:44831) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot9I4-0007gl-RI for 58812@debbugs.gnu.org; Thu, 10 Nov 2022 10:16:32 -0500 Received: by mail-qt1-f182.google.com with SMTP id l2so1053277qtq.11 for <58812@debbugs.gnu.org>; Thu, 10 Nov 2022 07:16:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=thQR6g5NmInuaUQQbyY7CA0nkkbpDKRXRQeC/tTmX44=; b=P0Q+W2ZOtCOcmodNLtuwwW72W7Z3rIENzpV+OHraYrNHzhgGimKowcW4kGuHSyFxY/ OTdwgrbQu1c3Eqc9ROSqX1S4VCaTd1Tt3o1oufXzFG6p+pHVXoarKYD9RvBFSyefRWFW dVF9r6q0ZYu2Pbo41KWJyOPOMxce5nTGffb4u7WidHE4NfBBo1MyBx8VYIpBcRMKoOXV cMvOeb0839kf1/sKaVjOWr+RpKRp0qNsrNicBxZo7sresqrzv9wSieaC2sp7/sQQoPhR EMt7z5fGstifdu4HzCmrMq4HkvIRkg9o0UItySPg0VqVaPCTa4fon9XxhRDZuxO9Nh07 pSCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=thQR6g5NmInuaUQQbyY7CA0nkkbpDKRXRQeC/tTmX44=; b=dQXLhaTjr6T9BGOrj3p9UZ6wfB2wMguQujOOwJDJ7SU3SO0+6nJSeUFVdX+tsKS6Wc VZj/6bH/7R/pkJbTOFQvhfrJuUN05EbNPd9ZEkezxVtkpuccEOe7iKcpn/mDZwzO10mg V/DmL0Q9AhNENJICOV7jgzssZcS+xoDi8UZII/7JIsY/p2ouQH1ehByzlAdAta7IbwQd KsQ1HrKcwViTlXeijoycAH2TionaFL2nOIipSZO+JCwTGjEXYhx019TSA3MHw6xPzmme q3noXKlU9ceNgWbd+slN6w4zWWZwBP5z3YPJFcPK+uqUakbE9iv2XVDzVQbVFqtSTf5A i8VQ== X-Gm-Message-State: ACrzQf0hIrGCEkjnB01LWYOy4p+5l6LvnvWhvmL64952CqpJnGDhicgM tu2M9y0oA7bo6qGRPiddu+PavvJa0G0= X-Google-Smtp-Source: AMsMyM5RV/Z63TySjn9Jo1yZTTeTc29H40H+niMCLREWdlMyAVv5RwrB6YIhoehIwhm6uhUuK4eVZg== X-Received: by 2002:ac8:5b4d:0:b0:3a4:f759:5a9f with SMTP id n13-20020ac85b4d000000b003a4f7595a9fmr52269643qtw.665.1668093382502; Thu, 10 Nov 2022 07:16:22 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id i2-20020a05620a150200b006b9c9b7db8bsm12616503qkk.82.2022.11.10.07.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 07:16:22 -0800 (PST) From: Maxim Cournoyer References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-4-maxim.cournoyer@gmail.com> <87r0ybonei.fsf_-_@gnu.org> <87fsery05t.fsf@gmail.com> <87sfiqhp1u.fsf@gnu.org> <87k042x3sx.fsf@gmail.com> Date: Thu, 10 Nov 2022 10:16:20 -0500 In-Reply-To: <87k042x3sx.fsf@gmail.com> (Maxim Cournoyer's message of "Thu, 10 Nov 2022 09:49:34 -0500") Message-ID: <87fseqx2kb.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Maxim Cournoyer writes: > Hi Ludo! > > Ludovic Court=C3=A8s writes: > >> Hi Maxim! >> >> Maxim Cournoyer skribis: >> >>>> We should refrain from using @ref in sentences (info "(texinfo) @ref"). >>>> Instead, I=E2=80=99d write: >>>> >>>> documented for @command{guix pack} (@pxref{pack-symlink-option}). >>> >>> I've heard that from you before, but is there a reason against? I like >>> to know the rationale for doing things a certain way, lest I forget :-). >>> From info '(texinfo) @ref': >> >> It=E2=80=99s right below the bit you quoted: >> >> The '@ref' command can tempt writers to express themselves in a >> manner that is suitable for a printed manual but looks awkward in the >> Info format. Bear in mind that your audience could be using both the >> printed and the Info format. For example: [=E2=80=A6] > > Yes, and I don't get it :-) To be more concrete, this is what it looks currently: --8<---------------cut here---------------start------------->8--- =E2=80=98--symlink=3DSPEC=E2=80=99 =E2=80=98-S SPEC=E2=80=99 For containers, create the symbolic links specified by SPEC, as documented in *note pack-symlink-option::. --8<---------------cut here---------------end--------------->8--- This is what it'd look if I use (see: @pxref ...) instead: --8<---------------cut here---------------start------------->8--- =E2=80=98--symlink=3DSPEC=E2=80=99 =E2=80=98-S SPEC=E2=80=99 For containers, create the symbolic links specified by SPEC (see: *note pack-symlink-option::). --8<---------------cut here---------------end--------------->8--- Contrary to what the Texinfo manual says, pxref seems to be the one introducing the awkward "*note" verb in the resulting info. --=20 Thanks, Maxim From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH v3 1/4] Makefile.am: Sort EXTRA_DIST entries. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 16:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16680963752018 (code B ref 58812); Thu, 10 Nov 2022 16:07:02 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 16:06:15 +0000 Received: from localhost ([127.0.0.1]:44041 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otA4E-0000WT-Qq for submit@debbugs.gnu.org; Thu, 10 Nov 2022 11:06:15 -0500 Received: from mail-qt1-f170.google.com ([209.85.160.170]:33670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otA4A-0000W2-A1 for 58812@debbugs.gnu.org; Thu, 10 Nov 2022 11:06:13 -0500 Received: by mail-qt1-f170.google.com with SMTP id w4so1192733qts.0 for <58812@debbugs.gnu.org>; Thu, 10 Nov 2022 08:06:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=XGrPvhQ/9qGJmUplPfL27tDsvHuvx+A+Tne09I59vJU=; b=GsfOTu/Ye3sOjZh94z0ApIzOK/vLd9ZYyB+qDvKzZBLLEH+PAT1i3b7iyQIrwsnMs5 3kLP6BhLSAQgx4PSSHAmKEikf+L06CiJlWA56fWY01IE/YXCEERlvb1zZ00L4KRmnEXr Ph9M5JTJyFP42zv7xFwNrT2CmmP7R2NPVBW1kdxw4ePPfTqOKikgOpjFj7gDAjPxi9Aa q8GGPwFre0P5CHsn54dilzxOUj53IaG/4tyxb/IcUokNCVQDvLsBQhQXCXb5U7jjV9uG /ZujiMDFBDfzFBrnFwlGXKu0O0Ix9JvtuZeiJNZ6t21Jnfzl0sy2PafU08zZL6JJ9llu Ri5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=XGrPvhQ/9qGJmUplPfL27tDsvHuvx+A+Tne09I59vJU=; b=G6jzOH/rAU7VEwG09V+piLB+T0LVp9mNZ25RcxzLcKEHHBs69m0PHhiv/KSDN+HTUu Y2Ehce6KIr+nUhwr452PBBIW+QCE4tLwdPP22b9AZGyTNcNW1jUlKFBMUfABI1VXDvda o4zn9urJrA2wO4VYvC8VSYq7aFeTWgvggjFi+oJQIU6Rxb7IBXwgKe8PJvx120Qf3cVL /wMO3FY1RUOzH8TxsGSGAQ/KG2P/KIZNENDZcwpRsUki3PG6mfr0rLuajF+Dbo1STgdW 83BhOMM9ntQ7MZzamAmMkBivlnqaKAxgIcYUwT1qHgY7nc+PpkjDn2xIx9hz44T5M/7K 1Wqw== X-Gm-Message-State: ACrzQf2FvFbLC9sZt0nhQjHhJ8IcPQ57JJwowMVSTnhaIgPDCjnGZWvL lyeZ7G6rBXgnUoMyUYpqWd4k/jMA+Qs= X-Google-Smtp-Source: AMsMyM4zVKXGBGZM/wWQAFeCdh3yAy81wcN4GFDZPx6qA1jTERQtrMcmXBQnpE0MnAHDok4iyNhUyg== X-Received: by 2002:ac8:6bc8:0:b0:397:c806:2162 with SMTP id b8-20020ac86bc8000000b00397c8062162mr1347218qtt.171.1668096364599; Thu, 10 Nov 2022 08:06:04 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id t18-20020a37ea12000000b006fafc111b12sm6344916qkj.83.2022.11.10.08.06.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 08:06:04 -0800 (PST) From: Maxim Cournoyer Date: Thu, 10 Nov 2022 11:05:47 -0500 Message-Id: <20221110160550.4366-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <87sfiqhp1u.fsf@gnu.org> References: <87sfiqhp1u.fsf@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.1 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.9 (/) * Makefile.am (EXTRA_DIST): Sort. --- Makefile.am | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Makefile.am b/Makefile.am index 47886721fa..c3af23b68e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -660,49 +660,49 @@ dist_fishcompletion_DATA = etc/completion/fish/guix.fish nodist_selinux_policy_DATA = etc/guix-daemon.cil EXTRA_DIST += \ - HACKING \ - ROADMAP \ - TODO \ - CODE-OF-CONDUCT \ .dir-locals.el \ .guix-authorizations \ .guix-channel \ - scripts/guix.in \ - etc/disarchive-manifest.scm \ - etc/guix-install.sh \ - etc/news.scm \ - etc/release-manifest.scm \ - etc/source-manifest.scm \ - etc/system-tests.scm \ - etc/time-travel-manifest.scm \ - etc/historical-authorizations \ + CODE-OF-CONDUCT \ + HACKING \ + ROADMAP \ + TODO \ + bootstrap \ build-aux/build-self.scm \ - build-aux/compile-all.scm \ - build-aux/cuirass/hurd-manifest.scm \ - build-aux/check-final-inputs-self-contained.scm \ build-aux/check-channel-news.scm \ + build-aux/check-final-inputs-self-contained.scm \ + build-aux/compile-all.scm \ build-aux/compile-as-derivation.scm \ + build-aux/config.rpath \ build-aux/convert-xref.scm \ + build-aux/cuirass/hurd-manifest.scm \ build-aux/generate-authors.scm \ build-aux/test-driver.scm \ - build-aux/update-guix-package.scm \ build-aux/update-NEWS.scm \ - tests/test.drv \ + build-aux/update-guix-package.scm \ + doc/build.scm \ + etc/disarchive-manifest.scm \ + etc/guix-install.sh \ + etc/historical-authorizations \ + etc/news.scm \ + etc/release-manifest.scm \ + etc/source-manifest.scm \ + etc/system-tests.scm \ + etc/time-travel-manifest.scm \ + scripts/guix.in \ tests/cve-sample.json \ - tests/keys/signing-key.pub \ - tests/keys/signing-key.sec \ tests/keys/civodul.pub \ - tests/keys/rsa.pub \ tests/keys/dsa.pub \ - tests/keys/ed25519.pub \ - tests/keys/ed25519.sec \ tests/keys/ed25519-2.pub \ tests/keys/ed25519-2.sec \ tests/keys/ed25519-3.pub \ tests/keys/ed25519-3.sec \ - build-aux/config.rpath \ - bootstrap \ - doc/build.scm \ + tests/keys/ed25519.pub \ + tests/keys/ed25519.sec \ + tests/keys/rsa.pub \ + tests/keys/signing-key.pub \ + tests/keys/signing-key.sec \ + tests/test.drv \ $(TESTS) if !BUILD_DAEMON_OFFLOAD -- 2.37.3 From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH v3 2/4] install: Validate symlink target in evaluate-populate-directive. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 16:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16680963772033 (code B ref 58812); Thu, 10 Nov 2022 16:07:02 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 16:06:17 +0000 Received: from localhost ([127.0.0.1]:44045 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otA4H-0000Wi-BZ for submit@debbugs.gnu.org; Thu, 10 Nov 2022 11:06:17 -0500 Received: from mail-qt1-f181.google.com ([209.85.160.181]:34561) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otA4F-0000WC-Ke for 58812@debbugs.gnu.org; Thu, 10 Nov 2022 11:06:16 -0500 Received: by mail-qt1-f181.google.com with SMTP id e15so1174921qts.1 for <58812@debbugs.gnu.org>; Thu, 10 Nov 2022 08:06:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=zrkjGIBtzayhHZQrYnnG/gG6ymHR3J6x5PRzXc/KVf4=; b=ppiVJj8OjcamSEDw8VrTouNF+kWeQAzWkkdGuBuszLhux9+uPX4aVuv00hEbB+uQDp 7RoU09nD8SSGgYNpXW2H3SUQuEOFxcTkGkTHBtP9jjs4lwUrutzScGGjYuGUKUVBfoBr pqVb5PY661Gu2y9OA7LrsRviltzjQosOFTxL1eL52bsKaLBGA1CPcBVlOOz3te8a1z9x AkSMszeOp8qAtn0aqmKjOgnlCgCamDblqcUA9Y045Z3o+ZbYU8h6e24YeUbkqFp88e9y wn/zZ8sArdEsewsvt05kXhe5JGRii9fksAL9efEzmiKxzNow8YTlTGn+cHMhhvR1JBfC DKlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=zrkjGIBtzayhHZQrYnnG/gG6ymHR3J6x5PRzXc/KVf4=; b=dUu9DA/erGVzPgB0VlUfsVThCfbFT5sObQdmk78adJ4npbhLRr0y6gHXrIw7GDEUoz xci7y9xz9xPt8bD60sTXwG1xAbZAY0eYCwLGRaSrUIeVTWv5rNIXusDfd0TShutgDpNJ MwStE1iSgb/MjfClB0UNC/QEP/Zuwi5R7WtvEo4hJpSdH5yzhNJvmx1El6U5BBQ1p38B AFuHtblRyPclAatGixbMOC9GJ66O6j2AYevhiklFWm6P3Phf6kwDw7Jja5Mcz2cHoQoP vcKhGPRp3bapGgCiZHp9mWibVnGJ3HZB1kTwUC04TlPh+10d2qg+3C4TiQJUVYUYgmkj umTw== X-Gm-Message-State: ANoB5pkVjwVcFkplAdREbvlVIEGPlKB5fRGoVBy9EVRoI10xXTCY5g2S 9oaDy0ZMOJ2pMZFT+DwC1U46EzpAVKI= X-Google-Smtp-Source: AA0mqf43uru6AFvMrE0DdVpO4DVqAkfu1kQYydlnoemQPib17jc5v8xzUekZAo3BKQ2/kR0owG8tzA== X-Received: by 2002:ac8:7755:0:b0:3a5:925a:b33a with SMTP id g21-20020ac87755000000b003a5925ab33amr15592955qtu.69.1668096368522; Thu, 10 Nov 2022 08:06:08 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id t18-20020a37ea12000000b006fafc111b12sm6344916qkj.83.2022.11.10.08.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 08:06:08 -0800 (PST) From: Maxim Cournoyer Date: Thu, 10 Nov 2022 11:05:48 -0500 Message-Id: <20221110160550.4366-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221110160550.4366-1-maxim.cournoyer@gmail.com> References: <87sfiqhp1u.fsf@gnu.org> <20221110160550.4366-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/build/install.scm (evaluate-populate-directive): By default, error when the target of a symlink doesn't exist. Always ensure TARGET ends with "/". (populate-root-file-system): Call evaluate-populate-directive with #:error-on-dangling-symlink #t and add comment. --- gnu/build/install.scm | 60 ++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/gnu/build/install.scm b/gnu/build/install.scm index f5c8407b89..33a9616c0d 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2016 Chris Marusich +;;; Copyright © 2022 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -56,19 +57,24 @@ (define (install-boot-config bootcfg bootcfg-location mount-point) (define* (evaluate-populate-directive directive target #:key (default-gid 0) - (default-uid 0)) + (default-uid 0) + (error-on-dangling-symlink? #t)) "Evaluate DIRECTIVE, an sexp describing a file or directory to create under directory TARGET. DEFAULT-UID and DEFAULT-GID are the default UID and GID in the context of the caller. If the directive matches those defaults then, -'chown' won't be run." +'chown' won't be run. When ERROR-ON-DANGLING-SYMLINK? is true, abort with an +error when a dangling symlink would be created." + (define target* (if (string-suffix? "/" target) + target + (string-append target "/"))) (let loop ((directive directive)) (catch 'system-error (lambda () (match directive (('directory name) - (mkdir-p (string-append target name))) + (mkdir-p (string-append target* name))) (('directory name uid gid) - (let ((dir (string-append target name))) + (let ((dir (string-append target* name))) (mkdir-p dir) ;; If called from a context without "root" permissions, "chown" ;; to root will fail. In that case, do not try to run "chown" @@ -78,27 +84,38 @@ (define* (evaluate-populate-directive directive target (chown dir uid gid)))) (('directory name uid gid mode) (loop `(directory ,name ,uid ,gid)) - (chmod (string-append target name) mode)) + (chmod (string-append target* name) mode)) (('file name) - (call-with-output-file (string-append target name) + (call-with-output-file (string-append target* name) (const #t))) (('file name (? string? content)) - (call-with-output-file (string-append target name) + (call-with-output-file (string-append target* name) (lambda (port) (display content port)))) ((new '-> old) - (let try () - (catch 'system-error - (lambda () - (symlink old (string-append target new))) - (lambda args - ;; When doing 'guix system init' on the current '/', some - ;; symlinks may already exists. Override them. - (if (= EEXIST (system-error-errno args)) - (begin - (delete-file (string-append target new)) - (try)) - (apply throw args)))))))) + (let ((new* (string-append target* new))) + (let try () + (catch 'system-error + (lambda () + (when error-on-dangling-symlink? + ;; When the symbolic link points to a relative path, + ;; checking if its target exists must be done relatively + ;; to the link location. + (unless (if (string-prefix? "/" old) + (file-exists? old) + (with-directory-excursion (dirname new*) + (file-exists? old))) + (error (format #f "symlink `~a' points to nonexistent \ +file `~a'" new* old)))) + (symlink old new*)) + (lambda args + ;; When doing 'guix system init' on the current '/', some + ;; symlinks may already exists. Override them. + (if (= EEXIST (system-error-errno args)) + (begin + (delete-file new*) + (try)) + (apply throw args))))))))) (lambda args ;; Usually we can only get here when installing to an existing root, ;; as with 'guix system init foo.scm /'. @@ -142,7 +159,10 @@ (define* (populate-root-file-system system target includes /etc, /var, /run, /bin/sh, etc., and all the symlinks to SYSTEM. EXTRAS is a list of directives appended to the built-in directives to populate TARGET." - (for-each (cut evaluate-populate-directive <> target) + ;; It's expected that some symbolic link targets do not exist yet, so do not + ;; error on dangling links. + (for-each (cut evaluate-populate-directive <> target + #:error-on-dangling-symlink? #f) (append (directives (%store-directory)) extras)) ;; Add system generation 1. -- 2.37.3 From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH v3 3/4] guix: shell: Add '--symlink' option. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 16:07:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16680963822052 (code B ref 58812); Thu, 10 Nov 2022 16:07:03 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 16:06:22 +0000 Received: from localhost ([127.0.0.1]:44048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otA4K-0000X0-RC for submit@debbugs.gnu.org; Thu, 10 Nov 2022 11:06:21 -0500 Received: from mail-qt1-f173.google.com ([209.85.160.173]:36720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otA4H-0000WI-0v for 58812@debbugs.gnu.org; Thu, 10 Nov 2022 11:06:17 -0500 Received: by mail-qt1-f173.google.com with SMTP id fz10so1168976qtb.3 for <58812@debbugs.gnu.org>; Thu, 10 Nov 2022 08:06:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=XlMVXdyLxHvxImaTRx/NY5OoFVEnXKMdxvcqdMhajjA=; b=k1GIz/AnK2ytx4YLVMqLPptW6O18W1+FW+Xzkr+m1Z+6r3IgM8Ak9U9fO6fH+4mf1u pKjcgg7Xw/764I70hIywx3tCyTkBcCyi8lVuHHhif31glSBbIeY0siXRO5S97QvI0EcH WnqTOieZtbs6pupU30r+W6rCnQXn1sXtsLnl/UYqzIMDC366DNkBwmVALtmg7gzpTWL5 9bKt2f1h+7ekqhQK/ogzSOdVyqVGwoeVMJZ+qDHwrRrUtlqw5xxtJIePRpLLBCRBJvdG XQcM7UD/YHiIpzZAFqH9PiMTDjmNMpz1jOGEFhcrfmSUZdaP8v1tJTmGwjjjfYjwYY1p bmHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=XlMVXdyLxHvxImaTRx/NY5OoFVEnXKMdxvcqdMhajjA=; b=X3YQExuWOPyhs15hSdG136eiE7v33j5NABWb32RrhoY5nmzI97q0aE15HA+2qGA9PD JDD6r26BlyIzDfVuDLPbAi8Hpje+UUvZvUz37KRfaWKNTMfmqZPwKsVxTNGLIazou2Ij qhgs2Be1pfylzV/iY57Y5DTCQvNz7RoxmIBDu+m2l3wlN0nsWpIUvCSu6pc6Fi7ZhYnD q2RH3FGYb+GAsv/ENgzjLV1x6gGAaa1KS2PJpS1d/PLBSb7Q5Eogn8lC4lPbgAK1N8Cu yVXaqr5ELljllb/mJmkRmYo1WCvHbVzvysgvWQUPqZ/MPX1pQepW0h8B+ecCNwAynS5C 776g== X-Gm-Message-State: ACrzQf0mm/sxKng5wJFPhR+GAJ3m4IpthmwaYNk9+b8g8WgWVMyTn4ss CT6+jLhor4kcfHEWnXDif21XFaeDEpY= X-Google-Smtp-Source: AMsMyM4UULa5p8A/fFiXxpQ8Sux1L1yw76OwcKnjNHs2AWzeJaskx0mm7dTFr/GRcmO0LS4HfYPwMQ== X-Received: by 2002:a05:622a:138a:b0:39c:e18e:758f with SMTP id o10-20020a05622a138a00b0039ce18e758fmr1371947qtk.187.1668096371231; Thu, 10 Nov 2022 08:06:11 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id t18-20020a37ea12000000b006fafc111b12sm6344916qkj.83.2022.11.10.08.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 08:06:10 -0800 (PST) From: Maxim Cournoyer Date: Thu, 10 Nov 2022 11:05:49 -0500 Message-Id: <20221110160550.4366-3-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221110160550.4366-1-maxim.cournoyer@gmail.com> References: <87sfiqhp1u.fsf@gnu.org> <20221110160550.4366-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/scripts/pack.scm (%options): Extract symlink parsing logic to... (symlink-spec-option-parser): ... here. (self-contained-tarball/builder): Add a comment mentioning why a relative file name is used for the link target. * guix/scripts/environment.scm (show-environment-options-help): Document new --symlink option. (%default-options): Add default value for symlinks. (%options): Register new symlink option. (launch-environment/container): Add #:symlinks argument and extend doc, and create symlinks using evaluate-populate-directive. (guix-environment*): Pass symlinks arguments to launch-environment/container. * doc/guix.texi (Invoking guix shell): Document it. * tests/guix-shell.sh: Add a --symlink (negative) test. * tests/guix-environment-container.sh: Add tests. --- doc/guix.texi | 9 +++++- guix/scripts/environment.scm | 43 ++++++++++++++++++++++------- guix/scripts/pack.scm | 39 ++++++++++++++------------ tests/guix-environment-container.sh | 9 ++++++ tests/guix-shell.sh | 3 ++ 5 files changed, 75 insertions(+), 28 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 3f76184495..94c3f29790 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -49,7 +49,7 @@ Copyright @copyright{} 2017 humanitiesNerd@* Copyright @copyright{} 2017, 2021 Christine Lemmer-Webber@* Copyright @copyright{} 2017, 2018, 2019, 2020, 2021, 2022 Marius Bakke@* Copyright @copyright{} 2017, 2019, 2020, 2022 Hartmut Goebel@* -Copyright @copyright{} 2017, 2019, 2020, 2021 Maxim Cournoyer@* +Copyright @copyright{} 2017, 2019, 2020, 2021, 2022 Maxim Cournoyer@* Copyright @copyright{} 2017–2022 Tobias Geerinckx-Rice@* Copyright @copyright{} 2017 George Clemmer@* Copyright @copyright{} 2017 Andy Wingo@* @@ -6242,6 +6242,12 @@ directory: guix shell --container --expose=$HOME=/exchange guile -- guile @end example +@cindex symbolic links, guix shell +@item --symlink=@var{spec} +@itemx -S @var{spec} +For containers, create the symbolic links specified by @var{spec}, as +documented in @ref{pack-symlink-option}. + @cindex file system hierarchy standard (FHS) @cindex FHS (file system hierarchy standard) @item --emulate-fhs @@ -7034,6 +7040,7 @@ Compress the resulting tarball using @var{tool}---one of @code{gzip}, @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression. +@anchor{pack-symlink-option} @item --symlink=@var{spec} @itemx -S @var{spec} Add the symlinks specified by @var{spec} to the pack. This option can diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index de9bc8f98d..13c6f6cb5c 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -33,8 +33,10 @@ (define-module (guix scripts environment) #:use-module ((guix gexp) #:select (lower-object)) #:use-module (guix scripts) #:use-module (guix scripts build) + #:autoload (guix scripts pack) (symlink-spec-option-parser) #:use-module (guix transformations) #:autoload (ice-9 ftw) (scandir) + #:use-module (gnu build install) #:autoload (gnu build linux-container) (call-with-container %namespaces user-namespace-supported? unprivileged-user-namespace-supported? @@ -120,6 +122,9 @@ (define (show-environment-options-help) --expose=SPEC for containers, expose read-only host file system according to SPEC")) (display (G_ " + -S, --symlink=SPEC for containers, add symlinks to the profile according + to SPEC, e.g. \"/usr/bin/env=bin/env\".")) + (display (G_ " -v, --verbosity=LEVEL use the given verbosity LEVEL")) (display (G_ " --bootstrap use bootstrap binaries to build the environment"))) @@ -157,6 +162,7 @@ (define (show-help) (define %default-options `((system . ,(%current-system)) (substitutes? . #t) + (symlinks . ()) (offload? . #t) (graft? . #t) (print-build-trace? . #t) @@ -256,6 +262,7 @@ (define %options (alist-cons 'file-system-mapping (specification->file-system-mapping arg #f) result))) + (option '(#\S "symlink") #t #f symlink-spec-option-parser) (option '(#\r "root") #t #f (lambda (opt name arg result) (alist-cons 'gc-root arg result))) @@ -672,7 +679,7 @@ (define* (launch-environment/fork command profile manifest (define* (launch-environment/container #:key command bash user user-mappings profile manifest link-profile? network? map-cwd? emulate-fhs? (setup-hook #f) - (white-list '())) + (symlinks '()) (white-list '())) "Run COMMAND within a container that features the software in PROFILE. Environment variables are set according to the search paths of MANIFEST. The global shell is BASH, a file name for a GNU Bash binary in the store. When @@ -690,6 +697,9 @@ (define* (launch-environment/container #:key command bash user user-mappings LINK-PROFILE? creates a symbolic link from ~/.guix-profile to the environment profile. +SYMLINKS must be a list of (SOURCE -> TARGET) tuples denoting symlinks to be +added to the container. + Preserve environment variables whose name matches the one of the regexps in WHILE-LIST." (define (optional-mapping->fs mapping) @@ -797,6 +807,15 @@ (define fhs-mappings (mkdir-p home-dir) (setenv "HOME" home-dir) + ;; Create symlinks. + (let ((symlink->directives + (match-lambda + ((source '-> target) + `((directory ,(dirname source)) + (,source -> ,(string-append profile "/" target))))))) + (for-each (cut evaluate-populate-directive <> ".") + (append-map symlink->directives symlinks))) + ;; Call an additional setup procedure, if provided. (when setup-hook (setup-hook profile)) @@ -970,6 +989,7 @@ (define (guix-environment* opts) (let* ((pure? (assoc-ref opts 'pure)) (container? (assoc-ref opts 'container?)) (link-prof? (assoc-ref opts 'link-profile?)) + (symlinks (assoc-ref opts 'symlinks)) (network? (assoc-ref opts 'network?)) (no-cwd? (assoc-ref opts 'no-cwd?)) (emulate-fhs? (assoc-ref opts 'emulate-fhs?)) @@ -1010,15 +1030,17 @@ (define-syntax-rule (with-store/maybe store exp ...) (when container? (assert-container-features)) - (when (and (not container?) link-prof?) - (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) - (when (and (not container?) user) - (leave (G_ "'--user' cannot be used without '--container'~%"))) - (when (and (not container?) no-cwd?) - (leave (G_ "--no-cwd cannot be used without '--container'~%"))) - (when (and (not container?) emulate-fhs?) - (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) - + (when (not container?) + (when link-prof? + (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) + (when user + (leave (G_ "'--user' cannot be used without '--container'~%"))) + (when no-cwd? + (leave (G_ "--no-cwd cannot be used without '--container'~%"))) + (when emulate-fhs? + (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) + (when (pair? symlinks) + (leave (G_ "'--symlink' cannot be used without '--container~%'")))) (with-store/maybe store (with-status-verbosity (assoc-ref opts 'verbosity) @@ -1099,6 +1121,7 @@ (define manifest #:network? network? #:map-cwd? (not no-cwd?) #:emulate-fhs? emulate-fhs? + #:symlinks symlinks #:setup-hook (and emulate-fhs? setup-fhs)))) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 06849e4761..a611922db3 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -61,7 +61,9 @@ (define-module (guix scripts pack) #:use-module (srfi srfi-26) #:use-module (srfi srfi-37) #:use-module (ice-9 match) - #:export (self-contained-tarball + #:export (symlink-spec-option-parser + + self-contained-tarball debian-archive docker-image squashfs-image @@ -160,6 +162,21 @@ (define str (string-join names "-")) ((_) str) ((names ... _) (loop names)))))) +(define (symlink-spec-option-parser opt name arg result) + "A SRFI-37 option parser for the --symlink option." + ;; Note: Using 'string-split' allows us to handle empty + ;; TARGET (as in "/opt/guile=", meaning that /opt/guile is + ;; a symlink to the profile) correctly. + (match (string-split arg (char-set #\=)) + ((source target) + (let ((symlinks (assoc-ref result 'symlinks))) + (alist-cons 'symlinks + `((,source -> ,target) ,@symlinks) + (alist-delete 'symlinks result eq?)))) + (x + (leave (G_ "~a: invalid symlink specification~%") + arg)))) + ;;; ;;; Tarball format. @@ -226,8 +243,9 @@ (define symlink->directives `(,@(if (string=? parent "/") '() `((directory ,parent))) - (,source - -> ,(relative-file-name parent target))))))) + ;; Use a relative file name for compatibility with + ;; relocatable packs. + (,source -> ,(relative-file-name parent target))))))) (define directives ;; Fully-qualified symlinks. @@ -1208,20 +1226,7 @@ (define %options (lambda (opt name arg result) (alist-cons 'compressor (lookup-compressor arg) result))) - (option '(#\S "symlink") #t #f - (lambda (opt name arg result) - ;; Note: Using 'string-split' allows us to handle empty - ;; TARGET (as in "/opt/guile=", meaning that /opt/guile is - ;; a symlink to the profile) correctly. - (match (string-split arg (char-set #\=)) - ((source target) - (let ((symlinks (assoc-ref result 'symlinks))) - (alist-cons 'symlinks - `((,source -> ,target) ,@symlinks) - (alist-delete 'symlinks result eq?)))) - (x - (leave (G_ "~a: invalid symlink specification~%") - arg))))) + (option '(#\S "symlink") #t #f symlink-spec-option-parser) (option '("save-provenance") #f #f (lambda (opt name arg result) (alist-cons 'save-provenance? #t result))) diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index fb2c19b193..82192375c7 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -241,3 +241,12 @@ guix shell -CF --bootstrap guile-bootstrap glibc \ "glibc-for-fhs") 0 1))' + +# '--symlink' works. +echo "TESTING SYMLINK IN CONTAINER" +guix shell --bootstrap guile-bootstrap --container \ + --symlink=/usr/bin/guile=bin/guile -- \ + /usr/bin/guile --version + +# A dangling symlink causes the command to fail. +! guix shell --bootstrap -CS /usr/bin/python=bin/python guile-bootstrap -- exit diff --git a/tests/guix-shell.sh b/tests/guix-shell.sh index 9a6b055264..cb2b53466d 100644 --- a/tests/guix-shell.sh +++ b/tests/guix-shell.sh @@ -32,6 +32,9 @@ export XDG_CONFIG_HOME guix shell --bootstrap --pure guile-bootstrap -- guile --version +# '--symlink' can only be used with --container. +! guix shell --bootstrap guile-bootstrap -S /dummy=bin/guile + # '--ad-hoc' is a thing of the past. ! guix shell --ad-hoc guile-bootstrap -- 2.37.3 From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH v3 4/4] shell: Detect --symlink spec problems early. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Nov 2022 16:07:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16680963852069 (code B ref 58812); Thu, 10 Nov 2022 16:07:03 +0000 Received: (at 58812) by debbugs.gnu.org; 10 Nov 2022 16:06:25 +0000 Received: from localhost ([127.0.0.1]:44050 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otA4O-0000XI-27 for submit@debbugs.gnu.org; Thu, 10 Nov 2022 11:06:25 -0500 Received: from mail-qt1-f178.google.com ([209.85.160.178]:34567) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otA4K-0000Wb-KR for 58812@debbugs.gnu.org; Thu, 10 Nov 2022 11:06:22 -0500 Received: by mail-qt1-f178.google.com with SMTP id e15so1175120qts.1 for <58812@debbugs.gnu.org>; Thu, 10 Nov 2022 08:06:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=amwygdAfcIWzrVj5Rglf6tQ3uRSbDoPtHhmeDYo2uP8=; b=WIfeiiMIrEGPmQCYZUrdGQACWeXco1QR9uGGtYUoNned3DKU8p5Liy1GvtCugbr9wo oXULeObz6fpZvAfCeHBnbRRB3dBfw0IUUuhqbW0edUvgEJJ26LYYucAA8X9gX+XToVPA 3mS7LRwZaZxcJm53bRuXu7ikS0RrdF3h/3p5BXB6tx4KPr6F2E/lnXmorhY6qUCT4whP h/jfVtxIlgOc3z6QqHq9Po22jfgMLFZcpGG5k0COApY/ZsZbFBEDD4A9F5m9PvSI6Oh+ ou8iPqt6AkDvqm24rpCqinIc3H1MJoN6lgQTw5ghEB5BXLlGGHK8dI6Ag7tCK7wiWFve 781Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=amwygdAfcIWzrVj5Rglf6tQ3uRSbDoPtHhmeDYo2uP8=; b=MFboyFhxZv9tEvB5ZI4VHqd+Pzhd68WaVRbVEyDMlHmKngL8CwfcTHZkD7Sx7XLxJg MIWcr1kMNzGNHPNvKSJuNcZHaP6B20W1pRXvRqPmlvT1IWsgMoylwVOoeTg7n+oLaJ79 v42vRRJ4BqcpZ5uEnpNObgggbAXR80eKy/Fq+N21GuYiQTeJjNh5Dj5T02Q542Y/LUlX 0XG7FK67N9Oarm3TJFkUldHrdraUQ9CrqY+xhZygrbKa/kmvxfJ4tC/eiqHNiZr+8Dd6 wDt2MfmRIREJbm3UCtqtCoYfAhN15+SK55zYoFm6YiNyV5uvOy9q2fgUQKtX924qiiOL z6rA== X-Gm-Message-State: ANoB5pnQlcI4CL1dcoAtg8M+/eabvbFrvFPrFmgIE3ZJEdQYiwAP4wKW 10Y93UOtZUGSaxnW12obxetSxy+/KJI= X-Google-Smtp-Source: AA0mqf58Vr9tbw62gI5pXOAhV9OT38RVWP7Ri3NVQWW6nJS+Slg7m9rb8M6wqAOagNPE58N2DfbcJw== X-Received: by 2002:a05:622a:6107:b0:3a5:9062:1f91 with SMTP id hg7-20020a05622a610700b003a590621f91mr16462261qtb.332.1668096374318; Thu, 10 Nov 2022 08:06:14 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id t18-20020a37ea12000000b006fafc111b12sm6344916qkj.83.2022.11.10.08.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 08:06:13 -0800 (PST) From: Maxim Cournoyer Date: Thu, 10 Nov 2022 11:05:50 -0500 Message-Id: <20221110160550.4366-4-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221110160550.4366-1-maxim.cournoyer@gmail.com> References: <87sfiqhp1u.fsf@gnu.org> <20221110160550.4366-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/scripts/pack.scm (symlink-spec-option-parser): Remove extraneous char-set. Raise an exception when the target is an absolute file name. (guix-pack): Move with-error-handler earlier. * guix/scripts/shell.scm (guix-shell): Likewise. * guix/scripts/environment.scm (guix-environment): Wrap the whole guix-environment* call with the with-error-handling handler. * tests/guix-environment-container.sh: Add tests. * tests/guix-pack.sh: Adjust symlink spec. --- guix/scripts/environment.scm | 294 ++++++++++++++-------------- guix/scripts/pack.scm | 155 ++++++++------- guix/scripts/shell.scm | 77 ++++---- tests/guix-environment-container.sh | 3 + tests/guix-pack.sh | 2 +- 5 files changed, 276 insertions(+), 255 deletions(-) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 13c6f6cb5c..64597f6e9f 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -980,158 +980,158 @@ (define-command (guix-environment . args) (category development) (synopsis "spawn one-off software environments (deprecated)") - (guix-environment* (parse-args args))) + (with-error-handling + (guix-environment* (parse-args args)))) (define (guix-environment* opts) "Run the 'guix environment' command on OPTS, an alist resulting for command-line option processing with 'parse-command-line'." - (with-error-handling - (let* ((pure? (assoc-ref opts 'pure)) - (container? (assoc-ref opts 'container?)) - (link-prof? (assoc-ref opts 'link-profile?)) - (symlinks (assoc-ref opts 'symlinks)) - (network? (assoc-ref opts 'network?)) - (no-cwd? (assoc-ref opts 'no-cwd?)) - (emulate-fhs? (assoc-ref opts 'emulate-fhs?)) - (user (assoc-ref opts 'user)) - (bootstrap? (assoc-ref opts 'bootstrap?)) - (system (assoc-ref opts 'system)) - (profile (assoc-ref opts 'profile)) - (command (or (assoc-ref opts 'exec) - ;; Spawn a shell if the user didn't specify - ;; anything in particular. - (if container? - ;; The user's shell is likely not available - ;; within the container. - '("/bin/sh") - (list %default-shell)))) - (mappings (pick-all opts 'file-system-mapping)) - (white-list (pick-all opts 'inherit-regexp))) - - (define store-needed? - ;; Whether connecting to the daemon is needed. - (or container? (not profile))) - - (define-syntax-rule (with-store/maybe store exp ...) - ;; Evaluate EXP... with STORE bound to a connection, unless - ;; STORE-NEEDED? is false, in which case STORE is bound to #f. - (let ((proc (lambda (store) exp ...))) - (if store-needed? - (with-store s - (set-build-options-from-command-line s opts) - (with-build-handler (build-notifier #:use-substitutes? - (assoc-ref opts 'substitutes?) - #:verbosity - (assoc-ref opts 'verbosity) - #:dry-run? - (assoc-ref opts 'dry-run?)) - (proc s))) - (proc #f)))) - - (when container? (assert-container-features)) - - (when (not container?) - (when link-prof? - (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) - (when user - (leave (G_ "'--user' cannot be used without '--container'~%"))) - (when no-cwd? - (leave (G_ "--no-cwd cannot be used without '--container'~%"))) - (when emulate-fhs? - (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) - (when (pair? symlinks) - (leave (G_ "'--symlink' cannot be used without '--container~%'")))) - - (with-store/maybe store - (with-status-verbosity (assoc-ref opts 'verbosity) - (define manifest-from-opts - (options/resolve-packages store opts)) - - (define manifest - (if profile - (profile-manifest profile) - manifest-from-opts)) - - (when (and profile - (> (length (manifest-entries manifest-from-opts)) 0)) - (leave (G_ "'--profile' cannot be used with package options~%"))) - - (when (null? (manifest-entries manifest)) - (warning (G_ "no packages specified; creating an empty environment~%"))) - - ;; Use the bootstrap Guile when requested. - (parameterize ((%graft? (assoc-ref opts 'graft?)) - (%guile-for-build - (and store-needed? - (package-derivation - store - (if bootstrap? - %bootstrap-guile - (default-guile)))))) - (run-with-store store - ;; Containers need a Bourne shell at /bin/sh. - (mlet* %store-monad ((bash (environment-bash container? - bootstrap? - system)) - (prof-drv (if profile - (return #f) - (manifest->derivation - manifest system bootstrap?))) - (profile -> (if profile - (readlink* profile) - (derivation->output-path prof-drv))) - (gc-root -> (assoc-ref opts 'gc-root))) - - ;; First build the inputs. This is necessary even for - ;; --search-paths. Additionally, we might need to build bash for - ;; a container. - (mbegin %store-monad - (mwhen store-needed? - (built-derivations (append - (if prof-drv (list prof-drv) '()) - (if (derivation? bash) (list bash) '())))) - (mwhen gc-root - (register-gc-root profile gc-root)) - - (mwhen (assoc-ref opts 'check?) - (return - (if container? - (warning (G_ "'--check' is unnecessary \ + (let* ((pure? (assoc-ref opts 'pure)) + (container? (assoc-ref opts 'container?)) + (link-prof? (assoc-ref opts 'link-profile?)) + (symlinks (assoc-ref opts 'symlinks)) + (network? (assoc-ref opts 'network?)) + (no-cwd? (assoc-ref opts 'no-cwd?)) + (emulate-fhs? (assoc-ref opts 'emulate-fhs?)) + (user (assoc-ref opts 'user)) + (bootstrap? (assoc-ref opts 'bootstrap?)) + (system (assoc-ref opts 'system)) + (profile (assoc-ref opts 'profile)) + (command (or (assoc-ref opts 'exec) + ;; Spawn a shell if the user didn't specify + ;; anything in particular. + (if container? + ;; The user's shell is likely not available + ;; within the container. + '("/bin/sh") + (list %default-shell)))) + (mappings (pick-all opts 'file-system-mapping)) + (white-list (pick-all opts 'inherit-regexp))) + + (define store-needed? + ;; Whether connecting to the daemon is needed. + (or container? (not profile))) + + (define-syntax-rule (with-store/maybe store exp ...) + ;; Evaluate EXP... with STORE bound to a connection, unless + ;; STORE-NEEDED? is false, in which case STORE is bound to #f. + (let ((proc (lambda (store) exp ...))) + (if store-needed? + (with-store s + (set-build-options-from-command-line s opts) + (with-build-handler (build-notifier #:use-substitutes? + (assoc-ref opts 'substitutes?) + #:verbosity + (assoc-ref opts 'verbosity) + #:dry-run? + (assoc-ref opts 'dry-run?)) + (proc s))) + (proc #f)))) + + (when container? (assert-container-features)) + + (when (not container?) + (when link-prof? + (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) + (when user + (leave (G_ "'--user' cannot be used without '--container'~%"))) + (when no-cwd? + (leave (G_ "--no-cwd cannot be used without '--container'~%"))) + (when emulate-fhs? + (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) + (when (pair? symlinks) + (leave (G_ "'--symlink' cannot be used without '--container~%'")))) + + (with-store/maybe store + (with-status-verbosity (assoc-ref opts 'verbosity) + (define manifest-from-opts + (options/resolve-packages store opts)) + + (define manifest + (if profile + (profile-manifest profile) + manifest-from-opts)) + + (when (and profile + (> (length (manifest-entries manifest-from-opts)) 0)) + (leave (G_ "'--profile' cannot be used with package options~%"))) + + (when (null? (manifest-entries manifest)) + (warning (G_ "no packages specified; creating an empty environment~%"))) + + ;; Use the bootstrap Guile when requested. + (parameterize ((%graft? (assoc-ref opts 'graft?)) + (%guile-for-build + (and store-needed? + (package-derivation + store + (if bootstrap? + %bootstrap-guile + (default-guile)))))) + (run-with-store store + ;; Containers need a Bourne shell at /bin/sh. + (mlet* %store-monad ((bash (environment-bash container? + bootstrap? + system)) + (prof-drv (if profile + (return #f) + (manifest->derivation + manifest system bootstrap?))) + (profile -> (if profile + (readlink* profile) + (derivation->output-path prof-drv))) + (gc-root -> (assoc-ref opts 'gc-root))) + + ;; First build the inputs. This is necessary even for + ;; --search-paths. Additionally, we might need to build bash for + ;; a container. + (mbegin %store-monad + (mwhen store-needed? + (built-derivations (append + (if prof-drv (list prof-drv) '()) + (if (derivation? bash) (list bash) '())))) + (mwhen gc-root + (register-gc-root profile gc-root)) + + (mwhen (assoc-ref opts 'check?) + (return + (if container? + (warning (G_ "'--check' is unnecessary \ when using '--container'; doing nothing~%")) - (validate-child-shell-environment profile manifest)))) - - (cond - ((assoc-ref opts 'search-paths) - (show-search-paths profile manifest #:pure? pure?) - (return #t)) - (container? - (let ((bash-binary - (if bootstrap? - (derivation->output-path bash) - (string-append (derivation->output-path bash) - "/bin/sh")))) - (launch-environment/container #:command command - #:bash bash-binary - #:user user - #:user-mappings mappings - #:profile profile - #:manifest manifest - #:white-list white-list - #:link-profile? link-prof? - #:network? network? - #:map-cwd? (not no-cwd?) - #:emulate-fhs? emulate-fhs? - #:symlinks symlinks - #:setup-hook - (and emulate-fhs? - setup-fhs)))) - - (else - (return - (exit/status - (launch-environment/fork command profile manifest - #:white-list white-list - #:pure? pure?)))))))))))))) + (validate-child-shell-environment profile manifest)))) + + (cond + ((assoc-ref opts 'search-paths) + (show-search-paths profile manifest #:pure? pure?) + (return #t)) + (container? + (let ((bash-binary + (if bootstrap? + (derivation->output-path bash) + (string-append (derivation->output-path bash) + "/bin/sh")))) + (launch-environment/container #:command command + #:bash bash-binary + #:user user + #:user-mappings mappings + #:profile profile + #:manifest manifest + #:white-list white-list + #:link-profile? link-prof? + #:network? network? + #:map-cwd? (not no-cwd?) + #:emulate-fhs? emulate-fhs? + #:symlinks symlinks + #:setup-hook + (and emulate-fhs? + setup-fhs)))) + + (else + (return + (exit/status + (launch-environment/fork command profile manifest + #:white-list white-list + #:pure? pure?))))))))))))) ;;; Local Variables: ;;; eval: (put 'with-store/maybe 'scheme-indent-function 1) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index a611922db3..f81b3e6501 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -42,6 +42,7 @@ (define-module (guix scripts pack) #:use-module (guix profiles) #:use-module (guix describe) #:use-module (guix derivations) + #:use-module (guix diagnostics) #:use-module (guix search-paths) #:use-module (guix build-system gnu) #:use-module (guix scripts build) @@ -59,6 +60,7 @@ (define-module (guix scripts pack) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-35) #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:export (symlink-spec-option-parser @@ -163,12 +165,27 @@ (define str (string-join names "-")) ((names ... _) (loop names)))))) (define (symlink-spec-option-parser opt name arg result) - "A SRFI-37 option parser for the --symlink option." + "A SRFI-37 option parser for the --symlink option. The symlink spec accepts +the link file name as its left-hand side value and its target as its +right-hand side value. The target must be a relative link." ;; Note: Using 'string-split' allows us to handle empty ;; TARGET (as in "/opt/guile=", meaning that /opt/guile is ;; a symlink to the profile) correctly. - (match (string-split arg (char-set #\=)) + (match (string-split arg #\=) ((source target) + (when (string-prefix? "/" target) + (raise-exception + (make-compound-condition + (formatted-message (G_ "symlink target is absolute: '~a'~%") target) + (condition + (&fix-hint (hint (format #f (G_ "The target of the symlink must be +relative rather than absolute, as it is relative to the profile created. +Perhaps the source and target components of the symlink spec were inverted? +Below is a valid example, where the @file{/usr/bin/env} symbolic link is to +target the profile's @file{bin/env} file: +@example +--symlink=/usr/bin/env=bin/env +@end example")))))))) (let ((symlinks (assoc-ref result 'symlinks))) (alist-cons 'symlinks `((,source -> ,target) ,@symlinks) @@ -1326,74 +1343,74 @@ (define-command (guix-pack . args) (category development) (synopsis "create application bundles") - (define opts - (parse-command-line args %options (list %default-options))) - - (define maybe-package-argument - ;; Given an option pair, return a package, a package/output tuple, or #f. - (match-lambda - (('argument . spec) - (call-with-values - (lambda () - (specification->package+output spec)) - list)) - (('expression . exp) - (read/eval-package-expression exp)) - (x #f))) - - (define (manifest-from-args store opts) - (let* ((transform (options->transformation opts)) - (packages (map (match-lambda - (((? package? package) output) - (list (transform package) output)) - ((? package? package) - (list (transform package) "out"))) - (reverse - (filter-map maybe-package-argument opts)))) - (manifests (filter-map (match-lambda - (('manifest . file) file) - (_ #f)) - opts))) - (define with-provenance - (if (assoc-ref opts 'save-provenance?) - (lambda (manifest) - (map-manifest-entries - (lambda (entry) - (let ((entry (manifest-entry-with-provenance entry))) - (unless (assq 'provenance (manifest-entry-properties entry)) - (warning (G_ "could not determine provenance of package ~a~%") - (manifest-entry-name entry))) - entry)) - manifest)) - identity)) - - (with-provenance - (cond - ((and (not (null? manifests)) (not (null? packages))) - (leave (G_ "both a manifest and a package list were given~%"))) - ((not (null? manifests)) - (concatenate-manifests - (map (lambda (file) - (let ((user-module (make-user-module - '((guix profiles) (gnu))))) - (load* file user-module))) - manifests))) - (else - (packages->manifest packages)))))) - - (define (process-file-arg opts name) - ;; Validate that the file exists and return it as a object, - ;; else #f. - (let ((value (assoc-ref opts name))) - (match value - ((and (? string?) (not (? file-exists?))) - (leave (G_ "file provided with option ~a does not exist: ~a~%") - (string-append "--" (symbol->string name)) value)) - ((? string?) - (local-file value)) - (#f #f)))) - (with-error-handling + (define opts + (parse-command-line args %options (list %default-options))) + + (define maybe-package-argument + ;; Given an option pair, return a package, a package/output tuple, or #f. + (match-lambda + (('argument . spec) + (call-with-values + (lambda () + (specification->package+output spec)) + list)) + (('expression . exp) + (read/eval-package-expression exp)) + (x #f))) + + (define (manifest-from-args store opts) + (let* ((transform (options->transformation opts)) + (packages (map (match-lambda + (((? package? package) output) + (list (transform package) output)) + ((? package? package) + (list (transform package) "out"))) + (reverse + (filter-map maybe-package-argument opts)))) + (manifests (filter-map (match-lambda + (('manifest . file) file) + (_ #f)) + opts))) + (define with-provenance + (if (assoc-ref opts 'save-provenance?) + (lambda (manifest) + (map-manifest-entries + (lambda (entry) + (let ((entry (manifest-entry-with-provenance entry))) + (unless (assq 'provenance (manifest-entry-properties entry)) + (warning (G_ "could not determine provenance of package ~a~%") + (manifest-entry-name entry))) + entry)) + manifest)) + identity)) + + (with-provenance + (cond + ((and (not (null? manifests)) (not (null? packages))) + (leave (G_ "both a manifest and a package list were given~%"))) + ((not (null? manifests)) + (concatenate-manifests + (map (lambda (file) + (let ((user-module (make-user-module + '((guix profiles) (gnu))))) + (load* file user-module))) + manifests))) + (else + (packages->manifest packages)))))) + + (define (process-file-arg opts name) + ;; Validate that the file exists and return it as a object, + ;; else #f. + (let ((value (assoc-ref opts name))) + (match value + ((and (? string?) (not (? file-exists?))) + (leave (G_ "file provided with option ~a does not exist: ~a~%") + (string-append "--" (symbol->string name)) value)) + ((? string?) + (local-file value)) + (#f #f)))) + (with-store store (with-status-verbosity (assoc-ref opts 'verbosity) ;; Set the build options before we do anything else. diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm index 7a379122ae..2fc1dc942a 100644 --- a/guix/scripts/shell.scm +++ b/guix/scripts/shell.scm @@ -534,43 +534,44 @@ (define-command (guix-shell . args) (category development) (synopsis "spawn one-off software environments") - (define (cache-entries directory) - (filter-map (match-lambda - ((or "." "..") #f) - (file (string-append directory "/" file))) - (or (scandir directory) '()))) - - (define* (entry-expiration file) - ;; Return the time at which FILE, a cached profile, is considered expired. - (match (false-if-exception (lstat file)) - (#f 0) ;FILE may have been deleted in the meantime - (st (+ (stat:atime st) (* 60 60 24 7))))) - - (define opts - (parse-args args)) - - (define interactive? - (not (assoc-ref opts 'exec))) - - (if (assoc-ref opts 'check?) - (record-hint 'shell-check) - (when (and interactive? - (not (hint-given? 'shell-check)) - (not (assoc-ref opts 'container?)) - (not (assoc-ref opts 'search-paths))) - (display-hint (G_ "Consider passing the @option{--check} option once + (with-error-handling + (define (cache-entries directory) + (filter-map (match-lambda + ((or "." "..") #f) + (file (string-append directory "/" file))) + (or (scandir directory) '()))) + + (define* (entry-expiration file) + ;; Return the time at which FILE, a cached profile, is considered expired. + (match (false-if-exception (lstat file)) + (#f 0) ;FILE may have been deleted in the meantime + (st (+ (stat:atime st) (* 60 60 24 7))))) + + (define opts + (parse-args args)) + + (define interactive? + (not (assoc-ref opts 'exec))) + + (if (assoc-ref opts 'check?) + (record-hint 'shell-check) + (when (and interactive? + (not (hint-given? 'shell-check)) + (not (assoc-ref opts 'container?)) + (not (assoc-ref opts 'search-paths))) + (display-hint (G_ "Consider passing the @option{--check} option once to make sure your shell does not clobber environment variables."))) ) - ;; Clean the cache in EXIT-HOOK so that (1) it happens after potential use - ;; of cached profiles, and (2) cleanup actually happens, even when - ;; 'guix-environment*' calls 'exit'. - (add-hook! exit-hook - (lambda _ - (maybe-remove-expired-cache-entries - (%profile-cache-directory) - cache-entries - #:entry-expiration entry-expiration))) - - (if (assoc-ref opts 'export-manifest?) - (export-manifest opts (current-output-port)) - (guix-environment* opts))) + ;; Clean the cache in EXIT-HOOK so that (1) it happens after potential use + ;; of cached profiles, and (2) cleanup actually happens, even when + ;; 'guix-environment*' calls 'exit'. + (add-hook! exit-hook + (lambda _ + (maybe-remove-expired-cache-entries + (%profile-cache-directory) + cache-entries + #:entry-expiration entry-expiration))) + + (if (assoc-ref opts 'export-manifest?) + (export-manifest opts (current-output-port)) + (guix-environment* opts)))) diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index 82192375c7..0306fc1744 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -250,3 +250,6 @@ guix shell --bootstrap guile-bootstrap --container \ # A dangling symlink causes the command to fail. ! guix shell --bootstrap -CS /usr/bin/python=bin/python guile-bootstrap -- exit + +# An invalid symlink spec causes the command to fail. +! guix shell --bootstrap -CS bin/guile=/usr/bin/guile guile-bootstrap -- exit diff --git a/tests/guix-pack.sh b/tests/guix-pack.sh index f19a0f754e..6fc9e3723b 100644 --- a/tests/guix-pack.sh +++ b/tests/guix-pack.sh @@ -103,7 +103,7 @@ fi guix pack --dry-run --bootstrap -f docker guile-bootstrap # Build a Docker image with a symlink. -guix pack --dry-run --bootstrap -f docker -S /opt/gnu=/ guile-bootstrap +guix pack --dry-run --bootstrap -f docker -S /opt/gnu= guile-bootstrap # Build a tarball pack of cross-compiled software. Use coreutils because # guile-bootstrap is not intended to be cross-compiled. -- 2.37.3 From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 14 Nov 2022 09:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166841751614432 (code B ref 58812); Mon, 14 Nov 2022 09:19:02 +0000 Received: (at 58812) by debbugs.gnu.org; 14 Nov 2022 09:18:36 +0000 Received: from localhost ([127.0.0.1]:48917 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouVbw-0003ki-0C for submit@debbugs.gnu.org; Mon, 14 Nov 2022 04:18:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouVbt-0003kT-6c for 58812@debbugs.gnu.org; Mon, 14 Nov 2022 04:18:34 -0500 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 1ouVbn-000338-P0; Mon, 14 Nov 2022 04:18:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=cIlwb7QIXf05vc2i5SPXJxMrjwRNMjjiPBWw4O1MTD0=; b=OkJyqg/UNO+a5uIpZRBi XU+tah+CUjG5udRHYWfjH3TJ/K90GIOLRHr82TcCZ2FBZBJ8C8K7JYEJvrkEWVON4rILgVN9rL+gF TERXgdZqGMfEI/I3tjp67JiHFL7Nx390+PUe3Nw3WFv41gUvBV8QSZJaAfrJHj/04kN/rtukktYhA n5NdYC4LVpsT2hcsZVvoKIQdmAWNd+wRwN10Eux5NzLWExx5OZB3aEH7x/HeUuHTbRE+ERXC5A0JB Ywy7UA1NBPSwqKnvlGsicnSem5qlNbw5fIAwGINl6bXvm+rXHAJt9JCkNsV4UBuP1z114eqJ//cPQ WDIj9VmKyusQ1g==; Received: from [193.50.110.147] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouVbm-0008Gz-RQ; Mon, 14 Nov 2022 04:18:27 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-4-maxim.cournoyer@gmail.com> <87r0ybonei.fsf_-_@gnu.org> <87fsery05t.fsf@gmail.com> <87sfiqhp1u.fsf@gnu.org> <87k042x3sx.fsf@gmail.com> <87fseqx2kb.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Quartidi 24 Brumaire an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour de l'Orange X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Mon, 14 Nov 2022 10:18:23 +0100 In-Reply-To: <87fseqx2kb.fsf@gmail.com> (Maxim Cournoyer's message of "Thu, 10 Nov 2022 10:16:20 -0500") Message-ID: <875yfhsxls.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Maxim Cournoyer skribis: > Contrary to what the Texinfo manual says, pxref seems to be the one > introducing the awkward "*note" verb in the resulting info. If you read it in Emacs, it looks a bit different; I think info.el adds removes =E2=80=9Cnote=E2=80=9D and adds =E2=80=9Csee=E2=80=9D in some cases= (e.g., see =E2=80=98Info-hide-note-references=E2=80=99). Ludo=E2=80=99. From unknown Sat Jun 21 05:02:58 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Maxim Cournoyer Subject: bug#58812: closed (Re: bug#58812: [PATCH v3 1/4] shell: Detect --symlink spec problems early.) Message-ID: References: <87y1sblxls.fsf@gmail.com> <20221027034154.28435-1-maxim.cournoyer@gmail.com> X-Gnu-PR-Message: they-closed 58812 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 58812@debbugs.gnu.org Date: Tue, 15 Nov 2022 21:25:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1668547502-10229-1" This is a multi-part message in MIME format... ------------=_1668547502-10229-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #58812: [PATCH 0/5] Add --symlink option to 'guix shell'. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 58812@debbugs.gnu.org. --=20 58812: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D58812 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1668547502-10229-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 58812-done) by debbugs.gnu.org; 15 Nov 2022 21:25:00 +0000 Received: from localhost ([127.0.0.1]:55399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov3QS-0002ec-2T for submit@debbugs.gnu.org; Tue, 15 Nov 2022 16:25:00 -0500 Received: from mail-qk1-f175.google.com ([209.85.222.175]:46000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov3QP-0002eH-Kk; Tue, 15 Nov 2022 16:24:58 -0500 Received: by mail-qk1-f175.google.com with SMTP id v8so10413531qkg.12; Tue, 15 Nov 2022 13:24:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6On4ymAF8XwbbSSlnrqmfj74U2KxNG9NkiWzr1kjxfQ=; b=SYW2psAZkQvUmKvVYv11rhKuy0o1echY75eG+hlJ4aijMzO4zXx/yKj5/DetUG7Plm MTO0VxL5pNJ522KwulrtX5gHB44Ecq056TeMQdZd6dWgVpaAa56hDC4uZd8KhxUh8CKC PZy9qRuTaSEjZvtdVk0lp9Nu5nCg/9L1kyEaB2QCiwyy1w5toXpM6urPq+3CrgP0NprT wlKxbWn+rlG/CwcQUE2DvL7O7gq8h5sxjJ0zK5wMH10SQx6U9/J64D7XgSKabQureY0+ MWoD3Fm1P7bpS/ga1ImmlemZw+421CalumWcAbFeb3Zm1RaWHLPdAZXl3MnShXWev+Rz sjeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6On4ymAF8XwbbSSlnrqmfj74U2KxNG9NkiWzr1kjxfQ=; b=MoFNAeLGsNAFJNVsnOc/AyPjS0l/F6+KPbphA0qgBVh8Z1/hX/H5KjtSkQVfY2PxYJ ZkSCtHUfcZ/Mq911ASohtyxwbA2aA9pMYUgveLEvBx3i2iTnis9cR+qjzv5TcPGzjO57 OGM319vg1yhJGlLIQgsj33Rtan113uWaKR5oyhaOZQnbY4kFchy6UsM2A1sgsVKIZXIk tqiPVg6GGQPq+iXQP8aCaXu+1I/9tgB4DpPqZgcLRVZk3L8rF53AtBj98ksu7hicTB7w WoVT+pkzTTt1nLZqocco7tpE1ijjIqu0VeLVy7KbnkFXz/KEShj69jnvqC1VY7jiwdOI sPPw== X-Gm-Message-State: ANoB5plCfiLKeRGR/RSrwVFrDOTOvlcmCACvPf8XzVG7xwWzbBzvInZn RjRWTTUVLQsxLBSEVKoyvffjakN+DY+ytw== X-Google-Smtp-Source: AA0mqf5YXpFyR8Zc9+PRUtg/Kgu2id5FuLFmVrUOYpm+vHa9TEo6KAGjXCT56ZfyWL5ISFMW1o+3EA== X-Received: by 2002:a05:620a:51c6:b0:6fa:476:99ec with SMTP id cx6-20020a05620a51c600b006fa047699ecmr16420660qkb.727.1668547491936; Tue, 15 Nov 2022 13:24:51 -0800 (PST) Received: from hurd (dsl-151-98.b2b2c.ca. [66.158.151.98]) by smtp.gmail.com with ESMTPSA id i17-20020ac85c11000000b00397e97baa96sm7890032qti.0.2022.11.15.13.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 13:24:51 -0800 (PST) From: Maxim Cournoyer To: 58812-done@debbugs.gnu.org Subject: Re: bug#58812: [PATCH v3 1/4] shell: Detect --symlink spec problems early. References: <20221027034154.28435-1-maxim.cournoyer@gmail.com> Date: Tue, 15 Nov 2022 16:24:47 -0500 In-Reply-To: <20221027034154.28435-1-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Wed, 26 Oct 2022 23:41:54 -0400") Message-ID: <87y1sblxls.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58812-done Cc: 59164-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, [...] > Makefile.am: Sort EXTRA_DIST entries. > tests: Add a tests/utils.sh support file. > install: Validate symlink target in evaluate-populate-directive. > guix: shell: Add '--symlink' option. > shell: Detect --symlink spec problems early. I've now pushed this series as 8f9588185d, with a news entry added as 47f319f21f. Closing! -- Thanks, Maxim ------------=_1668547502-10229-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 27 Oct 2022 03:42:33 +0000 Received: from localhost ([127.0.0.1]:55688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontmc-0001rQ-Fj for submit@debbugs.gnu.org; Wed, 26 Oct 2022 23:42:33 -0400 Received: from lists.gnu.org ([209.51.188.17]:41788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontmP-0001r7-CX for submit@debbugs.gnu.org; Wed, 26 Oct 2022 23:42:16 -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 1ontmP-00036k-4U for guix-patches@gnu.org; Wed, 26 Oct 2022 23:42:05 -0400 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ontmJ-0007bM-TG for guix-patches@gnu.org; Wed, 26 Oct 2022 23:42:04 -0400 Received: by mail-qv1-xf2a.google.com with SMTP id n18so202112qvt.11 for ; Wed, 26 Oct 2022 20:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=D8mWfN0XzLz08gJwAzSvf2zqwuBOISMFIGApHbN2lVE=; b=HPvvQF64m+WzMvEDQAP7QxQh3EqjkLkCDTPWzUt+Hru2JS1tn7659mUIgwsavFl7Xw o5hO7AkFJ7Sw++GM8QAhMXO4AXuANVIb/SMZlN7HK8ce+5zB6lqKsibeaBKNBu8yffp4 YnzjpJV7De0wum5dl6zF+zWbHFgtvs2vMjeNUBJs55r7tV7N3n/d3EwA3fBOJ8crhBCl zQb9IO6jhOgsfCSZDTEtkomJdJGNxjiYn08rONuuiu9UkUhUfkfYTFE3rLO+n+3upfjW VvtRgqVIyo6i0CB0faaysixDe3XiV1tt1jk3OYiU8JWKeSab2EI6ST9N4xpZRfiTv3CJ Nz/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=D8mWfN0XzLz08gJwAzSvf2zqwuBOISMFIGApHbN2lVE=; b=CJnMim9Dh5c/NhEiZkVJnq+U/x7lyswNPVUzqR8Wy3zMY7iLGk0sH+2nppzGG2Z6wV zUgECfCPYfWlNNbxajzX+09Oj3qR/u+hl0aeR97O34NbWbRYRnBgnrtdHeMzUcnDUrvw 2rtiQ5CArNCZS7BUUEXaXj+a2/dR1K/jp6cBVMVSSSTWmGK2N4b9Turrwm7+9gWiu/ik bWY5URu8nJde7hXTFSixayg3wxPNijuVrzisWA1Kj5Q28FSZfGaFuQn99v4/Ep+C8kMf a9ZRAB1RKIKVLOJ5rKQV8tZiN06FaGSkCFjg2TfFhWikO8+pGIjWDZBizmtBhwYtUlb0 /r2Q== X-Gm-Message-State: ACrzQf0RPUdN1SGavya/pTrxjbfS7fk7haqtjEApDyDP+H9747fP8L7v xqN5+tmw7yCo8eQQeip0wDJkDQZi/W8= X-Google-Smtp-Source: AMsMyM5mDozLWdPM7BmUrhzoXKbJqvf2FgGBI/2M0YkXY92mHnQMMsymjB4LxECzUo8CaiOK7hMfKQ== X-Received: by 2002:a05:6214:c6d:b0:4b1:c751:ac7 with SMTP id t13-20020a0562140c6d00b004b1c7510ac7mr40879503qvj.96.1666842116805; Wed, 26 Oct 2022 20:41:56 -0700 (PDT) Received: from localhost.localdomain (dsl-152-21.b2b2c.ca. [66.158.152.21]) by smtp.gmail.com with ESMTPSA id f11-20020a05620a280b00b006eee3a09ff3sm265260qkp.69.2022.10.26.20.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 20:41:56 -0700 (PDT) From: Maxim Cournoyer To: guix-patches@gnu.org Subject: [PATCH 0/5] Add --symlink option to 'guix shell'. Date: Wed, 26 Oct 2022 23:41:54 -0400 Message-Id: <20221027034154.28435-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qv1-xf2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Hi, I've wanted this enough times now to finally get around implementing it :-). My main use case for it will be creating a /usr/bin/env symlink in 'guix shell' environments for portability with the #!/usr/bin/env shebang. While at it, I've improved error reporting and made it fail early when a symlink would point to a nonexistent file (dangling symlink). The test suite passes, and I've run the basic system test as well as the 'btrfs-root-os' one successfully. Thanks, Maxim Cournoyer (5): Makefile.am: Sort EXTRA_DIST entries. tests: Add a tests/utils.sh support file. install: Validate symlink target in evaluate-populate-directive. guix: shell: Add '--symlink' option. shell: Detect --symlink spec problems early. Makefile.am | 55 ++++--- doc/guix.texi | 9 +- gnu/build/install.scm | 78 ++++++--- guix/scripts/environment.scm | 298 +++++++++++++++++++---------------- guix/scripts/pack.scm | 208 ++++++++++++------------ guix/scripts/shell.scm | 77 ++++----- tests/guix-pack.sh | 2 +- tests/guix-shell.sh | 21 +++ tests/shell-utils.scm | 29 ++++ tests/utils.sh | 33 ++++ 10 files changed, 483 insertions(+), 327 deletions(-) create mode 100644 tests/shell-utils.scm create mode 100644 tests/utils.sh -- 2.37.3 ------------=_1668547502-10229-1-- From unknown Sat Jun 21 05:02:58 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Maxim Cournoyer Subject: bug#59161: closed (Re: bug#58812: [PATCH v3 1/4] shell: Detect --symlink spec problems early.) Message-ID: References: <87y1sblxls.fsf@gmail.com> <20221110042351.829-2-maxim.cournoyer@gmail.com> X-Gnu-PR-Message: they-closed 59161 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 59161@debbugs.gnu.org Date: Tue, 15 Nov 2022 21:25:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1668547503-10229-3" This is a multi-part message in MIME format... ------------=_1668547503-10229-3 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #58812: [PATCH v2 2/4] install: Validate symlink target in evaluate-populat= e-directive. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 59161@debbugs.gnu.org. --=20 58812: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D58812 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1668547503-10229-3 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 58812-done) by debbugs.gnu.org; 15 Nov 2022 21:25:00 +0000 Received: from localhost ([127.0.0.1]:55399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov3QS-0002ec-2T for submit@debbugs.gnu.org; Tue, 15 Nov 2022 16:25:00 -0500 Received: from mail-qk1-f175.google.com ([209.85.222.175]:46000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov3QP-0002eH-Kk; Tue, 15 Nov 2022 16:24:58 -0500 Received: by mail-qk1-f175.google.com with SMTP id v8so10413531qkg.12; Tue, 15 Nov 2022 13:24:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6On4ymAF8XwbbSSlnrqmfj74U2KxNG9NkiWzr1kjxfQ=; b=SYW2psAZkQvUmKvVYv11rhKuy0o1echY75eG+hlJ4aijMzO4zXx/yKj5/DetUG7Plm MTO0VxL5pNJ522KwulrtX5gHB44Ecq056TeMQdZd6dWgVpaAa56hDC4uZd8KhxUh8CKC PZy9qRuTaSEjZvtdVk0lp9Nu5nCg/9L1kyEaB2QCiwyy1w5toXpM6urPq+3CrgP0NprT wlKxbWn+rlG/CwcQUE2DvL7O7gq8h5sxjJ0zK5wMH10SQx6U9/J64D7XgSKabQureY0+ MWoD3Fm1P7bpS/ga1ImmlemZw+421CalumWcAbFeb3Zm1RaWHLPdAZXl3MnShXWev+Rz sjeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6On4ymAF8XwbbSSlnrqmfj74U2KxNG9NkiWzr1kjxfQ=; b=MoFNAeLGsNAFJNVsnOc/AyPjS0l/F6+KPbphA0qgBVh8Z1/hX/H5KjtSkQVfY2PxYJ ZkSCtHUfcZ/Mq911ASohtyxwbA2aA9pMYUgveLEvBx3i2iTnis9cR+qjzv5TcPGzjO57 OGM319vg1yhJGlLIQgsj33Rtan113uWaKR5oyhaOZQnbY4kFchy6UsM2A1sgsVKIZXIk tqiPVg6GGQPq+iXQP8aCaXu+1I/9tgB4DpPqZgcLRVZk3L8rF53AtBj98ksu7hicTB7w WoVT+pkzTTt1nLZqocco7tpE1ijjIqu0VeLVy7KbnkFXz/KEShj69jnvqC1VY7jiwdOI sPPw== X-Gm-Message-State: ANoB5plCfiLKeRGR/RSrwVFrDOTOvlcmCACvPf8XzVG7xwWzbBzvInZn RjRWTTUVLQsxLBSEVKoyvffjakN+DY+ytw== X-Google-Smtp-Source: AA0mqf5YXpFyR8Zc9+PRUtg/Kgu2id5FuLFmVrUOYpm+vHa9TEo6KAGjXCT56ZfyWL5ISFMW1o+3EA== X-Received: by 2002:a05:620a:51c6:b0:6fa:476:99ec with SMTP id cx6-20020a05620a51c600b006fa047699ecmr16420660qkb.727.1668547491936; Tue, 15 Nov 2022 13:24:51 -0800 (PST) Received: from hurd (dsl-151-98.b2b2c.ca. [66.158.151.98]) by smtp.gmail.com with ESMTPSA id i17-20020ac85c11000000b00397e97baa96sm7890032qti.0.2022.11.15.13.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 13:24:51 -0800 (PST) From: Maxim Cournoyer To: 58812-done@debbugs.gnu.org Subject: Re: bug#58812: [PATCH v3 1/4] shell: Detect --symlink spec problems early. References: <20221027034154.28435-1-maxim.cournoyer@gmail.com> Date: Tue, 15 Nov 2022 16:24:47 -0500 In-Reply-To: <20221027034154.28435-1-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Wed, 26 Oct 2022 23:41:54 -0400") Message-ID: <87y1sblxls.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58812-done Cc: 59164-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, [...] > Makefile.am: Sort EXTRA_DIST entries. > tests: Add a tests/utils.sh support file. > install: Validate symlink target in evaluate-populate-directive. > guix: shell: Add '--symlink' option. > shell: Detect --symlink spec problems early. I've now pushed this series as 8f9588185d, with a news entry added as 47f319f21f. Closing! -- Thanks, Maxim ------------=_1668547503-10229-3 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 10 Nov 2022 04:24:16 +0000 Received: from localhost ([127.0.0.1]:41551 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osz6t-00052Y-8Y for submit@debbugs.gnu.org; Wed, 09 Nov 2022 23:24:15 -0500 Received: from lists.gnu.org ([209.51.188.17]:52086) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osz6r-00052P-Id for submit@debbugs.gnu.org; Wed, 09 Nov 2022 23:24:14 -0500 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 1osz6p-00046n-JJ for guix-patches@gnu.org; Wed, 09 Nov 2022 23:24:13 -0500 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osz6n-0006mG-Tk for guix-patches@gnu.org; Wed, 09 Nov 2022 23:24:11 -0500 Received: by mail-qt1-x829.google.com with SMTP id h21so403703qtu.2 for ; Wed, 09 Nov 2022 20:24:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=zrkjGIBtzayhHZQrYnnG/gG6ymHR3J6x5PRzXc/KVf4=; b=D0MycE7m4wtArYzszwaInPlmUkdFGQ2Yj/DGY4R/RWLun8TcZRVVYiqi3SnQx6KxLE ldSqwNXsMTfUQGUDWw8jrbFRR39fumxyEwbls6FZfrHAXO2yQhbeS1AaaFTWeP/0+Kpl co5h0AYhIkRmB3CGBKER6OpNPBRMUfArI3nImKBiqs39k4dRSb4ZrJkOh24IUXh+Vgc+ 2aEisOXJy5wU33On5fxQbsrBl1gMCDEKqA0lfsPTVIB/ud0We6tIkbgNVWShIHCpWIFJ kT/ZfC8XZSLA1Qg+cjz6Gvx4B5BaZjRdazenG8bkWBdaf0WcRt7ZSveA9yeBp5SL9ZFl I20g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=zrkjGIBtzayhHZQrYnnG/gG6ymHR3J6x5PRzXc/KVf4=; b=XuCFf0LA/ptdc7nr1991hooGTN4z5kq8wXgV7w24s5mETmKlIRPpA1ShIndzoxZ7uk vUhQO4PlLK8O/ZJt5N0WoDBR1i7kiwnTG6RaeIRfXOU8ocNw2wSrijlQlNDdSI8wHly5 mFzv2s2pvlHCZd97sZRolAW1by7PEZxz55xnhgTFDzFxhY2MFGo4eqwY5ksNHsmVLjxh bawQSaEijhN8KS7MV5L6McQS5Nl2/56pS0OTWNCD7Fa7BaW5FJ0yAoy5u63WXIOu0dI0 Xf0zC2foJke//TWOD8s3o8dF6/sKLlSd953iZanHEiIMEVOE5Ux31e8Gjbm+1b5VNgdf BaQQ== X-Gm-Message-State: ACrzQf1r2cKujfI5vayEcfez778VeSbVslwUGTmGjehpKAinVPFkQJ6e NzwzcayhqySzc+J7ZCAiNepnb/d+4ZI= X-Google-Smtp-Source: AMsMyM50jm9G7m0e3TdiaPj94AR1WbWsy6oyId3V1n86R/Pqxt76Z/kduwncSqYwJ6GNwDx1vopaLQ== X-Received: by 2002:ac8:6b45:0:b0:3a5:6416:a499 with SMTP id x5-20020ac86b45000000b003a56416a499mr24696824qts.263.1668054248667; Wed, 09 Nov 2022 20:24:08 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id r1-20020ac85e81000000b0039cc7ebf46bsm10515105qtx.93.2022.11.09.20.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 20:24:08 -0800 (PST) From: Maxim Cournoyer To: guix-patches@gnu.org Subject: [PATCH v2 2/4] install: Validate symlink target in evaluate-populate-directive. Date: Wed, 9 Nov 2022 23:23:49 -0500 Message-Id: <20221110042351.829-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221110042351.829-1-maxim.cournoyer@gmail.com> References: <87h6z7omzy.fsf_-_@gnu.org> <20221110042351.829-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x829.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * gnu/build/install.scm (evaluate-populate-directive): By default, error when the target of a symlink doesn't exist. Always ensure TARGET ends with "/". (populate-root-file-system): Call evaluate-populate-directive with #:error-on-dangling-symlink #t and add comment. --- gnu/build/install.scm | 60 ++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/gnu/build/install.scm b/gnu/build/install.scm index f5c8407b89..33a9616c0d 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2016 Chris Marusich +;;; Copyright © 2022 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -56,19 +57,24 @@ (define (install-boot-config bootcfg bootcfg-location mount-point) (define* (evaluate-populate-directive directive target #:key (default-gid 0) - (default-uid 0)) + (default-uid 0) + (error-on-dangling-symlink? #t)) "Evaluate DIRECTIVE, an sexp describing a file or directory to create under directory TARGET. DEFAULT-UID and DEFAULT-GID are the default UID and GID in the context of the caller. If the directive matches those defaults then, -'chown' won't be run." +'chown' won't be run. When ERROR-ON-DANGLING-SYMLINK? is true, abort with an +error when a dangling symlink would be created." + (define target* (if (string-suffix? "/" target) + target + (string-append target "/"))) (let loop ((directive directive)) (catch 'system-error (lambda () (match directive (('directory name) - (mkdir-p (string-append target name))) + (mkdir-p (string-append target* name))) (('directory name uid gid) - (let ((dir (string-append target name))) + (let ((dir (string-append target* name))) (mkdir-p dir) ;; If called from a context without "root" permissions, "chown" ;; to root will fail. In that case, do not try to run "chown" @@ -78,27 +84,38 @@ (define* (evaluate-populate-directive directive target (chown dir uid gid)))) (('directory name uid gid mode) (loop `(directory ,name ,uid ,gid)) - (chmod (string-append target name) mode)) + (chmod (string-append target* name) mode)) (('file name) - (call-with-output-file (string-append target name) + (call-with-output-file (string-append target* name) (const #t))) (('file name (? string? content)) - (call-with-output-file (string-append target name) + (call-with-output-file (string-append target* name) (lambda (port) (display content port)))) ((new '-> old) - (let try () - (catch 'system-error - (lambda () - (symlink old (string-append target new))) - (lambda args - ;; When doing 'guix system init' on the current '/', some - ;; symlinks may already exists. Override them. - (if (= EEXIST (system-error-errno args)) - (begin - (delete-file (string-append target new)) - (try)) - (apply throw args)))))))) + (let ((new* (string-append target* new))) + (let try () + (catch 'system-error + (lambda () + (when error-on-dangling-symlink? + ;; When the symbolic link points to a relative path, + ;; checking if its target exists must be done relatively + ;; to the link location. + (unless (if (string-prefix? "/" old) + (file-exists? old) + (with-directory-excursion (dirname new*) + (file-exists? old))) + (error (format #f "symlink `~a' points to nonexistent \ +file `~a'" new* old)))) + (symlink old new*)) + (lambda args + ;; When doing 'guix system init' on the current '/', some + ;; symlinks may already exists. Override them. + (if (= EEXIST (system-error-errno args)) + (begin + (delete-file new*) + (try)) + (apply throw args))))))))) (lambda args ;; Usually we can only get here when installing to an existing root, ;; as with 'guix system init foo.scm /'. @@ -142,7 +159,10 @@ (define* (populate-root-file-system system target includes /etc, /var, /run, /bin/sh, etc., and all the symlinks to SYSTEM. EXTRAS is a list of directives appended to the built-in directives to populate TARGET." - (for-each (cut evaluate-populate-directive <> target) + ;; It's expected that some symbolic link targets do not exist yet, so do not + ;; error on dangling links. + (for-each (cut evaluate-populate-directive <> target + #:error-on-dangling-symlink? #f) (append (directives (%store-directory)) extras)) ;; Add system generation 1. -- 2.37.3 ------------=_1668547503-10229-3-- From unknown Sat Jun 21 05:02:58 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Maxim Cournoyer Subject: bug#59162: closed (Re: bug#58812: [PATCH v3 1/4] shell: Detect --symlink spec problems early.) Message-ID: References: <87y1sblxls.fsf@gmail.com> <20221110042351.829-3-maxim.cournoyer@gmail.com> X-Gnu-PR-Message: they-closed 59162 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 59162@debbugs.gnu.org Date: Tue, 15 Nov 2022 21:25:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1668547503-10229-5" This is a multi-part message in MIME format... ------------=_1668547503-10229-5 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #58812: [PATCH v2 3/4] guix: shell: Add '--symlink' option. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 59162@debbugs.gnu.org. --=20 58812: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D58812 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1668547503-10229-5 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 58812-done) by debbugs.gnu.org; 15 Nov 2022 21:25:00 +0000 Received: from localhost ([127.0.0.1]:55399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov3QS-0002ec-2T for submit@debbugs.gnu.org; Tue, 15 Nov 2022 16:25:00 -0500 Received: from mail-qk1-f175.google.com ([209.85.222.175]:46000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov3QP-0002eH-Kk; Tue, 15 Nov 2022 16:24:58 -0500 Received: by mail-qk1-f175.google.com with SMTP id v8so10413531qkg.12; Tue, 15 Nov 2022 13:24:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6On4ymAF8XwbbSSlnrqmfj74U2KxNG9NkiWzr1kjxfQ=; b=SYW2psAZkQvUmKvVYv11rhKuy0o1echY75eG+hlJ4aijMzO4zXx/yKj5/DetUG7Plm MTO0VxL5pNJ522KwulrtX5gHB44Ecq056TeMQdZd6dWgVpaAa56hDC4uZd8KhxUh8CKC PZy9qRuTaSEjZvtdVk0lp9Nu5nCg/9L1kyEaB2QCiwyy1w5toXpM6urPq+3CrgP0NprT wlKxbWn+rlG/CwcQUE2DvL7O7gq8h5sxjJ0zK5wMH10SQx6U9/J64D7XgSKabQureY0+ MWoD3Fm1P7bpS/ga1ImmlemZw+421CalumWcAbFeb3Zm1RaWHLPdAZXl3MnShXWev+Rz sjeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6On4ymAF8XwbbSSlnrqmfj74U2KxNG9NkiWzr1kjxfQ=; b=MoFNAeLGsNAFJNVsnOc/AyPjS0l/F6+KPbphA0qgBVh8Z1/hX/H5KjtSkQVfY2PxYJ ZkSCtHUfcZ/Mq911ASohtyxwbA2aA9pMYUgveLEvBx3i2iTnis9cR+qjzv5TcPGzjO57 OGM319vg1yhJGlLIQgsj33Rtan113uWaKR5oyhaOZQnbY4kFchy6UsM2A1sgsVKIZXIk tqiPVg6GGQPq+iXQP8aCaXu+1I/9tgB4DpPqZgcLRVZk3L8rF53AtBj98ksu7hicTB7w WoVT+pkzTTt1nLZqocco7tpE1ijjIqu0VeLVy7KbnkFXz/KEShj69jnvqC1VY7jiwdOI sPPw== X-Gm-Message-State: ANoB5plCfiLKeRGR/RSrwVFrDOTOvlcmCACvPf8XzVG7xwWzbBzvInZn RjRWTTUVLQsxLBSEVKoyvffjakN+DY+ytw== X-Google-Smtp-Source: AA0mqf5YXpFyR8Zc9+PRUtg/Kgu2id5FuLFmVrUOYpm+vHa9TEo6KAGjXCT56ZfyWL5ISFMW1o+3EA== X-Received: by 2002:a05:620a:51c6:b0:6fa:476:99ec with SMTP id cx6-20020a05620a51c600b006fa047699ecmr16420660qkb.727.1668547491936; Tue, 15 Nov 2022 13:24:51 -0800 (PST) Received: from hurd (dsl-151-98.b2b2c.ca. [66.158.151.98]) by smtp.gmail.com with ESMTPSA id i17-20020ac85c11000000b00397e97baa96sm7890032qti.0.2022.11.15.13.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 13:24:51 -0800 (PST) From: Maxim Cournoyer To: 58812-done@debbugs.gnu.org Subject: Re: bug#58812: [PATCH v3 1/4] shell: Detect --symlink spec problems early. References: <20221027034154.28435-1-maxim.cournoyer@gmail.com> Date: Tue, 15 Nov 2022 16:24:47 -0500 In-Reply-To: <20221027034154.28435-1-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Wed, 26 Oct 2022 23:41:54 -0400") Message-ID: <87y1sblxls.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58812-done Cc: 59164-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, [...] > Makefile.am: Sort EXTRA_DIST entries. > tests: Add a tests/utils.sh support file. > install: Validate symlink target in evaluate-populate-directive. > guix: shell: Add '--symlink' option. > shell: Detect --symlink spec problems early. I've now pushed this series as 8f9588185d, with a news entry added as 47f319f21f. Closing! -- Thanks, Maxim ------------=_1668547503-10229-5 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 10 Nov 2022 04:24:20 +0000 Received: from localhost ([127.0.0.1]:41556 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osz6x-000532-QY for submit@debbugs.gnu.org; Wed, 09 Nov 2022 23:24:20 -0500 Received: from lists.gnu.org ([209.51.188.17]:52100) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osz6t-00052Z-9P for submit@debbugs.gnu.org; Wed, 09 Nov 2022 23:24:16 -0500 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 1osz6r-00046v-Pf for guix-patches@gnu.org; Wed, 09 Nov 2022 23:24:14 -0500 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osz6o-0006mU-Uh for guix-patches@gnu.org; Wed, 09 Nov 2022 23:24:13 -0500 Received: by mail-qv1-xf2f.google.com with SMTP id x13so687024qvn.6 for ; Wed, 09 Nov 2022 20:24:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=62Aj9dyq4hcgsGUeIJDejgZUwgP+d5EOqLQYoO4X42s=; b=ccMotLEOGFb6bT0ap9XaVnhhqrplrd82Py9ITSHUfWDYbcEPa7Fi6IlZbS4nMSd2FW E2UPAOP4DsHW6SYd+nUEv291gk4+2YF3MOPydIw818DzpWyfjlK6vld1krJS5yt5nbgk Ta9mADVlWE2VzeHaU8JkM5WPmQjlxCiwhPXEWpQKzMpYLmDr8l+27RJ6j2ArJEpIbFmY hTEvFzKmoqOnNBE7Si3DeRhbUh04IjhxSygkurLBb9knyqqw9PWRUVHfBXdqpomKeii2 +7mLxvKfmK+V+5qIeVXZNSKPhlqP/1fO6apVmI05uhodQhFGnwC46GqxvsobwG/Tac+q UrOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=62Aj9dyq4hcgsGUeIJDejgZUwgP+d5EOqLQYoO4X42s=; b=pnc6vEDO0h4HrqMOZ/RAKVbQtUv0eIoObVBMvbjww4OrhOq4NTcaOIr1H0sI8AAIYm vPq94F3KcvM3i46QNhOrgxAEc6CAjZ+R9FfOy2raQTNXhynRlHMyKflqDiHGBCrwt99x JFGeReAzR3bIyr4WFTnfSRlRbr9tIqZDNgAyDbEPgLO56fqQMNJWzjPeL0+E8RfoT3Eh cawKLkQhUIrYwF+ggS8HpkvyVyC9fscDwjmvYjYDHrb7JaeP5j6ahsFQw3Y2NFvTOnqn WshInVgbIl+nSBikZD13fpNAPYtJlKTeDGSxSQFg3p3q4suR6pcJzcUodLSKf/x3t+L4 zzXQ== X-Gm-Message-State: ACrzQf2bsj0+ahlB4x0MgdfpDTQg0R18fyk0mNc1cDuACqLYWGvWJMSQ EYzGQoPYzyFoMys1oUPW/x1+fb3v7mo= X-Google-Smtp-Source: AMsMyM4DMCz9PgE1R+hx7f+EBsw8h01ruuClae7CyG96m3Sa/UcqGbV+tPIZE4WrBURatGbHgbStug== X-Received: by 2002:a05:6214:cac:b0:4bb:5477:c24d with SMTP id s12-20020a0562140cac00b004bb5477c24dmr57915470qvs.116.1668054249436; Wed, 09 Nov 2022 20:24:09 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id r1-20020ac85e81000000b0039cc7ebf46bsm10515105qtx.93.2022.11.09.20.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 20:24:09 -0800 (PST) From: Maxim Cournoyer To: guix-patches@gnu.org Subject: [PATCH v2 3/4] guix: shell: Add '--symlink' option. Date: Wed, 9 Nov 2022 23:23:50 -0500 Message-Id: <20221110042351.829-3-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221110042351.829-1-maxim.cournoyer@gmail.com> References: <87h6z7omzy.fsf_-_@gnu.org> <20221110042351.829-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qv1-xf2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * guix/scripts/pack.scm (%options): Extract symlink parsing logic to... (symlink-spec-option-parser): ... here. (self-contained-tarball/builder): Extract symlink->directives logic to... * gnu/build/install.scm (make-symlink->directives): ... here. Add a comment mentioning why a relative file name is used for the link target. * guix/scripts/environment.scm (show-environment-options-help): Document new --symlink option. (%default-options): Add default value for symlinks. (%options): Register new symlink option. (launch-environment/container): Add #:symlinks argument and extend doc. Create symlinks using evaluate-populate-directive and make-symlink->directives. (guix-environment*): Pass symlinks arguments to launch-environment/container. * doc/guix.texi (Invoking guix shell): Document it. * tests/guix-shell.sh: Add a --symlink (negative) test. * tests/guix-environment-container.sh: Add tests. --- doc/guix.texi | 9 ++++- gnu/build/install.scm | 18 +++++++++ guix/scripts/environment.scm | 38 ++++++++++++++----- guix/scripts/pack.scm | 57 ++++++++++++----------------- tests/guix-environment-container.sh | 12 ++++++ tests/guix-shell.sh | 3 ++ 6 files changed, 92 insertions(+), 45 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 3f76184495..94c3f29790 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -49,7 +49,7 @@ Copyright @copyright{} 2017 humanitiesNerd@* Copyright @copyright{} 2017, 2021 Christine Lemmer-Webber@* Copyright @copyright{} 2017, 2018, 2019, 2020, 2021, 2022 Marius Bakke@* Copyright @copyright{} 2017, 2019, 2020, 2022 Hartmut Goebel@* -Copyright @copyright{} 2017, 2019, 2020, 2021 Maxim Cournoyer@* +Copyright @copyright{} 2017, 2019, 2020, 2021, 2022 Maxim Cournoyer@* Copyright @copyright{} 2017–2022 Tobias Geerinckx-Rice@* Copyright @copyright{} 2017 George Clemmer@* Copyright @copyright{} 2017 Andy Wingo@* @@ -6242,6 +6242,12 @@ directory: guix shell --container --expose=$HOME=/exchange guile -- guile @end example +@cindex symbolic links, guix shell +@item --symlink=@var{spec} +@itemx -S @var{spec} +For containers, create the symbolic links specified by @var{spec}, as +documented in @ref{pack-symlink-option}. + @cindex file system hierarchy standard (FHS) @cindex FHS (file system hierarchy standard) @item --emulate-fhs @@ -7034,6 +7040,7 @@ Compress the resulting tarball using @var{tool}---one of @code{gzip}, @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression. +@anchor{pack-symlink-option} @item --symlink=@var{spec} @itemx -S @var{spec} Add the symlinks specified by @var{spec} to the pack. This option can diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 33a9616c0d..031a97e91b 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -19,6 +19,7 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu build install) + #:use-module ((guix build union) #:select (relative-file-name)) #:use-module (guix build syscalls) #:use-module (guix build utils) #:use-module (guix build store-copy) @@ -26,6 +27,7 @@ (define-module (gnu build install) #:use-module (ice-9 match) #:export (install-boot-config evaluate-populate-directive + make-symlink->directives populate-root-file-system install-database-and-gc-roots populate-single-profile-directory @@ -124,6 +126,22 @@ (define target* (if (string-suffix? "/" target) directive) (apply throw args))))) +(define (make-symlink->directives directory) + "Return a procedure that turn symlinks specs into directives that target +DIRECTORY." + (match-lambda + ((source '-> target) + (let ((target (string-append directory "/" target)) + (parent (dirname source))) + ;; Never add a 'directory' directive for "/" so as to preserve its + ;; ownership and avoid adding the same entries multiple times. + `(,@(if (string=? parent "/") + '() + `((directory ,parent))) + ;; Note: a relative file name is used for compatibility with + ;; relocatable packs. + (,source -> ,(relative-file-name parent target))))))) + (define (directives store) "Return a list of directives to populate the root file system that will host STORE." diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index de9bc8f98d..7174dd72d2 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -33,8 +33,10 @@ (define-module (guix scripts environment) #:use-module ((guix gexp) #:select (lower-object)) #:use-module (guix scripts) #:use-module (guix scripts build) + #:autoload (guix scripts pack) (symlink-spec-option-parser) #:use-module (guix transformations) #:autoload (ice-9 ftw) (scandir) + #:use-module (gnu build install) #:autoload (gnu build linux-container) (call-with-container %namespaces user-namespace-supported? unprivileged-user-namespace-supported? @@ -120,6 +122,9 @@ (define (show-environment-options-help) --expose=SPEC for containers, expose read-only host file system according to SPEC")) (display (G_ " + -S, --symlink=SPEC for containers, add symlinks to the profile according + to SPEC, e.g. \"/usr/bin/env=bin/env\".")) + (display (G_ " -v, --verbosity=LEVEL use the given verbosity LEVEL")) (display (G_ " --bootstrap use bootstrap binaries to build the environment"))) @@ -157,6 +162,7 @@ (define (show-help) (define %default-options `((system . ,(%current-system)) (substitutes? . #t) + (symlinks . ()) (offload? . #t) (graft? . #t) (print-build-trace? . #t) @@ -256,6 +262,7 @@ (define %options (alist-cons 'file-system-mapping (specification->file-system-mapping arg #f) result))) + (option '(#\S "symlink") #t #f symlink-spec-option-parser) (option '(#\r "root") #t #f (lambda (opt name arg result) (alist-cons 'gc-root arg result))) @@ -672,7 +679,7 @@ (define* (launch-environment/fork command profile manifest (define* (launch-environment/container #:key command bash user user-mappings profile manifest link-profile? network? map-cwd? emulate-fhs? (setup-hook #f) - (white-list '())) + (symlinks '()) (white-list '())) "Run COMMAND within a container that features the software in PROFILE. Environment variables are set according to the search paths of MANIFEST. The global shell is BASH, a file name for a GNU Bash binary in the store. When @@ -690,6 +697,9 @@ (define* (launch-environment/container #:key command bash user user-mappings LINK-PROFILE? creates a symbolic link from ~/.guix-profile to the environment profile. +SYMLINKS must be a list of (SOURCE -> TARGET) tuples denoting symlinks to be +added to the container. + Preserve environment variables whose name matches the one of the regexps in WHILE-LIST." (define (optional-mapping->fs mapping) @@ -797,6 +807,10 @@ (define fhs-mappings (mkdir-p home-dir) (setenv "HOME" home-dir) + ;; Create symlinks. + (for-each (cut evaluate-populate-directive <> ".") + (append-map (make-symlink->directives profile) symlinks)) + ;; Call an additional setup procedure, if provided. (when setup-hook (setup-hook profile)) @@ -970,6 +984,7 @@ (define (guix-environment* opts) (let* ((pure? (assoc-ref opts 'pure)) (container? (assoc-ref opts 'container?)) (link-prof? (assoc-ref opts 'link-profile?)) + (symlinks (assoc-ref opts 'symlinks)) (network? (assoc-ref opts 'network?)) (no-cwd? (assoc-ref opts 'no-cwd?)) (emulate-fhs? (assoc-ref opts 'emulate-fhs?)) @@ -1010,15 +1025,17 @@ (define-syntax-rule (with-store/maybe store exp ...) (when container? (assert-container-features)) - (when (and (not container?) link-prof?) - (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) - (when (and (not container?) user) - (leave (G_ "'--user' cannot be used without '--container'~%"))) - (when (and (not container?) no-cwd?) - (leave (G_ "--no-cwd cannot be used without '--container'~%"))) - (when (and (not container?) emulate-fhs?) - (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) - + (when (not container?) + (when link-prof? + (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) + (when user + (leave (G_ "'--user' cannot be used without '--container'~%"))) + (when no-cwd? + (leave (G_ "--no-cwd cannot be used without '--container'~%"))) + (when emulate-fhs? + (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) + (when (pair? symlinks) + (leave (G_ "'--symlink' cannot be used without '--container~%'")))) (with-store/maybe store (with-status-verbosity (assoc-ref opts 'verbosity) @@ -1099,6 +1116,7 @@ (define manifest #:network? network? #:map-cwd? (not no-cwd?) #:emulate-fhs? emulate-fhs? + #:symlinks symlinks #:setup-hook (and emulate-fhs? setup-fhs)))) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 06849e4761..e3bddc4274 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -61,7 +61,9 @@ (define-module (guix scripts pack) #:use-module (srfi srfi-26) #:use-module (srfi srfi-37) #:use-module (ice-9 match) - #:export (self-contained-tarball + #:export (symlink-spec-option-parser + + self-contained-tarball debian-archive docker-image squashfs-image @@ -160,6 +162,21 @@ (define str (string-join names "-")) ((_) str) ((names ... _) (loop names)))))) +(define (symlink-spec-option-parser opt name arg result) + "A SRFI-37 option parser for the --symlink option." + ;; Note: Using 'string-split' allows us to handle empty + ;; TARGET (as in "/opt/guile=", meaning that /opt/guile is + ;; a symlink to the profile) correctly. + (match (string-split arg (char-set #\=)) + ((source target) + (let ((symlinks (assoc-ref result 'symlinks))) + (alist-cons 'symlinks + `((,source -> ,target) ,@symlinks) + (alist-delete 'symlinks result eq?)))) + (x + (leave (G_ "~a: invalid symlink specification~%") + arg)))) + ;;; ;;; Tarball format. @@ -204,30 +221,15 @@ (define (import-module? module) (use-modules (guix build pack) (guix build store-copy) (guix build utils) - ((guix build union) #:select (relative-file-name)) (gnu build install) (srfi srfi-1) - (srfi srfi-26) - (ice-9 match)) + (srfi srfi-26)) (define %root "root") - (define symlink->directives - ;; Return "populate directives" to make the given symlink and its - ;; parent directories. - (match-lambda - ((source '-> target) - (let ((target (string-append #$profile "/" target)) - (parent (dirname source))) - ;; Never add a 'directory' directive for "/" so as to - ;; preserve its ownership when extracting the archive (see - ;; below), and also because this would lead to adding the - ;; same entries twice in the tarball. - `(,@(if (string=? parent "/") - '() - `((directory ,parent))) - (,source - -> ,(relative-file-name parent target))))))) + ;; Return "populate directives" to make the given symlink and its + ;; parent directories. + (define symlink->directives (make-symlink->directives #$profile)) (define directives ;; Fully-qualified symlinks. @@ -1208,20 +1210,7 @@ (define %options (lambda (opt name arg result) (alist-cons 'compressor (lookup-compressor arg) result))) - (option '(#\S "symlink") #t #f - (lambda (opt name arg result) - ;; Note: Using 'string-split' allows us to handle empty - ;; TARGET (as in "/opt/guile=", meaning that /opt/guile is - ;; a symlink to the profile) correctly. - (match (string-split arg (char-set #\=)) - ((source target) - (let ((symlinks (assoc-ref result 'symlinks))) - (alist-cons 'symlinks - `((,source -> ,target) ,@symlinks) - (alist-delete 'symlinks result eq?)))) - (x - (leave (G_ "~a: invalid symlink specification~%") - arg))))) + (option '(#\S "symlink") #t #f symlink-spec-option-parser) (option '("save-provenance") #f #f (lambda (opt name arg result) (alist-cons 'save-provenance? #t result))) diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index fb2c19b193..b509e52e26 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -241,3 +241,15 @@ guix shell -CF --bootstrap guile-bootstrap glibc \ "glibc-for-fhs") 0 1))' + +# '--symlink' works. +echo "TESTING SYMLINK IN CONTAINER" +guix shell --bootstrap guile-bootstrap --container \ + --symlink=/usr/bin/guile=bin/guile -- \ + /usr/bin/guile --version + +# An invalid symlink spec causes the command to fail. +! guix shell --bootstrap -CS bin/guile=/usr/bin/guile guile-bootstrap -- exit + +# A dangling symlink causes the command to fail. +! guix shell --bootstrap -CS /usr/bin/python=bin/python guile-bootstrap -- exit diff --git a/tests/guix-shell.sh b/tests/guix-shell.sh index 9a6b055264..cb2b53466d 100644 --- a/tests/guix-shell.sh +++ b/tests/guix-shell.sh @@ -32,6 +32,9 @@ export XDG_CONFIG_HOME guix shell --bootstrap --pure guile-bootstrap -- guile --version +# '--symlink' can only be used with --container. +! guix shell --bootstrap guile-bootstrap -S /dummy=bin/guile + # '--ad-hoc' is a thing of the past. ! guix shell --ad-hoc guile-bootstrap -- 2.37.3 ------------=_1668547503-10229-5-- From unknown Sat Jun 21 05:02:58 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Maxim Cournoyer Subject: bug#59163: closed (Re: bug#58812: [PATCH v3 1/4] shell: Detect --symlink spec problems early.) Message-ID: References: <87y1sblxls.fsf@gmail.com> <20221110042351.829-4-maxim.cournoyer@gmail.com> X-Gnu-PR-Message: they-closed 59163 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 59163@debbugs.gnu.org Date: Tue, 15 Nov 2022 21:25:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1668547503-10229-7" This is a multi-part message in MIME format... ------------=_1668547503-10229-7 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #58812: [PATCH v2 4/4] shell: Detect --symlink spec problems early. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 59163@debbugs.gnu.org. --=20 58812: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D58812 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1668547503-10229-7 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 58812-done) by debbugs.gnu.org; 15 Nov 2022 21:25:00 +0000 Received: from localhost ([127.0.0.1]:55399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov3QS-0002ec-2T for submit@debbugs.gnu.org; Tue, 15 Nov 2022 16:25:00 -0500 Received: from mail-qk1-f175.google.com ([209.85.222.175]:46000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov3QP-0002eH-Kk; Tue, 15 Nov 2022 16:24:58 -0500 Received: by mail-qk1-f175.google.com with SMTP id v8so10413531qkg.12; Tue, 15 Nov 2022 13:24:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6On4ymAF8XwbbSSlnrqmfj74U2KxNG9NkiWzr1kjxfQ=; b=SYW2psAZkQvUmKvVYv11rhKuy0o1echY75eG+hlJ4aijMzO4zXx/yKj5/DetUG7Plm MTO0VxL5pNJ522KwulrtX5gHB44Ecq056TeMQdZd6dWgVpaAa56hDC4uZd8KhxUh8CKC PZy9qRuTaSEjZvtdVk0lp9Nu5nCg/9L1kyEaB2QCiwyy1w5toXpM6urPq+3CrgP0NprT wlKxbWn+rlG/CwcQUE2DvL7O7gq8h5sxjJ0zK5wMH10SQx6U9/J64D7XgSKabQureY0+ MWoD3Fm1P7bpS/ga1ImmlemZw+421CalumWcAbFeb3Zm1RaWHLPdAZXl3MnShXWev+Rz sjeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6On4ymAF8XwbbSSlnrqmfj74U2KxNG9NkiWzr1kjxfQ=; b=MoFNAeLGsNAFJNVsnOc/AyPjS0l/F6+KPbphA0qgBVh8Z1/hX/H5KjtSkQVfY2PxYJ ZkSCtHUfcZ/Mq911ASohtyxwbA2aA9pMYUgveLEvBx3i2iTnis9cR+qjzv5TcPGzjO57 OGM319vg1yhJGlLIQgsj33Rtan113uWaKR5oyhaOZQnbY4kFchy6UsM2A1sgsVKIZXIk tqiPVg6GGQPq+iXQP8aCaXu+1I/9tgB4DpPqZgcLRVZk3L8rF53AtBj98ksu7hicTB7w WoVT+pkzTTt1nLZqocco7tpE1ijjIqu0VeLVy7KbnkFXz/KEShj69jnvqC1VY7jiwdOI sPPw== X-Gm-Message-State: ANoB5plCfiLKeRGR/RSrwVFrDOTOvlcmCACvPf8XzVG7xwWzbBzvInZn RjRWTTUVLQsxLBSEVKoyvffjakN+DY+ytw== X-Google-Smtp-Source: AA0mqf5YXpFyR8Zc9+PRUtg/Kgu2id5FuLFmVrUOYpm+vHa9TEo6KAGjXCT56ZfyWL5ISFMW1o+3EA== X-Received: by 2002:a05:620a:51c6:b0:6fa:476:99ec with SMTP id cx6-20020a05620a51c600b006fa047699ecmr16420660qkb.727.1668547491936; Tue, 15 Nov 2022 13:24:51 -0800 (PST) Received: from hurd (dsl-151-98.b2b2c.ca. [66.158.151.98]) by smtp.gmail.com with ESMTPSA id i17-20020ac85c11000000b00397e97baa96sm7890032qti.0.2022.11.15.13.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 13:24:51 -0800 (PST) From: Maxim Cournoyer To: 58812-done@debbugs.gnu.org Subject: Re: bug#58812: [PATCH v3 1/4] shell: Detect --symlink spec problems early. References: <20221027034154.28435-1-maxim.cournoyer@gmail.com> Date: Tue, 15 Nov 2022 16:24:47 -0500 In-Reply-To: <20221027034154.28435-1-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Wed, 26 Oct 2022 23:41:54 -0400") Message-ID: <87y1sblxls.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58812-done Cc: 59164-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, [...] > Makefile.am: Sort EXTRA_DIST entries. > tests: Add a tests/utils.sh support file. > install: Validate symlink target in evaluate-populate-directive. > guix: shell: Add '--symlink' option. > shell: Detect --symlink spec problems early. I've now pushed this series as 8f9588185d, with a news entry added as 47f319f21f. Closing! -- Thanks, Maxim ------------=_1668547503-10229-7 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 10 Nov 2022 04:24:22 +0000 Received: from localhost ([127.0.0.1]:41558 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osz6y-000535-Ox for submit@debbugs.gnu.org; Wed, 09 Nov 2022 23:24:21 -0500 Received: from lists.gnu.org ([209.51.188.17]:52112) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osz6t-00052a-9i for submit@debbugs.gnu.org; Wed, 09 Nov 2022 23:24:17 -0500 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 1osz6s-00046w-Ic for guix-patches@gnu.org; Wed, 09 Nov 2022 23:24:15 -0500 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osz6p-0006mf-Pm for guix-patches@gnu.org; Wed, 09 Nov 2022 23:24:14 -0500 Received: by mail-qk1-x735.google.com with SMTP id v8so486022qkg.12 for ; Wed, 09 Nov 2022 20:24:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=eor9LWxTKeGMVCJ5LjFJhfGhvz5uVx3IkChxdnJf8Q0=; b=BYMDqrIvUiKHars7qN9wNdAqFvpQKc3yJCN30kPS/E75WP7o7L+OLt3UhfqRmabTSu 6bb9FMHSs/Mk8M3m3wVNqxgGf2xT9XZPLDdP0u4iCubgXjIOvChw9EdcXgkdY5wtrVtZ 5LkirNI3P7Sn60fzruqDLFqYusehVUJR+I6MpG8aoyPbRR+WG1BwOd2pKFt2kJYxJdRi tUUOh2wcDfBNNIQpY3h/J8wTUdPWbK5AcDtiincLyMNovEH5PMM9r1hjGaT15HQpEZaW 6fQLcVKLXPLQcvws+CH0TxTiqzfdptHZeLEZlpoY9oJdtY/uIblPGfG/awgUkBpQctmS P3qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=eor9LWxTKeGMVCJ5LjFJhfGhvz5uVx3IkChxdnJf8Q0=; b=YnW3gOT24P9gQ1iavBl9D2LzvCu8MRTJf/Wu7DWKVIraK0+iesPtaAM2QAaOx+yiIQ PCtrMCtL/aO2cM6+0T3tMhWadcV4Pl2p0RmwaQecqpu+m01kB7OgznXvedKyCAsaI6tr lwsFRXRBIAg7VmIEb/OOPzljh6Fu8fBuQkZiBtimXE2jh3kgrValhZIdV8yovlCuNquo qJknZ83zm70FsDP4TBFUpeaPyTeYA+iUjS63UpGRiZGAR5rHBcvKqt//n7rxIo35RYEZ zbQlACdLWAE9aYHVNVJ1vmrbnznw3EzkpHGtIuKs0nvVuvgg0bKCx1ntFfkH+c6xpCht kH/Q== X-Gm-Message-State: ACrzQf2Gjyyb34uDk61GeLr1I3csBpv0tdoi+EcSq0cBgVnrhJ4WBzu2 CW2ps+cyB+vRfer+vX5R2oDJE7fO4ZA= X-Google-Smtp-Source: AMsMyM5pp58ovmT7UIGmbamUcVSZ/+ZKRBi0LpDCJfi9W7DaRZF44PvXEbNbQcRwvepYW82wNitPHg== X-Received: by 2002:ae9:dfc5:0:b0:6f9:f70f:b4ab with SMTP id t188-20020ae9dfc5000000b006f9f70fb4abmr46075893qkf.528.1668054250322; Wed, 09 Nov 2022 20:24:10 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id r1-20020ac85e81000000b0039cc7ebf46bsm10515105qtx.93.2022.11.09.20.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 20:24:09 -0800 (PST) From: Maxim Cournoyer To: guix-patches@gnu.org Subject: [PATCH v2 4/4] shell: Detect --symlink spec problems early. Date: Wed, 9 Nov 2022 23:23:51 -0500 Message-Id: <20221110042351.829-4-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221110042351.829-1-maxim.cournoyer@gmail.com> References: <87h6z7omzy.fsf_-_@gnu.org> <20221110042351.829-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qk1-x735.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * guix/scripts/pack.scm (symlink-spec-option-parser): Remove extraneous char-set. Raise an exception when the target is an absolute file name. (guix-pack): Move with-error-handler earlier. * guix/scripts/shell.scm (guix-shell): Likewise. * guix/scripts/environment.scm (guix-environment): Wrap the whole guix-environment* call with the with-error-handling handler. * tests/guix-shell.sh: Add test. * tests/guix-pack.sh: Adjust symlink spec. --- guix/scripts/environment.scm | 294 +++++++++++++++++------------------ guix/scripts/pack.scm | 155 ++++++++++-------- guix/scripts/shell.scm | 77 ++++----- tests/guix-pack.sh | 2 +- 4 files changed, 273 insertions(+), 255 deletions(-) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 7174dd72d2..ce299c4533 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -975,158 +975,158 @@ (define-command (guix-environment . args) (category development) (synopsis "spawn one-off software environments (deprecated)") - (guix-environment* (parse-args args))) + (with-error-handling + (guix-environment* (parse-args args)))) (define (guix-environment* opts) "Run the 'guix environment' command on OPTS, an alist resulting for command-line option processing with 'parse-command-line'." - (with-error-handling - (let* ((pure? (assoc-ref opts 'pure)) - (container? (assoc-ref opts 'container?)) - (link-prof? (assoc-ref opts 'link-profile?)) - (symlinks (assoc-ref opts 'symlinks)) - (network? (assoc-ref opts 'network?)) - (no-cwd? (assoc-ref opts 'no-cwd?)) - (emulate-fhs? (assoc-ref opts 'emulate-fhs?)) - (user (assoc-ref opts 'user)) - (bootstrap? (assoc-ref opts 'bootstrap?)) - (system (assoc-ref opts 'system)) - (profile (assoc-ref opts 'profile)) - (command (or (assoc-ref opts 'exec) - ;; Spawn a shell if the user didn't specify - ;; anything in particular. - (if container? - ;; The user's shell is likely not available - ;; within the container. - '("/bin/sh") - (list %default-shell)))) - (mappings (pick-all opts 'file-system-mapping)) - (white-list (pick-all opts 'inherit-regexp))) - - (define store-needed? - ;; Whether connecting to the daemon is needed. - (or container? (not profile))) - - (define-syntax-rule (with-store/maybe store exp ...) - ;; Evaluate EXP... with STORE bound to a connection, unless - ;; STORE-NEEDED? is false, in which case STORE is bound to #f. - (let ((proc (lambda (store) exp ...))) - (if store-needed? - (with-store s - (set-build-options-from-command-line s opts) - (with-build-handler (build-notifier #:use-substitutes? - (assoc-ref opts 'substitutes?) - #:verbosity - (assoc-ref opts 'verbosity) - #:dry-run? - (assoc-ref opts 'dry-run?)) - (proc s))) - (proc #f)))) - - (when container? (assert-container-features)) - - (when (not container?) - (when link-prof? - (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) - (when user - (leave (G_ "'--user' cannot be used without '--container'~%"))) - (when no-cwd? - (leave (G_ "--no-cwd cannot be used without '--container'~%"))) - (when emulate-fhs? - (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) - (when (pair? symlinks) - (leave (G_ "'--symlink' cannot be used without '--container~%'")))) - - (with-store/maybe store - (with-status-verbosity (assoc-ref opts 'verbosity) - (define manifest-from-opts - (options/resolve-packages store opts)) - - (define manifest - (if profile - (profile-manifest profile) - manifest-from-opts)) - - (when (and profile - (> (length (manifest-entries manifest-from-opts)) 0)) - (leave (G_ "'--profile' cannot be used with package options~%"))) - - (when (null? (manifest-entries manifest)) - (warning (G_ "no packages specified; creating an empty environment~%"))) - - ;; Use the bootstrap Guile when requested. - (parameterize ((%graft? (assoc-ref opts 'graft?)) - (%guile-for-build - (and store-needed? - (package-derivation - store - (if bootstrap? - %bootstrap-guile - (default-guile)))))) - (run-with-store store - ;; Containers need a Bourne shell at /bin/sh. - (mlet* %store-monad ((bash (environment-bash container? - bootstrap? - system)) - (prof-drv (if profile - (return #f) - (manifest->derivation - manifest system bootstrap?))) - (profile -> (if profile - (readlink* profile) - (derivation->output-path prof-drv))) - (gc-root -> (assoc-ref opts 'gc-root))) - - ;; First build the inputs. This is necessary even for - ;; --search-paths. Additionally, we might need to build bash for - ;; a container. - (mbegin %store-monad - (mwhen store-needed? - (built-derivations (append - (if prof-drv (list prof-drv) '()) - (if (derivation? bash) (list bash) '())))) - (mwhen gc-root - (register-gc-root profile gc-root)) - - (mwhen (assoc-ref opts 'check?) - (return - (if container? - (warning (G_ "'--check' is unnecessary \ + (let* ((pure? (assoc-ref opts 'pure)) + (container? (assoc-ref opts 'container?)) + (link-prof? (assoc-ref opts 'link-profile?)) + (symlinks (assoc-ref opts 'symlinks)) + (network? (assoc-ref opts 'network?)) + (no-cwd? (assoc-ref opts 'no-cwd?)) + (emulate-fhs? (assoc-ref opts 'emulate-fhs?)) + (user (assoc-ref opts 'user)) + (bootstrap? (assoc-ref opts 'bootstrap?)) + (system (assoc-ref opts 'system)) + (profile (assoc-ref opts 'profile)) + (command (or (assoc-ref opts 'exec) + ;; Spawn a shell if the user didn't specify + ;; anything in particular. + (if container? + ;; The user's shell is likely not available + ;; within the container. + '("/bin/sh") + (list %default-shell)))) + (mappings (pick-all opts 'file-system-mapping)) + (white-list (pick-all opts 'inherit-regexp))) + + (define store-needed? + ;; Whether connecting to the daemon is needed. + (or container? (not profile))) + + (define-syntax-rule (with-store/maybe store exp ...) + ;; Evaluate EXP... with STORE bound to a connection, unless + ;; STORE-NEEDED? is false, in which case STORE is bound to #f. + (let ((proc (lambda (store) exp ...))) + (if store-needed? + (with-store s + (set-build-options-from-command-line s opts) + (with-build-handler (build-notifier #:use-substitutes? + (assoc-ref opts 'substitutes?) + #:verbosity + (assoc-ref opts 'verbosity) + #:dry-run? + (assoc-ref opts 'dry-run?)) + (proc s))) + (proc #f)))) + + (when container? (assert-container-features)) + + (when (not container?) + (when link-prof? + (leave (G_ "'--link-profile' cannot be used without '--container'~%"))) + (when user + (leave (G_ "'--user' cannot be used without '--container'~%"))) + (when no-cwd? + (leave (G_ "--no-cwd cannot be used without '--container'~%"))) + (when emulate-fhs? + (leave (G_ "'--emulate-fhs' cannot be used without '--container~%'"))) + (when (pair? symlinks) + (leave (G_ "'--symlink' cannot be used without '--container~%'")))) + + (with-store/maybe store + (with-status-verbosity (assoc-ref opts 'verbosity) + (define manifest-from-opts + (options/resolve-packages store opts)) + + (define manifest + (if profile + (profile-manifest profile) + manifest-from-opts)) + + (when (and profile + (> (length (manifest-entries manifest-from-opts)) 0)) + (leave (G_ "'--profile' cannot be used with package options~%"))) + + (when (null? (manifest-entries manifest)) + (warning (G_ "no packages specified; creating an empty environment~%"))) + + ;; Use the bootstrap Guile when requested. + (parameterize ((%graft? (assoc-ref opts 'graft?)) + (%guile-for-build + (and store-needed? + (package-derivation + store + (if bootstrap? + %bootstrap-guile + (default-guile)))))) + (run-with-store store + ;; Containers need a Bourne shell at /bin/sh. + (mlet* %store-monad ((bash (environment-bash container? + bootstrap? + system)) + (prof-drv (if profile + (return #f) + (manifest->derivation + manifest system bootstrap?))) + (profile -> (if profile + (readlink* profile) + (derivation->output-path prof-drv))) + (gc-root -> (assoc-ref opts 'gc-root))) + + ;; First build the inputs. This is necessary even for + ;; --search-paths. Additionally, we might need to build bash for + ;; a container. + (mbegin %store-monad + (mwhen store-needed? + (built-derivations (append + (if prof-drv (list prof-drv) '()) + (if (derivation? bash) (list bash) '())))) + (mwhen gc-root + (register-gc-root profile gc-root)) + + (mwhen (assoc-ref opts 'check?) + (return + (if container? + (warning (G_ "'--check' is unnecessary \ when using '--container'; doing nothing~%")) - (validate-child-shell-environment profile manifest)))) - - (cond - ((assoc-ref opts 'search-paths) - (show-search-paths profile manifest #:pure? pure?) - (return #t)) - (container? - (let ((bash-binary - (if bootstrap? - (derivation->output-path bash) - (string-append (derivation->output-path bash) - "/bin/sh")))) - (launch-environment/container #:command command - #:bash bash-binary - #:user user - #:user-mappings mappings - #:profile profile - #:manifest manifest - #:white-list white-list - #:link-profile? link-prof? - #:network? network? - #:map-cwd? (not no-cwd?) - #:emulate-fhs? emulate-fhs? - #:symlinks symlinks - #:setup-hook - (and emulate-fhs? - setup-fhs)))) - - (else - (return - (exit/status - (launch-environment/fork command profile manifest - #:white-list white-list - #:pure? pure?)))))))))))))) + (validate-child-shell-environment profile manifest)))) + + (cond + ((assoc-ref opts 'search-paths) + (show-search-paths profile manifest #:pure? pure?) + (return #t)) + (container? + (let ((bash-binary + (if bootstrap? + (derivation->output-path bash) + (string-append (derivation->output-path bash) + "/bin/sh")))) + (launch-environment/container #:command command + #:bash bash-binary + #:user user + #:user-mappings mappings + #:profile profile + #:manifest manifest + #:white-list white-list + #:link-profile? link-prof? + #:network? network? + #:map-cwd? (not no-cwd?) + #:emulate-fhs? emulate-fhs? + #:symlinks symlinks + #:setup-hook + (and emulate-fhs? + setup-fhs)))) + + (else + (return + (exit/status + (launch-environment/fork command profile manifest + #:white-list white-list + #:pure? pure?))))))))))))) ;;; Local Variables: ;;; eval: (put 'with-store/maybe 'scheme-indent-function 1) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index e3bddc4274..a101900736 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -42,6 +42,7 @@ (define-module (guix scripts pack) #:use-module (guix profiles) #:use-module (guix describe) #:use-module (guix derivations) + #:use-module (guix diagnostics) #:use-module (guix search-paths) #:use-module (guix build-system gnu) #:use-module (guix scripts build) @@ -59,6 +60,7 @@ (define-module (guix scripts pack) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-35) #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:export (symlink-spec-option-parser @@ -163,12 +165,27 @@ (define str (string-join names "-")) ((names ... _) (loop names)))))) (define (symlink-spec-option-parser opt name arg result) - "A SRFI-37 option parser for the --symlink option." + "A SRFI-37 option parser for the --symlink option. The symlink spec accepts +the link file name as its left-hand side value and its target as its +right-hand side value. The target must be a relative link." ;; Note: Using 'string-split' allows us to handle empty ;; TARGET (as in "/opt/guile=", meaning that /opt/guile is ;; a symlink to the profile) correctly. - (match (string-split arg (char-set #\=)) + (match (string-split arg #\=) ((source target) + (when (string-prefix? "/" target) + (raise-exception + (make-compound-condition + (formatted-message (G_ "symlink target is absolute: '~a'~%") target) + (condition + (&fix-hint (hint (format #f (G_ "The target of the symlink must be +relative rather than absolute, as it is relative to the profile created. +Perhaps the source and target components of the symlink spec were inverted? +Below is a valid example, where the @file{/usr/bin/env} symbolic link is to +target the profile's @file{bin/env} file: +@example +--symlink=/usr/bin/env=bin/env +@end example")))))))) (let ((symlinks (assoc-ref result 'symlinks))) (alist-cons 'symlinks `((,source -> ,target) ,@symlinks) @@ -1310,74 +1327,74 @@ (define-command (guix-pack . args) (category development) (synopsis "create application bundles") - (define opts - (parse-command-line args %options (list %default-options))) - - (define maybe-package-argument - ;; Given an option pair, return a package, a package/output tuple, or #f. - (match-lambda - (('argument . spec) - (call-with-values - (lambda () - (specification->package+output spec)) - list)) - (('expression . exp) - (read/eval-package-expression exp)) - (x #f))) - - (define (manifest-from-args store opts) - (let* ((transform (options->transformation opts)) - (packages (map (match-lambda - (((? package? package) output) - (list (transform package) output)) - ((? package? package) - (list (transform package) "out"))) - (reverse - (filter-map maybe-package-argument opts)))) - (manifests (filter-map (match-lambda - (('manifest . file) file) - (_ #f)) - opts))) - (define with-provenance - (if (assoc-ref opts 'save-provenance?) - (lambda (manifest) - (map-manifest-entries - (lambda (entry) - (let ((entry (manifest-entry-with-provenance entry))) - (unless (assq 'provenance (manifest-entry-properties entry)) - (warning (G_ "could not determine provenance of package ~a~%") - (manifest-entry-name entry))) - entry)) - manifest)) - identity)) - - (with-provenance - (cond - ((and (not (null? manifests)) (not (null? packages))) - (leave (G_ "both a manifest and a package list were given~%"))) - ((not (null? manifests)) - (concatenate-manifests - (map (lambda (file) - (let ((user-module (make-user-module - '((guix profiles) (gnu))))) - (load* file user-module))) - manifests))) - (else - (packages->manifest packages)))))) - - (define (process-file-arg opts name) - ;; Validate that the file exists and return it as a object, - ;; else #f. - (let ((value (assoc-ref opts name))) - (match value - ((and (? string?) (not (? file-exists?))) - (leave (G_ "file provided with option ~a does not exist: ~a~%") - (string-append "--" (symbol->string name)) value)) - ((? string?) - (local-file value)) - (#f #f)))) - (with-error-handling + (define opts + (parse-command-line args %options (list %default-options))) + + (define maybe-package-argument + ;; Given an option pair, return a package, a package/output tuple, or #f. + (match-lambda + (('argument . spec) + (call-with-values + (lambda () + (specification->package+output spec)) + list)) + (('expression . exp) + (read/eval-package-expression exp)) + (x #f))) + + (define (manifest-from-args store opts) + (let* ((transform (options->transformation opts)) + (packages (map (match-lambda + (((? package? package) output) + (list (transform package) output)) + ((? package? package) + (list (transform package) "out"))) + (reverse + (filter-map maybe-package-argument opts)))) + (manifests (filter-map (match-lambda + (('manifest . file) file) + (_ #f)) + opts))) + (define with-provenance + (if (assoc-ref opts 'save-provenance?) + (lambda (manifest) + (map-manifest-entries + (lambda (entry) + (let ((entry (manifest-entry-with-provenance entry))) + (unless (assq 'provenance (manifest-entry-properties entry)) + (warning (G_ "could not determine provenance of package ~a~%") + (manifest-entry-name entry))) + entry)) + manifest)) + identity)) + + (with-provenance + (cond + ((and (not (null? manifests)) (not (null? packages))) + (leave (G_ "both a manifest and a package list were given~%"))) + ((not (null? manifests)) + (concatenate-manifests + (map (lambda (file) + (let ((user-module (make-user-module + '((guix profiles) (gnu))))) + (load* file user-module))) + manifests))) + (else + (packages->manifest packages)))))) + + (define (process-file-arg opts name) + ;; Validate that the file exists and return it as a object, + ;; else #f. + (let ((value (assoc-ref opts name))) + (match value + ((and (? string?) (not (? file-exists?))) + (leave (G_ "file provided with option ~a does not exist: ~a~%") + (string-append "--" (symbol->string name)) value)) + ((? string?) + (local-file value)) + (#f #f)))) + (with-store store (with-status-verbosity (assoc-ref opts 'verbosity) ;; Set the build options before we do anything else. diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm index 7a379122ae..2fc1dc942a 100644 --- a/guix/scripts/shell.scm +++ b/guix/scripts/shell.scm @@ -534,43 +534,44 @@ (define-command (guix-shell . args) (category development) (synopsis "spawn one-off software environments") - (define (cache-entries directory) - (filter-map (match-lambda - ((or "." "..") #f) - (file (string-append directory "/" file))) - (or (scandir directory) '()))) - - (define* (entry-expiration file) - ;; Return the time at which FILE, a cached profile, is considered expired. - (match (false-if-exception (lstat file)) - (#f 0) ;FILE may have been deleted in the meantime - (st (+ (stat:atime st) (* 60 60 24 7))))) - - (define opts - (parse-args args)) - - (define interactive? - (not (assoc-ref opts 'exec))) - - (if (assoc-ref opts 'check?) - (record-hint 'shell-check) - (when (and interactive? - (not (hint-given? 'shell-check)) - (not (assoc-ref opts 'container?)) - (not (assoc-ref opts 'search-paths))) - (display-hint (G_ "Consider passing the @option{--check} option once + (with-error-handling + (define (cache-entries directory) + (filter-map (match-lambda + ((or "." "..") #f) + (file (string-append directory "/" file))) + (or (scandir directory) '()))) + + (define* (entry-expiration file) + ;; Return the time at which FILE, a cached profile, is considered expired. + (match (false-if-exception (lstat file)) + (#f 0) ;FILE may have been deleted in the meantime + (st (+ (stat:atime st) (* 60 60 24 7))))) + + (define opts + (parse-args args)) + + (define interactive? + (not (assoc-ref opts 'exec))) + + (if (assoc-ref opts 'check?) + (record-hint 'shell-check) + (when (and interactive? + (not (hint-given? 'shell-check)) + (not (assoc-ref opts 'container?)) + (not (assoc-ref opts 'search-paths))) + (display-hint (G_ "Consider passing the @option{--check} option once to make sure your shell does not clobber environment variables."))) ) - ;; Clean the cache in EXIT-HOOK so that (1) it happens after potential use - ;; of cached profiles, and (2) cleanup actually happens, even when - ;; 'guix-environment*' calls 'exit'. - (add-hook! exit-hook - (lambda _ - (maybe-remove-expired-cache-entries - (%profile-cache-directory) - cache-entries - #:entry-expiration entry-expiration))) - - (if (assoc-ref opts 'export-manifest?) - (export-manifest opts (current-output-port)) - (guix-environment* opts))) + ;; Clean the cache in EXIT-HOOK so that (1) it happens after potential use + ;; of cached profiles, and (2) cleanup actually happens, even when + ;; 'guix-environment*' calls 'exit'. + (add-hook! exit-hook + (lambda _ + (maybe-remove-expired-cache-entries + (%profile-cache-directory) + cache-entries + #:entry-expiration entry-expiration))) + + (if (assoc-ref opts 'export-manifest?) + (export-manifest opts (current-output-port)) + (guix-environment* opts)))) diff --git a/tests/guix-pack.sh b/tests/guix-pack.sh index f19a0f754e..6fc9e3723b 100644 --- a/tests/guix-pack.sh +++ b/tests/guix-pack.sh @@ -103,7 +103,7 @@ fi guix pack --dry-run --bootstrap -f docker guile-bootstrap # Build a Docker image with a symlink. -guix pack --dry-run --bootstrap -f docker -S /opt/gnu=/ guile-bootstrap +guix pack --dry-run --bootstrap -f docker -S /opt/gnu= guile-bootstrap # Build a tarball pack of cross-compiled software. Use coreutils because # guile-bootstrap is not intended to be cross-compiled. -- 2.37.3 ------------=_1668547503-10229-7-- From unknown Sat Jun 21 05:02:58 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Maxim Cournoyer Subject: bug#59164: closed (Re: bug#58812: [PATCH v3 1/4] shell: Detect --symlink spec problems early.) Message-ID: References: <87y1sblxls.fsf@gmail.com> <20221110042351.829-1-maxim.cournoyer@gmail.com> X-Gnu-PR-Message: they-closed 59164 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 59164@debbugs.gnu.org Date: Tue, 15 Nov 2022 21:25:04 +0000 Content-Type: multipart/mixed; boundary="----------=_1668547504-10229-9" This is a multi-part message in MIME format... ------------=_1668547504-10229-9 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #58812: [PATCH v2 1/4] Makefile.am: Sort EXTRA_DIST entries. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 59164@debbugs.gnu.org. --=20 58812: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D58812 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1668547504-10229-9 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 58812-done) by debbugs.gnu.org; 15 Nov 2022 21:25:00 +0000 Received: from localhost ([127.0.0.1]:55399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov3QS-0002ec-2T for submit@debbugs.gnu.org; Tue, 15 Nov 2022 16:25:00 -0500 Received: from mail-qk1-f175.google.com ([209.85.222.175]:46000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov3QP-0002eH-Kk; Tue, 15 Nov 2022 16:24:58 -0500 Received: by mail-qk1-f175.google.com with SMTP id v8so10413531qkg.12; Tue, 15 Nov 2022 13:24:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6On4ymAF8XwbbSSlnrqmfj74U2KxNG9NkiWzr1kjxfQ=; b=SYW2psAZkQvUmKvVYv11rhKuy0o1echY75eG+hlJ4aijMzO4zXx/yKj5/DetUG7Plm MTO0VxL5pNJ522KwulrtX5gHB44Ecq056TeMQdZd6dWgVpaAa56hDC4uZd8KhxUh8CKC PZy9qRuTaSEjZvtdVk0lp9Nu5nCg/9L1kyEaB2QCiwyy1w5toXpM6urPq+3CrgP0NprT wlKxbWn+rlG/CwcQUE2DvL7O7gq8h5sxjJ0zK5wMH10SQx6U9/J64D7XgSKabQureY0+ MWoD3Fm1P7bpS/ga1ImmlemZw+421CalumWcAbFeb3Zm1RaWHLPdAZXl3MnShXWev+Rz sjeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6On4ymAF8XwbbSSlnrqmfj74U2KxNG9NkiWzr1kjxfQ=; b=MoFNAeLGsNAFJNVsnOc/AyPjS0l/F6+KPbphA0qgBVh8Z1/hX/H5KjtSkQVfY2PxYJ ZkSCtHUfcZ/Mq911ASohtyxwbA2aA9pMYUgveLEvBx3i2iTnis9cR+qjzv5TcPGzjO57 OGM319vg1yhJGlLIQgsj33Rtan113uWaKR5oyhaOZQnbY4kFchy6UsM2A1sgsVKIZXIk tqiPVg6GGQPq+iXQP8aCaXu+1I/9tgB4DpPqZgcLRVZk3L8rF53AtBj98ksu7hicTB7w WoVT+pkzTTt1nLZqocco7tpE1ijjIqu0VeLVy7KbnkFXz/KEShj69jnvqC1VY7jiwdOI sPPw== X-Gm-Message-State: ANoB5plCfiLKeRGR/RSrwVFrDOTOvlcmCACvPf8XzVG7xwWzbBzvInZn RjRWTTUVLQsxLBSEVKoyvffjakN+DY+ytw== X-Google-Smtp-Source: AA0mqf5YXpFyR8Zc9+PRUtg/Kgu2id5FuLFmVrUOYpm+vHa9TEo6KAGjXCT56ZfyWL5ISFMW1o+3EA== X-Received: by 2002:a05:620a:51c6:b0:6fa:476:99ec with SMTP id cx6-20020a05620a51c600b006fa047699ecmr16420660qkb.727.1668547491936; Tue, 15 Nov 2022 13:24:51 -0800 (PST) Received: from hurd (dsl-151-98.b2b2c.ca. [66.158.151.98]) by smtp.gmail.com with ESMTPSA id i17-20020ac85c11000000b00397e97baa96sm7890032qti.0.2022.11.15.13.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 13:24:51 -0800 (PST) From: Maxim Cournoyer To: 58812-done@debbugs.gnu.org Subject: Re: bug#58812: [PATCH v3 1/4] shell: Detect --symlink spec problems early. References: <20221027034154.28435-1-maxim.cournoyer@gmail.com> Date: Tue, 15 Nov 2022 16:24:47 -0500 In-Reply-To: <20221027034154.28435-1-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Wed, 26 Oct 2022 23:41:54 -0400") Message-ID: <87y1sblxls.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58812-done Cc: 59164-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, [...] > Makefile.am: Sort EXTRA_DIST entries. > tests: Add a tests/utils.sh support file. > install: Validate symlink target in evaluate-populate-directive. > guix: shell: Add '--symlink' option. > shell: Detect --symlink spec problems early. I've now pushed this series as 8f9588185d, with a news entry added as 47f319f21f. Closing! -- Thanks, Maxim ------------=_1668547504-10229-9 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 10 Nov 2022 04:24:23 +0000 Received: from localhost ([127.0.0.1]:41560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osz70-00053J-Ug for submit@debbugs.gnu.org; Wed, 09 Nov 2022 23:24:23 -0500 Received: from lists.gnu.org ([209.51.188.17]:52128) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osz6x-00052v-21 for submit@debbugs.gnu.org; Wed, 09 Nov 2022 23:24:19 -0500 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 1osz6v-00048b-ST for guix-patches@gnu.org; Wed, 09 Nov 2022 23:24:18 -0500 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osz6n-0006mD-Gl for guix-patches@gnu.org; Wed, 09 Nov 2022 23:24:17 -0500 Received: by mail-qt1-x82c.google.com with SMTP id fz10so399070qtb.3 for ; Wed, 09 Nov 2022 20:24:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=XGrPvhQ/9qGJmUplPfL27tDsvHuvx+A+Tne09I59vJU=; b=aPYZ11GzJPv5zxE0si5ZDV0SvG7bF0KYOvZrRhfBK+L4m8gl5upvKmFaLyPYCPSO0s KFxWo6waaS8so06zR+ax+v/PAIrnD7icIJbb5xgRw8vybw+a6v2myhjwVTFa+/T2NdpI 49zyD1XfjP10uxReedVnIDaXPYTDEcHNzcdScOMhmgc9p/7sdT0dKV5AHWqt0ezhPsxT LnSIHZx7gOKqqInTOzIkRF/N7Uj150ElD/Z1WiSR/TpzlkVgX9cJCSMt/PBihi7bTQbi cWTSmVfEhali6Xyk9pVlaDw2lj4H2jpvV0+qStVk8B7eVmNGLDIOao3ZwNLU0+exzYOK lCEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=XGrPvhQ/9qGJmUplPfL27tDsvHuvx+A+Tne09I59vJU=; b=qVitUaW8FFJDlmIcBYyJ3/K2PoLosVL7seiXC59DnkEGa5T7HSxmVrEV0UKyG85YT9 3PIO2WKDK5uihrfz2KF0Ib9rZPr8AgjdtywGS2R34mlrJuGG0a079czdI6vv5ahUvnKO FE4aicvuaFuGapz0d1qv2pZwIytgfMO7CVNflDOSLwEc2bEeuOZIUrQeKp1BCZUG4lqU Fptd4WdaOPcukr9ay2N7DRl8tAEgAvjIQ5Qmso3j4z+UgPC+rHjf4LMJTVVSs6DuSaaW rRHdHelcrFF0uoDHVgHUBXpGykR+AUDxWsxBBcoCD/Eb9ZoLYB+20U0DFG7/dNXU/5a8 wFEw== X-Gm-Message-State: ACrzQf1/ty8RCWusMBbhEzn1G5QeLsi+k07tbgAAwtkkas/KWi3Q6bBK qNviTxDbIMbipT1AqQGetqN0PX3b2ew= X-Google-Smtp-Source: AMsMyM5aRRjFZl0pyIuIHnGtGUrFdhWZQb0Rl1UvFkPBRrQJgj4wb5Qh0lKdA/ZFxIt7gorfNbvxUw== X-Received: by 2002:a05:622a:116:b0:3a5:7422:112 with SMTP id u22-20020a05622a011600b003a574220112mr21947360qtw.429.1668054248018; Wed, 09 Nov 2022 20:24:08 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id r1-20020ac85e81000000b0039cc7ebf46bsm10515105qtx.93.2022.11.09.20.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 20:24:07 -0800 (PST) From: Maxim Cournoyer To: guix-patches@gnu.org Subject: [PATCH v2 1/4] Makefile.am: Sort EXTRA_DIST entries. Date: Wed, 9 Nov 2022 23:23:48 -0500 Message-Id: <20221110042351.829-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <87h6z7omzy.fsf_-_@gnu.org> References: <87h6z7omzy.fsf_-_@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::82c; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x82c.google.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URI_HEX=0.1 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.2 (-) X-Debbugs-Envelope-To: submit Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.2 (--) * Makefile.am (EXTRA_DIST): Sort. --- Makefile.am | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Makefile.am b/Makefile.am index 47886721fa..c3af23b68e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -660,49 +660,49 @@ dist_fishcompletion_DATA = etc/completion/fish/guix.fish nodist_selinux_policy_DATA = etc/guix-daemon.cil EXTRA_DIST += \ - HACKING \ - ROADMAP \ - TODO \ - CODE-OF-CONDUCT \ .dir-locals.el \ .guix-authorizations \ .guix-channel \ - scripts/guix.in \ - etc/disarchive-manifest.scm \ - etc/guix-install.sh \ - etc/news.scm \ - etc/release-manifest.scm \ - etc/source-manifest.scm \ - etc/system-tests.scm \ - etc/time-travel-manifest.scm \ - etc/historical-authorizations \ + CODE-OF-CONDUCT \ + HACKING \ + ROADMAP \ + TODO \ + bootstrap \ build-aux/build-self.scm \ - build-aux/compile-all.scm \ - build-aux/cuirass/hurd-manifest.scm \ - build-aux/check-final-inputs-self-contained.scm \ build-aux/check-channel-news.scm \ + build-aux/check-final-inputs-self-contained.scm \ + build-aux/compile-all.scm \ build-aux/compile-as-derivation.scm \ + build-aux/config.rpath \ build-aux/convert-xref.scm \ + build-aux/cuirass/hurd-manifest.scm \ build-aux/generate-authors.scm \ build-aux/test-driver.scm \ - build-aux/update-guix-package.scm \ build-aux/update-NEWS.scm \ - tests/test.drv \ + build-aux/update-guix-package.scm \ + doc/build.scm \ + etc/disarchive-manifest.scm \ + etc/guix-install.sh \ + etc/historical-authorizations \ + etc/news.scm \ + etc/release-manifest.scm \ + etc/source-manifest.scm \ + etc/system-tests.scm \ + etc/time-travel-manifest.scm \ + scripts/guix.in \ tests/cve-sample.json \ - tests/keys/signing-key.pub \ - tests/keys/signing-key.sec \ tests/keys/civodul.pub \ - tests/keys/rsa.pub \ tests/keys/dsa.pub \ - tests/keys/ed25519.pub \ - tests/keys/ed25519.sec \ tests/keys/ed25519-2.pub \ tests/keys/ed25519-2.sec \ tests/keys/ed25519-3.pub \ tests/keys/ed25519-3.sec \ - build-aux/config.rpath \ - bootstrap \ - doc/build.scm \ + tests/keys/ed25519.pub \ + tests/keys/ed25519.sec \ + tests/keys/rsa.pub \ + tests/keys/signing-key.pub \ + tests/keys/signing-key.sec \ + tests/test.drv \ $(TESTS) if !BUILD_DAEMON_OFFLOAD -- 2.37.3 ------------=_1668547504-10229-9-- From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 16 Nov 2022 19:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Maxim Cournoyer Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166862574519801 (code B ref 58812); Wed, 16 Nov 2022 19:10:02 +0000 Received: (at 58812) by debbugs.gnu.org; 16 Nov 2022 19:09:05 +0000 Received: from localhost ([127.0.0.1]:58143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovNmT-00059J-FZ for submit@debbugs.gnu.org; Wed, 16 Nov 2022 14:09:05 -0500 Received: from mail-wr1-f50.google.com ([209.85.221.50]:39676) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovNmR-00058p-5B for 58812@debbugs.gnu.org; Wed, 16 Nov 2022 14:09:04 -0500 Received: by mail-wr1-f50.google.com with SMTP id o4so31384269wrq.6 for <58812@debbugs.gnu.org>; Wed, 16 Nov 2022 11:09:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=W1OaS1w3X1jklItMzuSs+SGNLr+6KhP+5CiBlA0DNc4=; b=LgemWf5YvarlESuRcIfyAVLZIWaCwu/gL4yIt6VItC1ojW9i1duC+EJtrmO1QutwZ2 LhfNmzc2b4g+eM6FTUDgToyx9ihnnWD/wGlqF6b98CvcaAlAp2G/LWxnKNXKOHpZPxeG wo6cxsu/yAILhSqZSwsms4RTx4hK1j+QEVqWABfUJfR4qaD8uO5Mvh1e3z/loG7Q0mTR +tQ7TjSGdmuae2l37yPwPCGp5vsE8u09DxbFMEpZqv74fzQIxj1APMeA/9ZlJoieQKkM aw/3+LGTjw2aMAjsrl6+QNFHS2fSgoqZlyi4O66+ycDkPv4r5Ezbdb3bV3QK9pPfVkxA blBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=W1OaS1w3X1jklItMzuSs+SGNLr+6KhP+5CiBlA0DNc4=; b=GovNm3JyuUYinadYd0sBBB7SgCN1DwGiOsu489tyQghSPltbvs9Tpj4RvzRJrhnBUr J9U1SeAXPISxGCDpCDqEIBydvcSZGxheROnGt5Aff6fErlqWvhsNEYUB+rL5QRAyNAiM p3Vm3JGEfFPXogEDK+HRQMbivk1LvMFDOhDqUeifZPa1QuDC0gkYMuq+yXFwbitpXHOm /DrjyDOeELrExiSkKsapVZnc0cjesALGZO9sPLbzOA85Je1PNB9Le0LYGdIYekrwYZtc a5NpBE9+n2ABOhDZlGDpJdaODGxpD1aT9tn6MPHtREJ0VYgdI7db92z03PdmFMRi8Vks SHgg== X-Gm-Message-State: ANoB5pm849cAR3GEHYJj5piHC0eVEuocmSvF5tgnoZoYn+sUuGt9xqSQ cWKdUA8ifO0nI/jxj7FTwHQUCjXTlLo= X-Google-Smtp-Source: AA0mqf4fPN8QkpD9/JGmYWC7BurBKrmyoLxPSJtfShbhm5pGVEQh9JABLsNb8EvBUPLgzgGZcCMcyw== X-Received: by 2002:adf:f00a:0:b0:236:4838:515d with SMTP id j10-20020adff00a000000b002364838515dmr14233023wro.541.1668625737297; Wed, 16 Nov 2022 11:08:57 -0800 (PST) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id bk11-20020a0560001d8b00b002416f0f1e96sm15477589wrb.43.2022.11.16.11.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 11:08:56 -0800 (PST) From: zimoun In-Reply-To: <87r0ybonei.fsf_-_@gnu.org> References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-4-maxim.cournoyer@gmail.com> <87r0ybonei.fsf_-_@gnu.org> Date: Wed, 16 Nov 2022 20:03:17 +0100 Message-ID: <87mt8qyb62.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Maxim, On Wed, 09 Nov 2022 at 21:58, Ludovic Court=C3=A8s wrote: >> +@item --symlink=3D@var{spec} >> +@itemx -S @var{spec} >> +For containers, create the symbolic links specified by @var{spec}, as >> +documented in @ref{pack-symlink-option}. > > We should refrain from using @ref in sentences (info "(texinfo) @ref"). > Instead, I=E2=80=99d write: > > documented for @command{guix pack} (@pxref{pack-symlink-option}). Well, for what it is worth, I have marked this email [1] by Eli Zaretskii from Emacs. Somehow, the message provides some rules of thumb to write Texinfo. :-) Quoting about cross-reference: 5. Cross-references: As a separate sentence: @xref{Node name}, for the details. In the middle of a sentence ... see @ref{Node name}, for more. In parentheses: Some text (@pxref{Some node}) more text. 1: https://lists.gnu.org/archive/html/emacs-devel/2017-11/msg00525.html Cheers, simon From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 16 Nov 2022 19:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: zimoun Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166862728231077 (code B ref 58812); Wed, 16 Nov 2022 19:35:01 +0000 Received: (at 58812) by debbugs.gnu.org; 16 Nov 2022 19:34:42 +0000 Received: from localhost ([127.0.0.1]:58229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovOBF-00085B-Vg for submit@debbugs.gnu.org; Wed, 16 Nov 2022 14:34:42 -0500 Received: from mail-qk1-f171.google.com ([209.85.222.171]:41732) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovOBD-00084x-2c for 58812@debbugs.gnu.org; Wed, 16 Nov 2022 14:34:40 -0500 Received: by mail-qk1-f171.google.com with SMTP id k4so12377060qkj.8 for <58812@debbugs.gnu.org>; Wed, 16 Nov 2022 11:34:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Dac/OyD3RtLh4Hmz1MbVnyCQk2KZQFxBS13coLUG3dM=; b=O2tP+wojVxWEdg7rYIxwl23IXprXGHbZ42M7rgmmjHvNnAqJlfHl7kiQWAq/+Vz87R yhrDH/2lzpYBh5AXZVu9XepShEX34yHlish1ppA1sf5PzhLBCVY4HPKGNTt29vfMqzxf eTJfW8ncZqriLPwH8vcGEXpkYwAw5LtYK2A8fW2wFmVEM/r6z4byWEtgzFC5MfgH06o3 n/cSbFvIfar6PIdAqgpzU+rF8vPppQbj3TmEmO21Vq9PjwGIgDKpxfjt9tYc1ZdwiwCe GBbynJ717smsHGSoPwXpxtctTHOloBFQ3YG02mXO2gCR8HCJZB8CpGDwNGEBEki2bLrf AtVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Dac/OyD3RtLh4Hmz1MbVnyCQk2KZQFxBS13coLUG3dM=; b=3F6s7Oq12t3WaDNWIRymKJhRlGriIvX0qS6d4w/8z+cgpEvM0JOBbb+yUj7JTq6pMF Elj6hPgLmsGTyp3JBaZwYKAEZA7BGdHCVE98NkqVv4ffGIyC+vBgElmqgfDSh+YtkMEX X/BU3Va1yTase8oTTo0NW2U0DI8MBceBDMCbYM08gr9sbArHs1qa8Syf2armaqBh2pWa E6janZNo92Ir5S/uOuUdyzN83CsgTYTb4pnBK6sCtbCxz9fAZTGvKcw5sWS2ZQcrzscu fFU2iOXCkLfQaN1yQyByIsHkIGyMUhEfS0geGLDuppFPgMExhpQlUiLQBAbIXDFKAz0i sWag== X-Gm-Message-State: ANoB5pnWw691ptISsIHFK7G5jyK+FPAx5EFWOyqa88a+TkufdkvZV5Ht n7Ut9GC31BRVtMQVFMOIPsL31goumJzo9Q== X-Google-Smtp-Source: AA0mqf611e/9UZlr9WxzQ0urOEq/jGjUR4sQhiTxcu0TStqtVLpt66TK/UjWCuD59jfE9+qYI1Ljog== X-Received: by 2002:ae9:e201:0:b0:6fa:326e:c42f with SMTP id c1-20020ae9e201000000b006fa326ec42fmr20685853qkc.271.1668627273344; Wed, 16 Nov 2022 11:34:33 -0800 (PST) Received: from hurd (dsl-10-133-21.b2b2c.ca. [72.10.133.21]) by smtp.gmail.com with ESMTPSA id q6-20020a37f706000000b006ed61f18651sm10409882qkj.16.2022.11.16.11.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 11:34:33 -0800 (PST) From: Maxim Cournoyer References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-4-maxim.cournoyer@gmail.com> <87r0ybonei.fsf_-_@gnu.org> <87mt8qyb62.fsf@gmail.com> Date: Wed, 16 Nov 2022 14:34:32 -0500 In-Reply-To: <87mt8qyb62.fsf@gmail.com> (zimoun's message of "Wed, 16 Nov 2022 20:03:17 +0100") Message-ID: <87pmdmith3.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Simon, zimoun writes: > Hi Maxim, > > On Wed, 09 Nov 2022 at 21:58, Ludovic Court=C3=A8s wrote: > >>> +@item --symlink=3D@var{spec} >>> +@itemx -S @var{spec} >>> +For containers, create the symbolic links specified by @var{spec}, as >>> +documented in @ref{pack-symlink-option}. >> >> We should refrain from using @ref in sentences (info "(texinfo) @ref"). >> Instead, I=E2=80=99d write: >> >> documented for @command{guix pack} (@pxref{pack-symlink-option}). > > Well, for what it is worth, I have marked this email [1] by Eli > Zaretskii from Emacs. Somehow, the message provides some rules of thumb > to write Texinfo. :-) Quoting about cross-reference: > > 5. Cross-references: > > As a separate sentence: @xref{Node name}, for the details. > In the middle of a sentence ... see @ref{Node name}, for more. > In parentheses: Some text (@pxref{Some node}) more text. > > 1: https://lists.gnu.org/archive/html/emacs-devel/2017-11/msg00525.html I like it, it takes the occult out of the equation :-). --=20 Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 17 12:31:48 2022 Received: (at control) by debbugs.gnu.org; 17 Nov 2022 17:31:48 +0000 Received: from localhost ([127.0.0.1]:34246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovijr-0005F6-SG for submit@debbugs.gnu.org; Thu, 17 Nov 2022 12:31:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35792) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovijq-0005Eu-17 for control@debbugs.gnu.org; Thu, 17 Nov 2022 12:31:47 -0500 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 1ovijj-0007Ou-62 for control@debbugs.gnu.org; Thu, 17 Nov 2022 12:31:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:Subject:From:To:Date:in-reply-to: references; bh=vPR22pr2GkK2gcZ/EADNWgW7PB6mFnoXpSB+1AYBIFY=; b=c+nTNyh95eWRsx nNRSILzifwIshsPmI4D/CxT7o/a6/KdreeMRc6SrJqs9mC4b/XG+UQTAOlVAH7nI5GvTF+tJZXMNl S4MRNx0kTVjd8aaw7S2FucVLin1ygAzm4fUuTQH0uE+5aXSNr+GiBhTPX1e0Ly3W9Oqxt8EkGtSKv +xMoGKv7FTjArWPFpZqe6jNHxHBG1fAvvWdLh/M0cVV3U8jhQ42StGKslNuYNY7Omz3cZmBukjz9k p5BCJ7OsIePxjEmVaNnrk94vtdYnYvQplRhqvxEhSxipOHOsZ/m79bZFp0YWceC9gS07DJFrc5mzW r/EW6m+TghBcwGiMjmlw==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovijh-00074P-GA for control@debbugs.gnu.org; Thu, 17 Nov 2022 12:31:38 -0500 Date: Thu, 17 Nov 2022 18:31:35 +0100 Message-Id: <87zgcpfpxk.fsf@gnu.org> To: control@debbugs.gnu.org From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: control message for bug #59164 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) retitle 59164 [PATCH] Add '--symlink' to 'guix shell' quit From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] Coding style: similarly-named variables Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 17 Nov 2022 17:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 59164@debbugs.gnu.org, 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166870666820761 (code B ref 58812); Thu, 17 Nov 2022 17:38:02 +0000 Received: (at 58812) by debbugs.gnu.org; 17 Nov 2022 17:37:48 +0000 Received: from localhost ([127.0.0.1]:34257 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovipg-0005Om-DM for submit@debbugs.gnu.org; Thu, 17 Nov 2022 12:37:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovipf-0005OQ-6U; Thu, 17 Nov 2022 12:37:47 -0500 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 1ovipZ-0008I5-Qo; Thu, 17 Nov 2022 12:37:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=XIQC+g9JaYt78aJpubTEMWT/cz5ilH7L1mEsvIwcf2s=; b=nU7G5Cn/iwnTvTw0iq3N WIMD6U9l2zRniK1RtyPY+iD/qJ4e92H65a3eiuw94jhel5dW8XVUulTPXOtWEGM4UZIXcohzlEW7M 2k25ur3p1q2vBtgbLRLUFcvZnbDMQQExrs0vZIYn7z/Qgv9s2xaUH9pNguJeTR+BJ7yUGFccbfpwG 3cBzh7AM9a12pZiCIGg8SQCr9U3nsLIRWhX8EkqxYvV7Gu5MUiP3Fj9xLD3LnNzyZZf2Be+YfKOPP m4lI30xC+kKugzJgwinWrqZYHv1pnnwvYQv8c54G1McE3Q+lAwjj/9pmoVYTfgq2RAS4i9sfsuhTf X3gI0DbUfj5LXQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovipY-0006rn-SZ; Thu, 17 Nov 2022 12:37:41 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> <877d03xywl.fsf@gmail.com> Date: Thu, 17 Nov 2022 18:37:39 +0100 In-Reply-To: <877d03xywl.fsf@gmail.com> (Maxim Cournoyer's message of "Wed, 09 Nov 2022 22:37:46 -0500") Message-ID: <87sfihfpng.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Maxim Cournoyer skribis: > Ludovic Court=C3=A8s writes: > >> Maxim Cournoyer skribis: >> >>> * gnu/build/install.scm (evaluate-populate-directive): By default, erro= r when >>> the target of a symlink doesn't exist. Always ensure TARGET ends with = "/". >>> (populate-root-file-system): Call evaluate-populate-directive with >>> #:error-on-dangling-symlink #t and add comment. >> >> [...] >> >>> + (define target* (if (string-suffix? "/" target) >>> + target >>> + (string-append target "/"))) >> >> Maybe make it: >> >> (let ((target (if =E2=80=A6))) >> =E2=80=A6) >> >> so there=E2=80=99s only one =E2=80=98target=E2=80=99 in scope (and no = =E2=80=98target*=E2=80=99); otherwise it=E2=80=99s >> easy to forget the =E2=80=98*=E2=80=99 and refer to wrong one. > > It's a pattern I've used at other places; I find it more hygienic to not > shadow existing variables; it signal to the reader "be careful, this is > not the same as the argument-bound one, though they are closely > related". I don=E2=80=99t buy it. :-) The reader might be careful yet end up using = the =E2=80=9Cwrong=E2=80=9D variable. As long as the =E2=80=9Cwrong=E2=80=9D v= ariable has no use, I think it=E2=80=99s best to shadow it so that mistakes cannot happen. Of course the details vary depending on context, but I think we should not start introducing this pattern in different places. Perhaps something to discuss and codify under =E2=80=9CFormatting Code=E2=80=9D? Ludo=E2=80=99. From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] Coding style: similarly-named variables Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 17 Nov 2022 20:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 59164@debbugs.gnu.org, 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166871727813976 (code B ref 58812); Thu, 17 Nov 2022 20:35:02 +0000 Received: (at 58812) by debbugs.gnu.org; 17 Nov 2022 20:34:38 +0000 Received: from localhost ([127.0.0.1]:34529 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovlan-0003dL-Pc for submit@debbugs.gnu.org; Thu, 17 Nov 2022 15:34:38 -0500 Received: from mail-qt1-f176.google.com ([209.85.160.176]:37821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovlal-0003d4-2x; Thu, 17 Nov 2022 15:34:36 -0500 Received: by mail-qt1-f176.google.com with SMTP id l15so1911374qtv.4; Thu, 17 Nov 2022 12:34:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=D8g2H1couwc9wvxak+9BIHQcWcgXJ03zy6cZpvnbnFI=; b=csBQ9koAauuQif8uEUmm7lqs1VtxXVOKl8BCEkh/9Fi8Gdc+lMmktLEo8Tg1U5ZEPh edB0NBt6Pbu/xiZcJA3ZPOf2ldsUB+azRwCO/3ssOu4lxcthXGSJ0NzxRmvM9XPDU4SG N0vkQXX4UFKHTIMT3lNI3SzlofXo3TsG1IL5UuSzCNfI7azBoSLGnT5vWvQVY1ADt1bx otFgsfKWfbJednMG6zpIedEbr7uqvIA7Vr6Oy2DTvzri9kcAuNITggfE5KN2GRpQYBp5 WP96hK9a2oiXVoZc9eWNpyrmRPCWg1yznOpBmDz6wIh3o3prM9hsAjnPN3bBypS43l5L lK+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=D8g2H1couwc9wvxak+9BIHQcWcgXJ03zy6cZpvnbnFI=; b=GWnfykC7H7etgPFnrYDJEYwbkonZZ4EGxeaEYQL3sk5KGT8Lf24/9KFp9Lq8Saj7aN YnAtqRYLSDf7PN563DpkhBYAv1TYH25qToYs/N/w/qpKFELc5Cmf21dHwEbyL2MvtCde 6WUqKdTzHpmiAMLuRWQQRGxahaH+5kre2vfTT/SkhvYsA5VSQshOhWGiZdBcAmXJDaOZ ccT4RPhmRgJUj3DxIIxKsNaYdan3/KD64f3arjdJ7+EUwQQlsdmLEkiUlTHAV4Mjt6TK eWlMu5V0ZZC1086wuJxisU6DXjB411dzjY5gXRmBUGbPmUTMJmBK7f9alKFPRBJpuJGy xMaQ== X-Gm-Message-State: ANoB5plz6IquerI+7fGH1EOvLyekKVyysGhnGyE53+FDhLDiJ4KPXOZ4 rBefJt1P6znvYWIRtt+KGdf4HPVcnNE= X-Google-Smtp-Source: AA0mqf5TVcJ6pZMXnlsLXfADPpfk5dZlSC/1XOxRhLMPnY7zVzSTWeWPx9r2MF1ghDPDr+DWWT34Tg== X-Received: by 2002:ac8:1483:0:b0:39c:bf89:65f0 with SMTP id l3-20020ac81483000000b0039cbf8965f0mr3941924qtj.35.1668717269380; Thu, 17 Nov 2022 12:34:29 -0800 (PST) Received: from hurd (dsl-10-133-21.b2b2c.ca. [72.10.133.21]) by smtp.gmail.com with ESMTPSA id p5-20020ac84605000000b003a55fe9f352sm863559qtn.64.2022.11.17.12.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 12:34:29 -0800 (PST) From: Maxim Cournoyer References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> <877d03xywl.fsf@gmail.com> <87sfihfpng.fsf_-_@gnu.org> Date: Thu, 17 Nov 2022 15:34:27 -0500 In-Reply-To: <87sfihfpng.fsf_-_@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Thu, 17 Nov 2022 18:37:39 +0100") Message-ID: <87v8ndtj58.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Ludovic Court=C3=A8s writes: > Hi, > > Maxim Cournoyer skribis: > >> Ludovic Court=C3=A8s writes: >> >>> Maxim Cournoyer skribis: >>> >>>> * gnu/build/install.scm (evaluate-populate-directive): By default, err= or when >>>> the target of a symlink doesn't exist. Always ensure TARGET ends with= "/". >>>> (populate-root-file-system): Call evaluate-populate-directive with >>>> #:error-on-dangling-symlink #t and add comment. >>> >>> [...] >>> >>>> + (define target* (if (string-suffix? "/" target) >>>> + target >>>> + (string-append target "/"))) >>> >>> Maybe make it: >>> >>> (let ((target (if =E2=80=A6))) >>> =E2=80=A6) >>> >>> so there=E2=80=99s only one =E2=80=98target=E2=80=99 in scope (and no = =E2=80=98target*=E2=80=99); otherwise it=E2=80=99s >>> easy to forget the =E2=80=98*=E2=80=99 and refer to wrong one. >> >> It's a pattern I've used at other places; I find it more hygienic to not >> shadow existing variables; it signal to the reader "be careful, this is >> not the same as the argument-bound one, though they are closely >> related". > > I don=E2=80=99t buy it. :-) The reader might be careful yet end up usin= g the > =E2=80=9Cwrong=E2=80=9D variable. As long as the =E2=80=9Cwrong=E2=80=9D= variable has no use, I think > it=E2=80=99s best to shadow it so that mistakes cannot happen. I'm surprised you're not buying it, given we're writing Scheme in a more functional style, and mutating same-named variables clearly goes against that style :-). > Of course the details vary depending on context, but I think we should > not start introducing this pattern in different places. Perhaps > something to discuss and codify under =E2=80=9CFormatting Code=E2=80=9D? That's more of a coding style guidelines than "formatting" code (when I read "formatting", I think of a mechanical process like 'guix style' or 'rust-fmt' can do), but yes, that could be nice to have. Better yet, something basic to share across the whole Guile/Scheme community and include in the Guile user manual, like Python has PEP 8 they can refer to, to save every Guile/Scheme project from having to reinvent the wheel. --=20 Thanks, Maxim From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [bug#59164] Coding style: similarly-named variables Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 17 Nov 2022 21:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Maxim Cournoyer Cc: 59164@debbugs.gnu.org, 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166872151320664 (code B ref 58812); Thu, 17 Nov 2022 21:46:02 +0000 Received: (at 58812) by debbugs.gnu.org; 17 Nov 2022 21:45:13 +0000 Received: from localhost ([127.0.0.1]:34550 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovmh6-0005ND-O3 for submit@debbugs.gnu.org; Thu, 17 Nov 2022 16:45:13 -0500 Received: from mail-wm1-f46.google.com ([209.85.128.46]:51099) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovmh4-0005Mv-JG; Thu, 17 Nov 2022 16:45:11 -0500 Received: by mail-wm1-f46.google.com with SMTP id v7so2346744wmn.0; Thu, 17 Nov 2022 13:45:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=PzRSbKNYHGFmGVEiTRsmCY5EiTxuiy/jAs2zx6ddK90=; b=KPFNGPc+FC/NWmPLz0lfBeGw5e2ddkafxrVGeXzgH6jcRnlR/O8zyKEeBnbo9gmiwv tc/jLMJLA7H7PnqYFGpQQIi09YTjpnJYVV9Bmf1I2RFK/0ZPjJQp9cYKIld1Df+j7nnQ YglRcDhd5a6FTkOjZRSqKTVfiRxS2QWlaVoZPQ0fnWN1OAZJZEU7Eh6cj+JuDnGSXRMx tF7TflGo5QHmO6799i/5Uq2a9gEckHOo8XtSFM35kNfweCYHi7vr1QOp/HHDFWI/tRcw lBToaUXNWm0ZWuYz4x/fR2MYP+dfDoRZW1Ho1lyiOidEnx9acqzqXr7tTIu7KkYrj4QO R2Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=PzRSbKNYHGFmGVEiTRsmCY5EiTxuiy/jAs2zx6ddK90=; b=2Jlw1awhsiV3Bv/xoI4q8JWF2hMeqvqePDGCpDBcPFxIJ4L4Q/g62Zv9aPUVQG93gk CZY47G/rN0tL3Rck0JHEaSxjyKhu64gd0KI2TtmzXT0wEKgVtAu0uNfxcRCaW6tuG4n8 rQoaozHO4zV2OMq3PKelj76wG6jH8/gqOTBLZXIQdRVPYkXxlwsfxo1ELSdG99qWiGEl UTuPJv2A0cd0YKtJEh53savbEQtk9a8JZOhlzqaBeFT3wW3U6a6VURwaaINTmGB/z97g rU6ukW6I4HEZyPQ2pwu4BKA0xQqt2T51JLPNzalTACBzf84iubSCF9CQJyDipwUMEujW q5HQ== X-Gm-Message-State: ANoB5plJy9pW+llmM+Gf28TvxDtNW8OtWIOkFdR7+p0I8TjdmKnUnDpa Q5YrdF0dYorzz3UPDrEh1NPgIknsszA= X-Google-Smtp-Source: AA0mqf4zHmMFabRqQX4SGm0dM1S//Fffo4VfQRkDWLiuXgjxv8Lt6Waw6FhyxyYk12/hyl9xf5laXA== X-Received: by 2002:a7b:c84a:0:b0:3cf:5d41:b74b with SMTP id c10-20020a7bc84a000000b003cf5d41b74bmr6319729wml.184.1668721503468; Thu, 17 Nov 2022 13:45:03 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id 6-20020a05600c024600b003b50428cf66sm2340271wmj.33.2022.11.17.13.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 13:45:03 -0800 (PST) From: zimoun In-Reply-To: <87sfihfpng.fsf_-_@gnu.org> References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> <877d03xywl.fsf@gmail.com> <87sfihfpng.fsf_-_@gnu.org> Date: Thu, 17 Nov 2022 19:44:18 +0100 Message-ID: <86zgcpju9p.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, On Thu, 17 Nov 2022 at 18:37, Ludovic =?UTF-8?Q?Court=C3=A8s?= wrote: >> It's a pattern I've used at other places; I find it more hygienic to not >> shadow existing variables; it signal to the reader "be careful, this is >> not the same as the argument-bound one, though [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.1 DATE_IN_PAST_03_06 Date: is 3 to 6 hours before Received: date 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zimon.toutoune[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.46 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.46 listed in list.dnswl.org] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.1 (/) Hi, On Thu, 17 Nov 2022 at 18:37, Ludovic Court=C3=A8s wrote: >> It's a pattern I've used at other places; I find it more hygienic to not >> shadow existing variables; it signal to the reader "be careful, this is >> not the same as the argument-bound one, though they are closely >> related". > > I don=E2=80=99t buy it. :-) The reader might be careful yet end up usin= g the > =E2=80=9Cwrong=E2=80=9D variable. As long as the =E2=80=9Cwrong=E2=80=9D= variable has no use, I think > it=E2=80=99s best to shadow it so that mistakes cannot happen. > > Of course the details vary depending on context, but I think we should > not start introducing this pattern in different places. Perhaps > something to discuss and codify under =E2=80=9CFormatting Code=E2=80=9D? I agree with Ludo. For another instance than target*, the previous was, --8<---------------cut here---------------start------------->8--- ((new '-> old) [...] - (symlink old (string-append target new))) [...] - (delete-file (string-append target new)) --8<---------------cut here---------------end--------------->8--- then replaced by, --8<---------------cut here---------------start------------->8--- ((new '-> old) [...] + (let ((new* (string-append target* new))) [...] + (error (format #f "symlink `~a' points to nonexis= tent \ +file `~a'" new* old))))) + (symlink old new*)) --8<---------------cut here---------------end--------------->8--- Well, it seems a Star War. ;-) As Ludo, I am not convinced that it is less error-prone, maybe the contrary. Cheers, simon From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [bug#59164] Coding style: similarly-named variables Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 18 Nov 2022 17:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: zimoun Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 59164@debbugs.gnu.org, 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16687909735872 (code B ref 58812); Fri, 18 Nov 2022 17:03:01 +0000 Received: (at 58812) by debbugs.gnu.org; 18 Nov 2022 17:02:53 +0000 Received: from localhost ([127.0.0.1]:38121 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ow4lR-0001Wd-96 for submit@debbugs.gnu.org; Fri, 18 Nov 2022 12:02:53 -0500 Received: from mail-qk1-f169.google.com ([209.85.222.169]:38814) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ow4lP-0001WM-F7; Fri, 18 Nov 2022 12:02:51 -0500 Received: by mail-qk1-f169.google.com with SMTP id s20so3845772qkg.5; Fri, 18 Nov 2022 09:02:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=GZqS0vELfbgnJQqgEuoyKqeSudkJk9ipeJxdZdtd/cs=; b=Sd6xtZ69GR828LndhYUUIomNc+mPCs8XGNLME9KtnKtj1VEgyef+Vd1/HAoPxlepsx zOnNe3yWtPqTVoh2cRRw6n09fbsszPLgXEI97dy+OYyYq4vlxQgmSrB9//diFCiYSn57 o2Ynu61Uzotaat+4QLFJ71ODGwWW4pRIuUT4AJxLvpP85iieqDVOiY0DcoOORlxY4tHy sZsyUbUcCq1nrinXb5w/u3EYDWLJiqEeV5Lg5Z/QuUh6HcK5Q7ljJ0TZqMw8bfznQGS8 pqP5ePTM0Grj9ZgQGSddZFS4ZtmpifL+anDjYndDgdszHGvDBiq0H+G7yVzafzqP/ysd QSMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GZqS0vELfbgnJQqgEuoyKqeSudkJk9ipeJxdZdtd/cs=; b=wGBlRccEo6zndQuqNiHzHxkQIKbhkJTJo2cO+bpTDTv360QGr0dwBtfKLKbAknMPTK f54EC0f4dUJjNYaZDmLt5zOYOfLGax96wvrq6fT2jwrv+mEjIsEJ4f+vHaCIOcJrhGcr f8rDY589aiiPPOvCmqRKJdQ5QdxZvHxv86IP/e+Czl5GT2cehRTXOKQcvjzv9x51pujR 15T1cSnwz6rMtO8zHqPMgj90n9k59B3o221hXENqrS5+mMOUs6pjkeE4j4d1u/AV28sS AO1RSw5Xdeue3zHZ5ZpXMI9gwlgNFlAb4oLDyFwzEUERMrheQ0Un/OS5dAu2uPJyHpgD zonQ== X-Gm-Message-State: ANoB5pngL4nHToaBbeijjGl8uMm+PiZ5EOvwbVKhOOIET054+0L2QFyP HGuDOUTgpW3usFwSPaG4dQe74Vq6gzPZcw== X-Google-Smtp-Source: AA0mqf7EqziDVhlEjMOjAqB5FXv29sGCXgip9eTetG1nOIM/mWoLvICQ24QGu5nI7HM2jD+AW3qQsw== X-Received: by 2002:a37:b96:0:b0:6fa:1031:5b2f with SMTP id 144-20020a370b96000000b006fa10315b2fmr6682368qkl.585.1668790965632; Fri, 18 Nov 2022 09:02:45 -0800 (PST) Received: from hurd (dsl-10-132-210.b2b2c.ca. [72.10.132.210]) by smtp.gmail.com with ESMTPSA id w11-20020a05620a444b00b006fb72dbbaa4sm2736649qkp.27.2022.11.18.09.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 09:02:45 -0800 (PST) From: Maxim Cournoyer References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> <877d03xywl.fsf@gmail.com> <87sfihfpng.fsf_-_@gnu.org> <86zgcpju9p.fsf@gmail.com> Date: Fri, 18 Nov 2022 12:02:44 -0500 In-Reply-To: <86zgcpju9p.fsf@gmail.com> (zimoun's message of "Thu, 17 Nov 2022 19:44:18 +0100") Message-ID: <87y1s82o23.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, zimoun writes: > Hi, > > On Thu, 17 Nov 2022 at 18:37, Ludovic Court=C3=A8s wrote: > >>> It's a pattern I've used at other places; I find it more hygienic to not >>> shadow existing variables; it signal to the reader "be careful, this is >>> not the same as the argument-bound one, though they are closely >>> related". >> >> I don=E2=80=99t buy it. :-) The reader might be careful yet end up usi= ng the >> =E2=80=9Cwrong=E2=80=9D variable. As long as the =E2=80=9Cwrong=E2=80= =9D variable has no use, I think >> it=E2=80=99s best to shadow it so that mistakes cannot happen. >> >> Of course the details vary depending on context, but I think we should >> not start introducing this pattern in different places. Perhaps >> something to discuss and codify under =E2=80=9CFormatting Code=E2=80=9D? > > I agree with Ludo. For another instance than target*, the previous was, > > ((new '-> old) > [...] > - (symlink old (string-append target new))) > [...] > - (delete-file (string-append target new)) > > > then replaced by, > > ((new '-> old) > [...] > + (let ((new* (string-append target* new))) > [...] > + (error (format #f "symlink `~a' points to nonex= istent \ > +file `~a'" new* old))))) > + (symlink old new*)) The intent was to keep away from the following imperative style, which hurts both readability and debuggability in my opinion: --8<---------------cut here---------------start------------->8--- (let* ((my-target "something") (my-target (mutate-once my-target)) (my-target (mutate-twice my-target))) (do-something-with my-target)) --8<---------------cut here---------------end--------------->8--- Perhaps the problem at hand would benefit being broken down in smaller chunks, to avoid having a page-full of code sharing the same scope. --=20 Thanks, Maxim From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] Coding style: similarly-named variables Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 20 Nov 2022 10:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 59164@debbugs.gnu.org, 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166894117224537 (code B ref 58812); Sun, 20 Nov 2022 10:47:02 +0000 Received: (at 58812) by debbugs.gnu.org; 20 Nov 2022 10:46:12 +0000 Received: from localhost ([127.0.0.1]:42449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owhq0-0006Nf-9t for submit@debbugs.gnu.org; Sun, 20 Nov 2022 05:46:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40054) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owhpx-0006NP-Tk; Sun, 20 Nov 2022 05:46:10 -0500 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 1owhps-0002nG-K7; Sun, 20 Nov 2022 05:46:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=AooPTJittKMtshp5EuVjLkXx8fWHzSCbkMVx/nIIrhw=; b=iBDKxyNmXsw0UQ/wDKSG g8Llmpirl017MxFQR5E6y5WhVlyYkJZW1gcY6zsxxpdscE+y9QEnczmpbH9YUHYKOuVSCq+Kriajk 7fdQwNn/AgjbGlmTd40CD/VL7rJiMOfVDOKEgK6pK3TvWsCoAxej4kT3pV4B/kT+P5/1Ot9TLtcko GktuPf0roU/5ScHocqfYkngyaRbrdewhq35QoCAT1Ws6+PKEvsiIaV6fjALw1FeFIlLC5ZKdkISqa MOSmbYnYxa8nEAuBOV4jDkTyPe3nF0tqIhBPDXgAdbyogAQ0ueg44l/ZzmPFJHDFi7XgbnqI6Dxqi iJw/umTtdAVHag==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1owhps-0004Xx-5R; Sun, 20 Nov 2022 05:46:04 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> <877d03xywl.fsf@gmail.com> <87sfihfpng.fsf_-_@gnu.org> <87v8ndtj58.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: =?UTF-8?Q?D=C3=A9cadi?= 30 Brumaire an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour du Rouleau X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Sun, 20 Nov 2022 11:46:00 +0100 In-Reply-To: <87v8ndtj58.fsf@gmail.com> (Maxim Cournoyer's message of "Thu, 17 Nov 2022 15:34:27 -0500") Message-ID: <87pmdh7vkn.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Maxim Cournoyer skribis: [...] >>> It's a pattern I've used at other places; I find it more hygienic to not >>> shadow existing variables; it signal to the reader "be careful, this is >>> not the same as the argument-bound one, though they are closely >>> related". >> >> I don=E2=80=99t buy it. :-) The reader might be careful yet end up usi= ng the >> =E2=80=9Cwrong=E2=80=9D variable. As long as the =E2=80=9Cwrong=E2=80= =9D variable has no use, I think >> it=E2=80=99s best to shadow it so that mistakes cannot happen. > > I'm surprised you're not buying it, given we're writing Scheme in a more > functional style, and mutating same-named variables clearly goes against > that style :-). There=E2=80=99s no mutation here, only lexical scoping. Anyway, I find it = clear that the risk of typing =E2=80=98x=E2=80=99 instead of =E2=80=98x*=E2=80=99= , especially in relatively long functions, justifies shadowing in situations like this one. WDYT? >> Of course the details vary depending on context, but I think we should >> not start introducing this pattern in different places. Perhaps >> something to discuss and codify under =E2=80=9CFormatting Code=E2=80=9D? > > That's more of a coding style guidelines than "formatting" code Sorry I meant =E2=80=9CCoding Style=E2=80=9D, which is the section that doc= uments the project=E2=80=99s conventions. > (when I read "formatting", I think of a mechanical process like 'guix > style' or 'rust-fmt' can do), but yes, that could be nice to have. > Better yet, something basic to share across the whole Guile/Scheme > community and include in the Guile user manual, like Python has PEP 8 > they can refer to, to save every Guile/Scheme project from having to > reinvent the wheel. I won=E2=80=99t do it, but sure, why not! My immediate concern is to make = sure we have a shared understanding, within Guix, of some of the conventions we follow. It=E2=80=99s a minor issue, but minor issues are what our day-t= o-day work is made of. :-) Thanks, Ludo=E2=80=99. From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [bug#59164] Coding style: similarly-named variables Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 21 Nov 2022 15:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 59164@debbugs.gnu.org, 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166904296931654 (code B ref 58812); Mon, 21 Nov 2022 15:03:02 +0000 Received: (at 58812) by debbugs.gnu.org; 21 Nov 2022 15:02:49 +0000 Received: from localhost ([127.0.0.1]:48448 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ox8Js-0008ET-LR for submit@debbugs.gnu.org; Mon, 21 Nov 2022 10:02:48 -0500 Received: from mail-wr1-f54.google.com ([209.85.221.54]:34633) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ox8Ji-0008Do-7e; Mon, 21 Nov 2022 10:02:42 -0500 Received: by mail-wr1-f54.google.com with SMTP id s5so3058051wru.1; Mon, 21 Nov 2022 07:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=I4Y6SfsgqjKChPZM8JJeYtcbXRrdExtrTZ1SAk97xoQ=; b=jqo95tjL0rm+nb+inIiT/pdbIQWh2gJsuSfpvcAOUQ/XPDhkpntSkePrprpPj96iVK P9G+xXU58QJ7rHls84deosP9BWhB90JI1vtg48Rkz2vsqx062MyxIxz5zF6pMi9sQy2z 3CzTUZ/o9smUZLhgKnTSws4H/cv4fAr8akrM9saNrRjjHjfWK999nhwhCllAkdMXD8Po UbHs4xpssvX6bqZjza5Nnyo60Mvjop8eCojulgWAUFa8DUgFSAEjnTMwEsBBhlc+lF8V ahjL64SgfDTF4LTCJRzX2HQUcxcwESPDhx2ecioWxYaRjFm+CEGXcqIwH7VR+LDpR8cl vu6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=I4Y6SfsgqjKChPZM8JJeYtcbXRrdExtrTZ1SAk97xoQ=; b=ATL8H4o8sCcmpwR1uqaSfdvIhTvbQX2HxAVJLsaz/KruJF19CqtcMF9kDbud3GbQPa /H0Q+E8fPM2eSgG9nzERcAwmup7eMN973pwPgXjcztsZp3Q2OX50FXM8O1/soAyLUIEG ELc5rl/Btb/G6gylPX+DrN+esbUcBMNRIonU8Rrq8cVoTriOehtunCO76gZxtmB75wG7 4u4W3BhPrBS0D6GbQLE233T56qwH7kgudWA/RyK5WjqlJUG2cZlI1LezlrXMrb31NXl+ qEDHIi0bfZnDaq+3XIVahOnXmiTsA9J7IDu5ocULB1dS9Nv1RHptijQTA8pMc8PVzWFr Rhmg== X-Gm-Message-State: ANoB5pmc1bwJiiYxhBIb/DM3mpJ9UCm7/+BRb8H3/VcRe0C3OEvLBgS+ XBrvJTZUqBpjAFSSv+0fVQWak6RdPYM= X-Google-Smtp-Source: AA0mqf60WhkqmdZgsN4dUJbgKn9DWFwH+FcURRsEzmkipBxaQDRUgTnQmoEnC0kIDbmcLrN9GMOkuQ== X-Received: by 2002:adf:f8ca:0:b0:241:c933:4b0e with SMTP id f10-20020adff8ca000000b00241c9334b0emr4613716wrq.48.1669042946973; Mon, 21 Nov 2022 07:02:26 -0800 (PST) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id f3-20020a5d4dc3000000b0022e57e66824sm13111119wru.99.2022.11.21.07.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 07:02:26 -0800 (PST) From: zimoun In-Reply-To: <87y1s82o23.fsf@gmail.com> References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> <877d03xywl.fsf@gmail.com> <87sfihfpng.fsf_-_@gnu.org> <86zgcpju9p.fsf@gmail.com> <87y1s82o23.fsf@gmail.com> Date: Mon, 21 Nov 2022 16:02:19 +0100 Message-ID: <87zgckwdtw.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Maxim, On Fri, 18 Nov 2022 at 12:02, Maxim Cournoyer w= rote: > The intent was to keep away from the following imperative style, which > hurts both readability and debuggability in my opinion: > > --8<---------------cut here---------------start------------->8--- > (let* ((my-target "something") > (my-target (mutate-once my-target)) > (my-target (mutate-twice my-target))) > (do-something-with my-target)) > --8<---------------cut here---------------end--------------->8--- Well, =E2=80=99mutate-*=E2=80=99 is not really mutating. Maybe I miss some= thing and from my understanding, this =E2=80=99let*=E2=80=99reads, --8<---------------cut here---------------start------------->8--- (let ((my-target "something")) (let ((my-target (mutate-once my-target))) (let ((my-target (mutate-twice my-target))) (do-something-with my-target)))) --8<---------------cut here---------------end--------------->8--- and not, --8<---------------cut here---------------start------------->8--- (begin (define my-target "something") (set! my-target (mutate-once my-target)) (set! my-target (mutate-twice my-target)) (do-something-with my-target)) --8<---------------cut here---------------end--------------->8--- Well, the former is =E2=80=99lexical-scope=E2=80=99d so the 3 =E2=80=99my-t= arget=E2=80=99 are not truly an imperative style, I guess. Back to the pattern, you are suggesting to write, --8<---------------cut here---------------start------------->8--- (let* ((my-target "something") (my-target* (mutate-once my-target)) (my-target** (mutate-twice my-target*))) (do-something-with my-target**)) --8<---------------cut here---------------end--------------->8--- well, I am not convinced it helps for readibility. And I think, the pattern is manually doing what =E2=80=99let*=E2=80=99 is already doing for = you. Cheers, simon From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [bug#59164] Coding style: similarly-named variables Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 21 Nov 2022 15:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 59164@debbugs.gnu.org, 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166904598113484 (code B ref 58812); Mon, 21 Nov 2022 15:53:01 +0000 Received: (at 58812) by debbugs.gnu.org; 21 Nov 2022 15:53:01 +0000 Received: from localhost ([127.0.0.1]:48523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ox96S-0003VN-LB for submit@debbugs.gnu.org; Mon, 21 Nov 2022 10:53:00 -0500 Received: from mail-wr1-f49.google.com ([209.85.221.49]:45014) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ox96N-0003V0-4b; Mon, 21 Nov 2022 10:52:59 -0500 Received: by mail-wr1-f49.google.com with SMTP id v1so20455673wrt.11; Mon, 21 Nov 2022 07:52:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=vGu88NGK3bl0EzsaMcsFWCozdy09RqmbXZbPldUaQN4=; b=C1SvSORZhvMOy625ttNmO5SyVJZGFqOzMLb7GsZZX2QZfUh6JJIpbYXX+pbnUXmSeV vNMBZZaiORLHYpkbfu4q8lKdZywT90VIfq7DrxA/DCP83zKDa4L0eiHi6fIvNuR8+apK pJGLYre4KPBQPWtEjLvr13HGpQ0zpz4BPdXlauXqPun+D67JL1pXy4JW9uw+qrA52fsV nCvkP1dRSH/6RhG5TrHbGs+sah4cTcH0XamW+Zj0QS7pEAnZAhQ/MUgSe5YlqnZVu1Ja nzy+P4C3ht3LLzXrYZgyeip5sJ5HxYwZ1wd3TG1fYemU/5tyd21q8lUJXl/O4SVfeUFg CQxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=vGu88NGK3bl0EzsaMcsFWCozdy09RqmbXZbPldUaQN4=; b=VXtvbuatTx7NUTKySiXaDrRTQlD6xEYYvviFcCvNeCQEuUB91uqIQb/2j8V0Ta31g1 A7rK2+Y1J/qo3PWc38lg1eD4Yhnt7EeaM9YA3LNnBavxQ4efAYgfYMFltQ5q5TaLlUtv 1ER/lefVgYjtANOi+SYLbEGpYkCHFVAolCZX7n2Y01URDPVjB6uWl1mrCtyWu/NWL+S0 6fHSxDgTNafjkORQYXMR5mVhLOsUAiZ3JK51u0ft98eDpDvdwjBZE0x9vQNrn9HEVp69 MPPdFWnew4qJ1xr6fYT5j07okJyhLb2MXzReXobp2jPDHnSyOy7HbR7os4KC4qeigYyE YdYQ== X-Gm-Message-State: ANoB5pm2+xen2w2JpmrLSiGNfmYue6PWrzLIfcnKGmxl8Ff0DtiyUggy ISja1F347tFFOSGgchJiXJwMDWKR4VQ= X-Google-Smtp-Source: AA0mqf5nngtEgjGP+lRHIQ5QkexNG0jamjoqMAb49Kkt7KHj6ViOjAQqj3A4HIabOXzCHvvP0UlSrw== X-Received: by 2002:a5d:6acf:0:b0:22e:224c:3443 with SMTP id u15-20020a5d6acf000000b0022e224c3443mr11575190wrw.361.1669045969019; Mon, 21 Nov 2022 07:52:49 -0800 (PST) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id f12-20020a7bc8cc000000b003c64c186206sm13746386wml.16.2022.11.21.07.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 07:52:48 -0800 (PST) From: zimoun In-Reply-To: <87zgckwdtw.fsf@gmail.com> References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> <877d03xywl.fsf@gmail.com> <87sfihfpng.fsf_-_@gnu.org> <86zgcpju9p.fsf@gmail.com> <87y1s82o23.fsf@gmail.com> <87zgckwdtw.fsf@gmail.com> Date: Mon, 21 Nov 2022 16:52:44 +0100 Message-ID: <87mt8kwbhv.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Mon, 21 Nov 2022 at 16:02, zimoun wrote: > Well, =E2=80=99mutate-*=E2=80=99 is not really mutating. Maybe I miss so= mething and > from my understanding, this =E2=80=99let*=E2=80=99reads, > > --8<---------------cut here---------------start------------->8--- > (let ((my-target "something")) > (let ((my-target (mutate-once my-target))) > (let ((my-target (mutate-twice my-target))) > (do-something-with my-target)))) > --8<---------------cut here---------------end--------------->8--- Well, it compiles to something similar=E2=80=A6 > And I think, the > pattern is manually doing what =E2=80=99let*=E2=80=99 is already doing fo= r you. =E2=80=A6for instance, it reads, --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> (macroexpand '(let* ((my-target "something") (my-target (mutate-once my-target)) (my-target (mutate-twice my-target))) (do-something-with my-target))) $1=3D # --8<---------------cut here---------------end--------------->8--- Cheers, simon From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [bug#59164] Coding style: similarly-named variables Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 21 Nov 2022 20:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: zimoun Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 59164@debbugs.gnu.org, 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166906415625269 (code B ref 58812); Mon, 21 Nov 2022 20:56:02 +0000 Received: (at 58812) by debbugs.gnu.org; 21 Nov 2022 20:55:56 +0000 Received: from localhost ([127.0.0.1]:48980 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxDpb-0006ZU-SI for submit@debbugs.gnu.org; Mon, 21 Nov 2022 15:55:56 -0500 Received: from mail-qk1-f178.google.com ([209.85.222.178]:45749) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxDpZ-0006ZD-TO; Mon, 21 Nov 2022 15:55:54 -0500 Received: by mail-qk1-f178.google.com with SMTP id v8so8909911qkg.12; Mon, 21 Nov 2022 12:55:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=f2BQH21an7hjWbLnErDeQIITcwak8jyouTcuX/SktR8=; b=jOSN5QfQl4uqW2nq4rmt8zgR4g4ZS2SzqTC4oy3fM46x6CTYMnF2PTQ+B7ip9RGSnp Mwx5+14iRKhwVEaPbFh5ckNiPFcsVnuUGO5x57+6BmrqUBnr8iuIW6Tm5cPLIvhCrLtj pDuZVZ8f0Z9xPslRYMako+HSIh1GcPpLNcR99OofYoP/FV7lXI6cZgLAi6AOgATyvp2G C6g7B1Txp7bi0pIMt+Jg/U6GmcivpWa8fKNAx+bQ61BEGudRnAlvYU74daZVZkE19w7Q +86Fx3FHlUR2CT72N/rV4iDWlyIrDFVeaKFZK0UdCLJ8UHyTmqOMu9o8MdN5A8ps5iLs OV6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=f2BQH21an7hjWbLnErDeQIITcwak8jyouTcuX/SktR8=; b=NE6oCL30lHI19QLQwA91GQpmm9sgxG9DGu4T7Gfudbx7MfopT9ksW9AZ9RPJu6OuDR +kwTtCw00q7IvYCu9jYiq9v6rPvaGbfau2ozNPdPu902ymdQLsvq7ErizXcjv19MfLbx 3iC1BaQRS/jjwlvGBljrZ3pO6m3ECn9pnv0yQq1Rgduz+q8kLW39WrlnlYnjVxFjcLab ftCXgfMmcjE55eTFDYS9a1siG33L+LcxnjelVcBewgOjyCzHSSHx6GGixPjWJCw/r7Wb xWFqnnwg6WLEOHaDkWB+ikaEMDcZiZzoW0anoYao5nfGlqmo7O2w3Y9E2AXpzsISZ4oe fIeg== X-Gm-Message-State: ANoB5pmKz3eXytCXkJ/o7zb2GYIXn8cIgiLa6YFX331d+EWR3b0Exz6c NTKb908k3EkcqmXn5cKwr47KPsrA7Tk= X-Google-Smtp-Source: AA0mqf5xo9+hsxIljoKwTGqTH2y9w2XYzrGq8UqIRUgOGjYcXA1U8m5jv+KxfVNiigwBUhdVllIgyw== X-Received: by 2002:a37:44ce:0:b0:6fa:4335:5793 with SMTP id r197-20020a3744ce000000b006fa43355793mr666636qka.242.1669064148020; Mon, 21 Nov 2022 12:55:48 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1003]) by smtp.gmail.com with ESMTPSA id m14-20020ac85b0e000000b003a591194221sm7445908qtw.7.2022.11.21.12.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 12:55:47 -0800 (PST) From: Maxim Cournoyer References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> <877d03xywl.fsf@gmail.com> <87sfihfpng.fsf_-_@gnu.org> <86zgcpju9p.fsf@gmail.com> <87y1s82o23.fsf@gmail.com> <87zgckwdtw.fsf@gmail.com> Date: Mon, 21 Nov 2022 15:55:46 -0500 In-Reply-To: <87zgckwdtw.fsf@gmail.com> (zimoun's message of "Mon, 21 Nov 2022 16:02:19 +0100") Message-ID: <87sficqb71.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Simon, zimoun writes: > Hi Maxim, > > On Fri, 18 Nov 2022 at 12:02, Maxim Cournoyer = wrote: > >> The intent was to keep away from the following imperative style, which >> hurts both readability and debuggability in my opinion: >> >> --8<---------------cut here---------------start------------->8--- >> (let* ((my-target "something") >> (my-target (mutate-once my-target)) >> (my-target (mutate-twice my-target))) >> (do-something-with my-target)) >> --8<---------------cut here---------------end--------------->8--- > > Well, =E2=80=99mutate-*=E2=80=99 is not really mutating. Maybe I miss so= mething and > from my understanding, this =E2=80=99let*=E2=80=99reads, > > (let ((my-target "something")) > (let ((my-target (mutate-once my-target))) > (let ((my-target (mutate-twice my-target))) > (do-something-with my-target)))) > > > and not, > > (begin > (define my-target "something") > (set! my-target (mutate-once my-target)) > (set! my-target (mutate-twice my-target)) > (do-something-with my-target)) Right. I used "mutated" where I should have used "shadowed by lexical scoping". The outcome for me is the same; the original value of an argument (target) in the code gets shadowed, thus is theory it becomes more difficult to inspect its original value, should we have a debugger that is able to stop at the place to inspect to print ',locals'. In practice since using breakpoints/a debugger to debug Guile code rarely works as intended (in my experience hacking on Guix!), we typically sprinkle the source with 'pk', and that point becomes moot. > Well, the former is =E2=80=99lexical-scope=E2=80=99d so the 3 =E2=80=99my= -target=E2=80=99 are not truly > an imperative style, I guess. > > Back to the pattern, you are suggesting to write, > > (let* ((my-target "something") > (my-target* (mutate-once my-target)) > (my-target** (mutate-twice my-target*))) > (do-something-with my-target**)) > well, I am not convinced it helps for readibility. And I think, the > pattern is manually doing what =E2=80=99let*=E2=80=99 is already doing fo= r you. The value it provides is that it becomes easy to inspect each intermediary result in a debugger. I think we're done expressing the arguments to have on both sides, which aren't too strong either ways :-). I'm happy to restrain myself using such a pattern and keep moving forward. --=20 Thanks, Maxim From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [bug#59164] Coding style: similarly-named variables Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 22 Nov 2022 15:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 59164@debbugs.gnu.org, 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166913164917333 (code B ref 58812); Tue, 22 Nov 2022 15:41:01 +0000 Received: (at 58812) by debbugs.gnu.org; 22 Nov 2022 15:40:49 +0000 Received: from localhost ([127.0.0.1]:52314 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxVOD-0004VT-Cx for submit@debbugs.gnu.org; Tue, 22 Nov 2022 10:40:49 -0500 Received: from mail-wm1-f43.google.com ([209.85.128.43]:42592) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxVO9-0004V2-5C; Tue, 22 Nov 2022 10:40:47 -0500 Received: by mail-wm1-f43.google.com with SMTP id p13-20020a05600c468d00b003cf8859ed1bso11594948wmo.1; Tue, 22 Nov 2022 07:40:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=4OnFDgr+/AMD5/lfU/rs6H1Y3g/sM8f/bcP4gw2gN7Q=; b=SPedOGtJBUd8CDEEp12rt5H3dmidYw9vi5kF7uEH7OVDNa3bo6yDTnRYyr8b2lC97b nqW46KkuFRvmm/Al1UMCmcaI1pXUilAz/0A//g8Z1OetOkhk/q/Y2FLUMRzHjrDmy1FI fcPlWSSfTclq6g3vDDAZvH0BBiqhBxy6kVcO1y1gLK3glp6+2uHzL/EkGV1ZK+dIx5L9 uL1mhr5gtyBGjrFeXcHrXg8lm0n/ZiEIje+IKu2TnrYBb803jfzCqa2TAY2ytwNqp4Ga UOZHtNDAn85FtIcII3YSzlZIYHbh4g3Lw38kHNTfHvIHFxuWatmnr2AF2Es9I7lJkAQV IFkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=4OnFDgr+/AMD5/lfU/rs6H1Y3g/sM8f/bcP4gw2gN7Q=; b=H6EDcer8xyS6CSbPsVUbDu/Ej5BWEnll8lYj6LuPtFMWvk7BZAA5t0TBRyPVJvw34C buUGEfCLRMM+B+a7+oqsJawUsb5gdL6/p7C0iKubk9SsoVEzMDkSlym7E7NdFOqhCn4y ViVN5jOgHmzIUvzpYXb7bW6mGulAx91fnYx/PYwTJa0X+xwr+dba2EyzKaTC5M1XfMN4 ukHU5DdMJmW2a33O4wHj4brVWZTZhmLrw1yqS5g7nX6RDzHsj5NAmPK9kLnhyKlsYMQp P/sjxC7Y/S2EUmateVPKCq60G4iFDZdogvLah3yRG3GpgaOErQSXPBMcMu8s2/YLq5g6 YcgA== X-Gm-Message-State: ANoB5pmXDZODj7P9/0rDlir1WYxWCEyUhd2TpBCVoopV1oCwcedwT9YK FhFynZ00zxbc2ZwgOzHgia1y4+zM3Gk= X-Google-Smtp-Source: AA0mqf62Hoze0YFLbO6CJJKGUvyBkvsd8Qplym/vfbrgmzijU+U1QQND3V824qoffeA6DMFZiUkIFA== X-Received: by 2002:a1c:ed01:0:b0:3cf:7d41:f2bb with SMTP id l1-20020a1ced01000000b003cf7d41f2bbmr4665002wmh.62.1669131639045; Tue, 22 Nov 2022 07:40:39 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c4ed100b003c701c12a17sm25163065wmq.12.2022.11.22.07.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 07:40:38 -0800 (PST) From: zimoun In-Reply-To: <87sficqb71.fsf@gmail.com> References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> <877d03xywl.fsf@gmail.com> <87sfihfpng.fsf_-_@gnu.org> <86zgcpju9p.fsf@gmail.com> <87y1s82o23.fsf@gmail.com> <87zgckwdtw.fsf@gmail.com> <87sficqb71.fsf@gmail.com> Date: Tue, 22 Nov 2022 15:35:30 +0100 Message-ID: <86fsebdpl9.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Maxim, On Mon, 21 Nov 2022 at 15:55, Maxim Cournoyer w= rote: > In practice since using breakpoints/a debugger to debug Guile code > rarely works as intended (in my experience hacking on Guix!), we > typically sprinkle the source with 'pk', and that point becomes moot. I totally agree! Preparing some materials for introducing Guile to GuixHPC folk, I am trying to collect some tips and, if I am honest, the debugging experience with Guile is really poor; compared to others (as Python). For example, DrRacket provides an easy and nice user experience [1] =E2=80=93 where it is easy to compare each intermediary resu= lt in the debugger. For what it is worth, I have not been able to have some similar inspections as in [1]. Maybe, I am missing something=E2=80=A6 Well, IMHO, we are somehow suffering from some Guile limitations and improvements in this area are an hard task. Cheers, simon Short video demoing (link will be dead after 2022-12-07) 1: https://filesender.renater.fr/?s=3Ddownload&token=3D92d4312a-91b4-402e-8= 98a-40ce01a5c3ed From unknown Sat Jun 21 05:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [bug#59164] Coding style: similarly-named variables Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 26 Nov 2022 14:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: zimoun Cc: 59164@debbugs.gnu.org, Maxim Cournoyer , 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.166947406021901 (code B ref 58812); Sat, 26 Nov 2022 14:48:02 +0000 Received: (at 58812) by debbugs.gnu.org; 26 Nov 2022 14:47:40 +0000 Received: from localhost ([127.0.0.1]:38350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oywSy-0005h9-Bg for submit@debbugs.gnu.org; Sat, 26 Nov 2022 09:47:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oywSx-0005gl-CY; Sat, 26 Nov 2022 09:47:39 -0500 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 1oywSs-0007dV-4V; Sat, 26 Nov 2022 09:47:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=pXhHo9+CVvQAVWtIQsYZk2Is/Xw+D53l5GQ4hF1jA5k=; b=rAaFGDtb9TxkQH3Sd9Qm U9G1EIy2HUneTm8daNmfiCMTnApaqpIHduib2EtfZU48gRsBdu01MmQz2Uq7bJm4PGzPienw6yYTc mPb0OCRXbPnHRJwVFzBCE09hI/Dk6UEyP5q3M47I+k7ixKqA51+ITYlz0Cnqf9Aqu/90LWPitqDgl T/oc+lqrhQ99NYdvABjsviMQBOiSQQiX5F+dJos+zW8+MZe5ggtQ3eUNA8dtt/mVqFFDnBGWLoomO dRlK1bkJnqjV3ejHmRWBWSgxVihnqWiVHXKqCc/7X5n+zFtesicQazbIA3vuooNEkQRckMTyYfH7f OIyzHG30IzmOgg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oywSr-0003ig-Ob; Sat, 26 Nov 2022 09:47:33 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> <87leojon1z.fsf_-_@gnu.org> <877d03xywl.fsf@gmail.com> <87sfihfpng.fsf_-_@gnu.org> <86zgcpju9p.fsf@gmail.com> <87y1s82o23.fsf@gmail.com> <87zgckwdtw.fsf@gmail.com> <87sficqb71.fsf@gmail.com> <86fsebdpl9.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Sextidi 6 Frimaire an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour de la =?UTF-8?Q?M=C3=A2che?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Sat, 26 Nov 2022 15:47:31 +0100 In-Reply-To: <86fsebdpl9.fsf@gmail.com> (zimoun's message of "Tue, 22 Nov 2022 15:35:30 +0100") Message-ID: <87pmd993i4.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, zimoun skribis: > I totally agree! Preparing some materials for introducing Guile to > GuixHPC folk, I am trying to collect some tips and, if I am honest, the > debugging experience with Guile is really poor; compared to others (as > Python). For example, DrRacket provides an easy and nice user > experience [1] =E2=80=93 where it is easy to compare each intermediary re= sult in > the debugger. For what it is worth, I have not been able to have some > similar inspections as in [1]. Maybe, I am missing something=E2=80=A6 Looking at the video you posted, I better understand what debugging features we=E2=80=99re talking about. DrRacket is the gold standard; here = it does something similar to what we have with in Elisp with EDebug, which is certainly useful. It may be more of a limitation of Geiser than of Guile. I find it more useful in =E2=80=9Ctypical=E2=80=9D imperative ELisp code than in functiona= l Scheme code, but it=E2=80=99d be nice to have either way! Ludo=E2=80=99.