From patchwork Wed Jul 21 02:59:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sarah Morgensen X-Patchwork-Id: 31545 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9D47927BC78; Wed, 21 Jul 2021 04:00:30 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1D3B327BC6B for ; Wed, 21 Jul 2021 04:00:30 +0100 (BST) Received: from localhost ([::1]:51130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m62TF-0008Pn-76 for patchwork@mira.cbaines.net; Tue, 20 Jul 2021 23:00:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m62So-0008Pe-Ks for guix-patches@gnu.org; Tue, 20 Jul 2021 23:00:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m62So-0005GV-Cf for guix-patches@gnu.org; Tue, 20 Jul 2021 23:00:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m62So-0005Bl-66 for guix-patches@gnu.org; Tue, 20 Jul 2021 23:00:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49531] [PATCH core-updates v2] import: go: Emit new-style package inputs. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 21 Jul 2021 03:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49531 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49531@debbugs.gnu.org Received: via spool by 49531-submit@debbugs.gnu.org id=B49531.162683636619870 (code B ref 49531); Wed, 21 Jul 2021 03:00:02 +0000 Received: (at 49531) by debbugs.gnu.org; 21 Jul 2021 02:59:26 +0000 Received: from localhost ([127.0.0.1]:35872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m62SD-0005AQ-Sz for submit@debbugs.gnu.org; Tue, 20 Jul 2021 22:59:26 -0400 Received: from out0.migadu.com ([94.23.1.103]:10295) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m62SC-0005AG-0d for 49531@debbugs.gnu.org; Tue, 20 Jul 2021 22:59:24 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1626836363; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mgi+35eUW3nj7GAWadm97uw3eBJ/oBfgqCmxnZjGwaA=; b=jiEMUeLbvacClhv4AhjZkQ4T0eNRfEbEgy9D586bE+XKcCtzuvAyL95YgJs3kc9YK3Ped8 QhFk4yXEiuZaITfqfulqp+6r282KF56X+m4+tt/I2VqcJfKgjn4eQ9a1ksP+0XmLeXFYmm dFX9L/j2GVQz8RAlRyCa1v4CrvVhJNY= From: Sarah Morgensen Date: Tue, 20 Jul 2021 19:59:21 -0700 Message-Id: <21e16bafbc6af293e7916b92af8fa9ece38a7483.1626832035.git.iskarian@mgsn.dev> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: iskarian@mgsn.dev 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Since PACKAGE-NAMES->PACKAGE-INPUTS is used by both the go and crate importers, give the crate importer a copy of the original so it continues to use old-style inputs until it is updated. * guix/import/utils.scm (package-names->package-inputs)[make-input]: Return new-style package inputs. (maybe-inputs): Wrap PACKAGE-INPUTS in 'list' instead of 'quasiquote'. * guix/import/crate.scm (package-names->package-inputs): New variable. * tests/go.scm ("go-module->guix-package"): Adjust to new-style package inputs. --- This patch narrows the scope to just the go importer; the crate importer can be handled separately. guix/import/crate.scm | 18 ++++++++++++++++++ guix/import/utils.scm | 13 ++++++------- tests/go.scm | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) base-commit: b15c3dd9b0e9cf6858f730e1d46c35ed9ab6a758 diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 287ffd2536..fa8f7bf096 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2019, 2020 Ludovic Courtès ;;; Copyright © 2019, 2020 Martin Becze ;;; Copyright © 2021 Nicolas Goaziou +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -132,6 +133,23 @@ record or #f if it was not found." ;;; Converting crates to Guix packages. ;;; +(define* (package-names->package-inputs names #:optional (output #f)) + "Given a list of PACKAGE-NAMES or (PACKAGE-NAME VERSION) pairs, and an +optional OUTPUT, tries to generate a quoted list of inputs, as suitable to +use in an 'inputs' field of a package definition." + (define (make-input input version) + (cons* input (list 'unquote (string->symbol + (if version + (string-append input "-" version) + input))) + (or (and output (list output)) + '()))) + + (map (match-lambda + ((input version) (make-input input version)) + (input (make-input input #f))) + names)) + (define (maybe-cargo-inputs package-names) (match (package-names->package-inputs package-names) (() diff --git a/guix/import/utils.scm b/guix/import/utils.scm index d817318a91..8fa017e18f 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com> ;;; Copyright © 2020 Martin Becze ;;; Copyright © 2021 Maxim Cournoyer +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -237,12 +238,10 @@ into a proper sentence and by using two spaces between sentences." optional OUTPUT, tries to generate a quoted list of inputs, as suitable to use in an 'inputs' field of a package definition." (define (make-input input version) - (cons* input (list 'unquote (string->symbol - (if version - (string-append input "-" version) - input))) - (or (and output (list output)) - '()))) + (let ((name (if version (string-append input "-" version) input))) + (if output + (list (string->symbol name) output) + (string->symbol name)))) (map (match-lambda ((input version) (make-input input version)) @@ -263,7 +262,7 @@ snippet generated is for regular inputs." (() '()) ((package-inputs ...) - `((,field-name (,'quasiquote ,package-inputs))))))) + `((,field-name (list ,@package-inputs))))))) (define* (maybe-native-inputs package-names #:optional (output #f)) "Same as MAYBE-INPUTS, but for native inputs." diff --git a/tests/go.scm b/tests/go.scm index 6749f4585f..743cffb023 100644 --- a/tests/go.scm +++ b/tests/go.scm @@ -389,7 +389,7 @@ require github.com/kr/pretty v0.2.1 (arguments '(#:import-path "github.com/go-check/check")) (propagated-inputs - `(("go-github-com-kr-pretty" ,go-github-com-kr-pretty))) + (list go-github-com-kr-pretty)) (home-page "https://github.com/go-check/check") (synopsis "Instructions") (description "Package check is a rich testing extension for Go's testing \