From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id yOjUJEnZ3GA0ZgEAgWs5BA (envelope-from ) for ; Wed, 30 Jun 2021 22:51:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id kBVxIEnZ3GBfKgAA1q6Kng (envelope-from ) for ; Wed, 30 Jun 2021 20:51:21 +0000 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 EDD131D9DE for ; Wed, 30 Jun 2021 22:51:20 +0200 (CEST) Received: from localhost ([::1]:56028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyhB2-0002z6-23 for larch@yhetil.org; Wed, 30 Jun 2021 16:51:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyh9t-00012V-JA for guix-patches@gnu.org; Wed, 30 Jun 2021 16:50:09 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyh9s-0001mv-OZ for guix-patches@gnu.org; Wed, 30 Jun 2021 16:50:09 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyh9s-0005DR-OE for guix-patches@gnu.org; Wed, 30 Jun 2021 16:50:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49169] [PATCH v2 15/16] import: print: Emit new-style package inputs when possible. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 30 Jun 2021 20:50:08 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49169 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49169@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 49169-submit@debbugs.gnu.org id=B49169.162508615719883 (code B ref 49169); Wed, 30 Jun 2021 20:50:08 +0000 Received: (at 49169) by debbugs.gnu.org; 30 Jun 2021 20:49:17 +0000 Received: from localhost ([127.0.0.1]:58950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyh93-0005AX-6J for submit@debbugs.gnu.org; Wed, 30 Jun 2021 16:49:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47928) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyh8q-00056t-R4 for 49169@debbugs.gnu.org; Wed, 30 Jun 2021 16:49:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53148) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyh8l-00011x-JA; Wed, 30 Jun 2021 16:48:59 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42586 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyh8l-0001jQ-BL; Wed, 30 Jun 2021 16:48:59 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Wed, 30 Jun 2021 22:48:31 +0200 Message-Id: <20210630204832.25753-16-ludo@gnu.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210630204832.25753-1-ludo@gnu.org> References: <20210622090221.15182-1-ludo@gnu.org> <20210630204832.25753-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625086281; 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; bh=ODckUIJWe3iGVdJHiKqAxqBU8x7iQd4QFgfBrOi3a+k=; b=gpS9WuhOKA5LAnueFOH+az8Lo4LKnnBSNeL/i5wR2hBLKPNF1wsnfzbmCsjOdQTXPAA3kg rZuIg0lFdrXqXUl9dJbL2btAYf+tAN2KcwVWEOZGVX9pjSTrCKDPVy6OmupwbhZTwDnaYl N+eB/pp+KU/4Q5AIbpDV6SwlaLcQ/qpZQa6k+68Mb2jCJ2FjMaZCCmFWYJ3Hb1B7kRWiWU TANGCIx4er63sglHJcRAbVs7YX1i9mRsPthYXgQbST1Z+fin2CykHnAMtK22gN+xxA6dDM 2Yz4wqPdsVyJXeagqyMEAtGpPBVA9NtAOXb+83jz4ehpxd5STesHQVVUTfL17g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625086281; a=rsa-sha256; cv=none; b=QFClKZl0SuVdLHGN/8cR4f+bB4/VQ6zS6x4/yBX4fkbI7ceHVeJvPxE/lC09zVsEQuZarX c8WlZr1edq5Fd6EY+u2dlFtgyXx8em98CFgu/Sl1DoH5Dzo2d7danDSS99P+I+cOMCeTtv 6OBNmFeQSjdM1RgknbaeDd91axIHYWROEiS3Iex+sSVgVMEEy/MTjtW+FwPHhLsYxfDS2i N1mgN7PCbNjSI4ZpA0kmR8k5D0WseCXSist3PgaCt0SZcyMLJIAD+te4C3Hk8wfAnbOMMD MgcNgkIf0mBFe/3ok4SDuAC/urN/ew25W893B8f1KnpNhSkCebGQw/7oN8yC9g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.42 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: EDD131D9DE X-Spam-Score: -0.42 X-Migadu-Scanner: scn1.migadu.com X-TUID: CV3vDdOA06oB * guix/import/print.scm (redundant-input-labels?): New procedure. (package->code)[package-lists->code]: Rename to... [inputs->code]: ... this. When 'redundant-input-labels?' returns true, emit label-less inputs. Adjust callers to new name. * tests/print.scm (pkg-with-inputs): Adjust accordingly. --- guix/import/print.scm | 57 +++++++++++++++++++++++++++++-------------- tests/print.scm | 4 +-- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/guix/import/print.scm b/guix/import/print.scm index dcc38abc70..77492e222c 100644 --- a/guix/import/print.scm +++ b/guix/import/print.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2020 Ricardo Wurmus +;;; Copyright © 2021 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -30,6 +31,14 @@ #:use-module (ice-9 match) #:export (package->code)) +(define (redundant-input-labels? inputs) + "Return #t if input labels in the INPUTS list are redundant." + (every (match-lambda + ((label (? package? package) . _) + (string=? label (package-name package))) + (_ #f)) + inputs)) + ;; FIXME: the quasiquoted arguments field may contain embedded package ;; objects, e.g. in #:disallowed-references; they will just be printed with ;; their usual # representation, not as variable names. @@ -104,21 +113,33 @@ when evaluated." ,@(if (null? patches) '() `((patches (search-patches ,@(map basename patches)))))))) - (define (package-lists->code lsts) - (list 'quasiquote - (map (match-lambda - ((? symbol? s) - (list (symbol->string s) (list 'unquote s))) - ((label pkg . out) - (let ((mod (package-module-name pkg))) - (cons* label - ;; FIXME: using '@ certainly isn't pretty, but it - ;; avoids having to import the individual package - ;; modules. - (list 'unquote - (list '@ mod (variable-name pkg mod))) - out)))) - lsts))) + (define (inputs->code inputs) + (if (redundant-input-labels? inputs) + `(list ,@(map (match-lambda ;no need for input labels ("new style") + ((_ package) + (let ((module (package-module-name package))) + `(@ ,module ,(variable-name package module)))) + ((_ package output) + (let ((module (package-module-name package))) + (list 'quasiquote + (list + (list 'unquote + `(@ ,module + ,(variable-name package module))) + output))))) + inputs)) + (list 'quasiquote ;preserve input labels (deprecated) + (map (match-lambda + ((label pkg . out) + (let ((mod (package-module-name pkg))) + (cons* label + ;; FIXME: using '@ certainly isn't pretty, but it + ;; avoids having to import the individual package + ;; modules. + (list 'unquote + (list '@ mod (variable-name pkg mod))) + out)))) + inputs)))) (let ((name (package-name package)) (version (package-version package)) @@ -160,13 +181,13 @@ when evaluated." (outs `((outputs (list ,@outs))))) ,@(match native-inputs (() '()) - (pkgs `((native-inputs ,(package-lists->code pkgs))))) + (pkgs `((native-inputs ,(inputs->code pkgs))))) ,@(match inputs (() '()) - (pkgs `((inputs ,(package-lists->code pkgs))))) + (pkgs `((inputs ,(inputs->code pkgs))))) ,@(match propagated-inputs (() '()) - (pkgs `((propagated-inputs ,(package-lists->code pkgs))))) + (pkgs `((propagated-inputs ,(inputs->code pkgs))))) ,@(if (lset= string=? supported-systems %supported-systems) '() `((supported-systems (list ,@supported-systems)))) diff --git a/tests/print.scm b/tests/print.scm index 3386590d3a..1b24e12f2e 100644 --- a/tests/print.scm +++ b/tests/print.scm @@ -60,8 +60,8 @@ (base32 "070pwb7brdcn1mfvplkd56vjc7lbz4iznzkqvfsakvgbv68k71ah")))) (build-system (@ (guix build-system gnu) gnu-build-system)) - (inputs `(("coreutils" ,(@ (gnu packages base) coreutils)) - ("glibc" ,(@ (gnu packages base) glibc) "debug"))) + (inputs (list (@ (gnu packages base) coreutils) + `(,(@ (gnu packages base) glibc) "debug"))) (home-page "http://gnu.org") (synopsis "Dummy") (description "This is a dummy package.") -- 2.32.0