From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id qKUeB9ACS2JG2gAAgWs5BA (envelope-from ) for ; Mon, 04 Apr 2022 16:38:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id aMOUA9ACS2InNAAAauVa8A (envelope-from ) for ; Mon, 04 Apr 2022 16:38:08 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7754FEF34 for ; Mon, 4 Apr 2022 16:38:07 +0200 (CEST) Received: from localhost ([::1]:60424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nbNqI-0005ar-3J for larch@yhetil.org; Mon, 04 Apr 2022 10:38:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbNqE-0005ai-Sz for guix-patches@gnu.org; Mon, 04 Apr 2022 10:38:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nbNqE-0006ac-Kl for guix-patches@gnu.org; Mon, 04 Apr 2022 10:38:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nbNqE-0000KY-Ia for guix-patches@gnu.org; Mon, 04 Apr 2022 10:38:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54393] [PATCH 0/2] Add 'guix manifest' to "translate" commands to manifests Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 04 Apr 2022 14:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54393 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 54393@debbugs.gnu.org Received: via spool by 54393-submit@debbugs.gnu.org id=B54393.16490830571216 (code B ref 54393); Mon, 04 Apr 2022 14:38:02 +0000 Received: (at 54393) by debbugs.gnu.org; 4 Apr 2022 14:37:37 +0000 Received: from localhost ([127.0.0.1]:52606 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbNpo-0000JY-Jc for submit@debbugs.gnu.org; Mon, 04 Apr 2022 10:37:36 -0400 Received: from mail-qk1-f180.google.com ([209.85.222.180]:37881) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbNpm-0000JG-Pj for 54393@debbugs.gnu.org; Mon, 04 Apr 2022 10:37:35 -0400 Received: by mail-qk1-f180.google.com with SMTP id d142so7772984qkc.4 for <54393@debbugs.gnu.org>; Mon, 04 Apr 2022 07:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=c5Dvt+V7/tR3Zz5s3b5JBpYuhrpKXhlrSUkS2978UbA=; b=A8UQ/2bm91ktAOQ7lRqQQmLt/GDe00Kf2QS6tsSTr7GlgaBAgj5hzRWd+Kl81+HvI+ ofT/75hriK6wxKd7HTITUmU5PwxR7hxUxHGOmCPjJuSGFabb3uPkumoM7Scs4Z8+lLsu b/4pFANU1MmebNZr04HhC4A3JPr/Va01xAL1k99ZoIwmb2E7JvCghXQGv3yeKmYcij4V L1ghp8TLmZ5jRo/t0BRFit+He4y3nVIL77IlybYH/ubid51x6T7UZj2FIaqdKzu7sgBw U6Py5RZ3CO2Tm1mk5/VfX0TyntPrlOw3lCrulaA08xl+HxAE8bS6U0qy4kl7u9uIu34J 1qeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=c5Dvt+V7/tR3Zz5s3b5JBpYuhrpKXhlrSUkS2978UbA=; b=dx+Fz5i0C5R0kdfXP5ZbQoiq63/lUiLvZvCStHuO++eoWFfkp/qlaEizp5FyFYS/p7 w/p/15S7qbV+64mc47pmEyUqCiz0+SMlJamCq6Fkbltz8xdTFX7KrAwiDCLMbx9pQ1fK Cnlx1Gx/wklAfzYX3UAvDpbxuKzwZpXAe017MgoNZNdpmYnxq4eDOunOXwCPwo74ACgh BGYNWnPTBZnNgDsNrM6sSbGLWvWa9EPjOOpnOOQms4jSgVZuYe2sN+9JWy1LNrot07BJ Mhnu4bdn+pWhbuJqTATj5/AnUiL1PBbiciuvKJH0H+90WFbwOzigB7uiE2rVm+kDGAfV JXNw== X-Gm-Message-State: AOAM532ma+Ow4ysdPWNLhKwyClaLO5qSSandOwTaKCGofH82ubXirA/Z 4HIL02pY7EqQW4qOpbbRg1CQ0n5F8NU= X-Google-Smtp-Source: ABdhPJxaYJqz84z8DR+tqDqmK2BXdpuwPZ861yDEeSr0j6Gd4B/iKAkyFw5SQ4YyelRgTumtGaU0Ag== X-Received: by 2002:a05:620a:2488:b0:680:9f57:efbb with SMTP id i8-20020a05620a248800b006809f57efbbmr50868qkn.714.1649083048836; Mon, 04 Apr 2022 07:37:28 -0700 (PDT) Received: from hurd (dsl-154-119.b2b2c.ca. [66.158.154.119]) by smtp.gmail.com with ESMTPSA id j21-20020ac85f95000000b002e1cde99863sm8636831qta.83.2022.04.04.07.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 07:37:27 -0700 (PDT) From: Maxim Cournoyer References: <87r173huph.fsf@gnu.org> <20220331110957.31829-1-ludo@gnu.org> <20220331110957.31829-3-ludo@gnu.org> Date: Mon, 04 Apr 2022 10:37:26 -0400 In-Reply-To: <20220331110957.31829-3-ludo@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Thu, 31 Mar 2022 13:09:57 +0200") Message-ID: <87sfqszzh5.fsf_-_@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1649083087; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=D+MNNEgS0bsSOscgboslSk9pqE4HGkvLWQ2XinUvfDA=; b=tCyLDDqqz4a6h+fgi4Fb6JMe6LO7IGE9rYAVfWuL55Bhcefuwby+dP5/nvOWABHjEYtnRQ IVFHvvzD6d1SvG4uqxsxmF1SVK2VRkmen5mfIyUN1cg7MpqNHHoFIgIQM52WkeiUVqI4ZH bhlcXdAKcm9LvTKJ49Kdva82MuO4kwY08YRId2OU2aCU0Xl0GvwlHreNSPyRnyx30BkQkT gLOfh2MB/ctDiZo7I8EUk0gm50YSLzbxB/YTdV8lHcgp3PMAVv5c9hyLvlHhBaukCURpTW lmjUSPUnZ/l4mx5piwTCYQPRUgTPM3+o1z8BonTw+EBXGgyfpTieHoc4sQMd2w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649083087; a=rsa-sha256; cv=none; b=VIJ/VCpXGVkgXtrHM6Y/4eYKjU7mpUAhY6RLUZ3bwIrZ/EHasY+cz3ZfbwfBQd2v6fLgBY NpWtWhNi4qTWzBReLt3qMTuaK9oxCM+aJGOKUWoyLNTLVbOpor1PBlq6KHPIBK0zsqxfRH r54aO1V1ykgWJYbJp4leVRy6Uyy/eDbrWQPrgqELH/MaDz+yTWYmmbzKivDgQ5vLykJApD ItGME8/9O8xxOyTrcfIsLR64z3NW90r79drfpZhF2K4qzoN+hJB6FmU2k0zXnY2KC6/rn+ yIX6v3nfn6E+qnckzFO4vO2YcLgJ4ejulfQnUnZn7BO6bqq1ZKf8/dj+PH9sIg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b="A8UQ/2bm"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 5.12 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b="A8UQ/2bm"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 7754FEF34 X-Spam-Score: 5.12 X-Migadu-Scanner: scn0.migadu.com X-TUID: snq2pfGtdmzg Hello, Ludovic Court=C3=A8s writes: > * guix/scripts/shell.scm (show-help, %options): Add '--export-manifest'. > (manifest-entry-version-prefix, manifest->code*) > (export-manifest): New procedures. > (guix-shell): Honor '--export-manifest'. > * tests/guix-shell-export-manifest.sh: New file. > * Makefile.am (SH_TESTS): Add it. > * doc/guix.texi (Invoking guix shell): Document '--export-manifest'. > (Invoking guix environment): Link to it. > (Invoking guix pack): Likewise. [...] > + > +;;; > +;;; Exporting a manifest. > +;;; > + > +(define (manifest-entry-version-prefix entry) > + "Search among all the versions of ENTRY's package that are available, = and > +return the shortest unambiguous version prefix for this package." > + (package-unique-version-prefix (manifest-entry-name entry) > + (manifest-entry-version entry))) > + > +(define (manifest->code* manifest extra-manifests) > + "Like 'manifest->code', but insert a 'concatenate-manifests' call that > +concatenates MANIFESTS, a list of expressions." > + (if (null? (manifest-entries manifest)) > + (match extra-manifests > + ((one) one) > + (lst `(concatenate-manifests ,@extra-manifests))) > + (match (manifest->code manifest > + #:entry-package-version > + manifest-entry-version-prefix) > + (('begin exp ... last) > + `(begin > + ,@exp > + ,(match extra-manifests > + (() last) > + (_ `(concatenate-manifests > + (list ,last ,@extra-manifests))))))))) Should an "else" clause be added here with a more useful error message that the default 'no match for x' or similar? If that'd be totally unexpected and a bug, then it's fine as-is. > +(define (export-manifest opts port) > + "Write to PORT a manifest corresponding to OPTS." > + (define (manifest-lift proc) > + (lambda (entry) > + (match (manifest-entry-item entry) > + ((? package? p) > + (manifest-entry > + (inherit (package->manifest-entry (proc p))) > + (output (manifest-entry-output entry)))) > + (_ > + entry)))) > + > + (define (validated-spec spec) > + ;; Return SPEC if it's validate package spec. As this is an action (proc), perhaps it should be named "validate-spec". The comment doc should also be worded as "if SPEC is a valid package spec" or similar. The rest LGTM. Thank you for addressing the suggestion to reuse an existing sub-command to try to keep things neatly organized instead of extending the already large set of them :-). Maxim