From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +GAxIN9ufGHgxAAAgWs5BA (envelope-from ) for ; Fri, 29 Oct 2021 23:59:59 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id aO7iG99ufGG5EQAAB5/wlQ (envelope-from ) for ; Fri, 29 Oct 2021 21:59:59 +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 338C3DBE3 for ; Fri, 29 Oct 2021 23:59:59 +0200 (CEST) Received: from localhost ([::1]:44190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgZuo-0003uO-Az for larch@yhetil.org; Fri, 29 Oct 2021 17:59:58 -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 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=1635544799; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=5rhw3BGgjnCC/1I96MdYzoPr5bwwelqFxUt+gHDrjb4=; b=aO+8IBmwL3KC2OL40qq/LgpZ+o4OylmEyTnQ6OXJQpEoKCTutPHdWWPtjuGAcRnZWlMXSg rJtBcrHfIqOxIC0SbEl9WX0jMjAn7v6mzCA9tsDOIYfeUuGbVL6I/vY3TwD4aCIunR8EGU vagvVdW9N7wmLw9fyOxqxZIJpDOaXkw0g9gMqtdvOWwlyBw7AA9M4uGUkhOrILqhrSFN+E sjKs1XwbuxdxUURESMJwJBN6OcYub9GVYICcaZUwQDabr3m16Tc1Ru28ne5RH89YuGS3h5 Eh5HvOuo4BunMXVcMgh1xJwTEZpb+IZb99WhZ+nhW6tGWF1+k0pSRBDH5zOXgw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1635544799; a=rsa-sha256; cv=none; b=ZjOL3mpZjySiMHlZSli1S5EV8TsjVsaKMY+g43EH/Um4i3t0c5YEI2m1ti78glXadF/L+m bdJ8GzLPZ7yq76WYIeCbq3vXh0YugfkTXjrSZdSdFXvVj+Nl9L6CK5Z+s595u0dHZqcXW1 3m+upsbuzrE9CYkW5kYUQndeJNQTQNchNZnnaEaQxBAlqBzQiBpOtibv45CzpWPg5NX73a VT6CU6FvMY4X/JDvm63oX9NE+bljAYFpBwE1q9T40PATuwZqOQme4vmBQqGk0esvJIk7NL kH+oGtSz7XgOxTtS8zsp/StYUJyOVSMOPzT7PzOEWYwH4mXkN0UFrkdZfM/8SQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=C6dF2cWd; 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: 2.08 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=C6dF2cWd; 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: 338C3DBE3 X-Spam-Score: 2.08 X-Migadu-Scanner: scn0.migadu.com X-TUID: 2H69jX3U3xj3 * 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") -- 2.33.0