From patchwork Fri Oct 29 21:35:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34141 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 57B2D27BBE3; Fri, 29 Oct 2021 23:00:02 +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_H2,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 BC14627BBE1 for ; Fri, 29 Oct 2021 23:00:01 +0100 (BST) Received: from localhost ([::1]:44190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgZuq-0003uO-MP for patchwork@mira.cbaines.net; Fri, 29 Oct 2021 18:00:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgZXe-0002Oa-Pf for guix-patches@gnu.org; Fri, 29 Oct 2021 17:36:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgZXe-0002kf-GD for guix-patches@gnu.org; Fri, 29 Oct 2021 17:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mgZXe-0006EG-DD for guix-patches@gnu.org; Fri, 29 Oct 2021 17:36:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51493] [PATCH 3/5] import: print: Properly render packages with origins as inputs. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 29 Oct 2021 21:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51493 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51493@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51493-submit@debbugs.gnu.org id=B51493.163554335623917 (code B ref 51493); Fri, 29 Oct 2021 21:36:02 +0000 Received: (at 51493) by debbugs.gnu.org; 29 Oct 2021 21:35:56 +0000 Received: from localhost ([127.0.0.1]:56149 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgZXY-0006Db-Bv for submit@debbugs.gnu.org; Fri, 29 Oct 2021 17:35:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgZXW-0006Cy-Bj for 51493@debbugs.gnu.org; Fri, 29 Oct 2021 17:35:54 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:58440) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgZXR-0002LS-3t; Fri, 29 Oct 2021 17:35:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=5rhw3BGgjnCC/1I96MdYzoPr5bwwelqFxUt+gHDrjb4=; b=C6dF2cWdlZ7FeEq9C8ir mxdqYSJORVCO4Mh9DKAo5b6gSJFnnk1apCI4aQEcQsN7jzwJO3cT/y81WkCdXC/xlQl4MwFAGCOyP Uf4vBaUJGv11y+izZW17pwsG0qOexue2yvBCeTR9TNI0hjoNghda6SDyn3RGojAOmxAqLEDGvE/N3 8MG2z1J0LzzD8gqt4cVgfCjBwwaJVl4b16ig6KpsyrYFrZyj3ezohtsMWWuR1S4kC2ISX2mPGB3Kg Nxp+b8JVL1uDGvyoKUwSN63J+8GGbPbudPRKoO3FICrTNaK0KWFK5mkO+l3ntbsmjcI+ehWO4bnA5 qZ3bS6YLG/n8qQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:55462 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 1mgZXQ-0002gP-Nu; Fri, 29 Oct 2021 17:35:48 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 29 Oct 2021 23:35:37 +0200 Message-Id: <20211029213539.30291-3-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211029213539.30291-1-ludo@gnu.org> References: <20211029213539.30291-1-ludo@gnu.org> MIME-Version: 1.0 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 * guix/import/print.scm (package->code)[source->code]: Check whether VERSION is true before calling 'factorize-uri'. [package-lists->code]: Add clause for inputs that are origins. * tests/print.scm (pkg-with-origin-input, pkg-with-origin-input-source): New variables. ("package with origin input"): New test. --- guix/import/print.scm | 14 +++++++++----- tests/print.scm | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/guix/import/print.scm b/guix/import/print.scm index 0310739b3a..8acf5d52f6 100644 --- a/guix/import/print.scm +++ b/guix/import/print.scm @@ -89,9 +89,11 @@ (define (source->code source version) (guix hg-download) (guix svn-download))) (procedure-name method))) - (uri (string-append ,@(match (factorize-uri uri version) - ((? string? uri) (list uri)) - (factorized factorized)))) + (uri ,(if version + `(string-append ,@(match (factorize-uri uri version) + ((? string? uri) (list uri)) + (factorized factorized))) + uri)) ,(if (equal? (content-hash-algorithm hash) 'sha256) `(sha256 (base32 ,(bytevector->nix-base32-string (content-hash-value hash)))) @@ -109,7 +111,7 @@ (define (package-lists->code lsts) (map (match-lambda ((? symbol? s) (list (symbol->string s) (list 'unquote s))) - ((label pkg . out) + ((label (? package? pkg) . out) (let ((mod (package-module-name pkg))) (cons* label ;; FIXME: using '@ certainly isn't pretty, but it @@ -117,7 +119,9 @@ (define (package-lists->code lsts) ;; modules. (list 'unquote (list '@ mod (variable-name pkg mod))) - out)))) + out))) + ((label (? origin? origin)) + (list label (list 'unquote (source->code origin #f))))) lsts))) (let ((name (package-name package)) diff --git a/tests/print.scm b/tests/print.scm index 3386590d3a..ad19f4573a 100644 --- a/tests/print.scm +++ b/tests/print.scm @@ -67,6 +67,30 @@ (define-with-source pkg-with-inputs pkg-with-inputs-source (description "This is a dummy package.") (license license:gpl3+))) +(define-with-source pkg-with-origin-input pkg-with-origin-input-source + (package + (name "test") + (version "1.2.3") + (source (origin + (method url-fetch) + (uri (string-append "file:///tmp/test-" + version ".tar.gz")) + (sha256 + (base32 + "070pwb7brdcn1mfvplkd56vjc7lbz4iznzkqvfsakvgbv68k71ah")))) + (build-system (@ (guix build-system gnu) gnu-build-system)) + (inputs + `(("o" ,(origin + (method url-fetch) + (uri "http://example.org/somefile.txt") + (sha256 + (base32 + "0000000000000000000000000000000000000000000000000000")))))) + (home-page "http://gnu.org") + (synopsis "Dummy") + (description "This is a dummy package.") + (license license:gpl3+))) + (test-equal "simple package" `(define-public test ,pkg-source) (package->code pkg)) @@ -75,4 +99,8 @@ (define-with-source pkg-with-inputs pkg-with-inputs-source `(define-public test ,pkg-with-inputs-source) (package->code pkg-with-inputs)) +(test-equal "package with origin input" + `(define-public test ,pkg-with-origin-input-source) + (package->code pkg-with-origin-input)) + (test-end "print")