From patchwork Wed Mar 15 12:51:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 11018 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 868A416C76; Wed, 15 Mar 2023 12:52:34 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 57D6F16961 for ; Wed, 15 Mar 2023 12:52:33 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcQbu-0003Po-K5; Wed, 15 Mar 2023 08:52:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcQbr-0003Oc-MZ for guix-patches@gnu.org; Wed, 15 Mar 2023 08:52:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcQbr-00038U-AT for guix-patches@gnu.org; Wed, 15 Mar 2023 08:52:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pcQbr-0001YI-5W for guix-patches@gnu.org; Wed, 15 Mar 2023 08:52:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62202] [PATCH 02/21] import: utils: Change git->origin function to git->origin+version. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 15 Mar 2023 12:52:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62202 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62202@debbugs.gnu.org Cc: ngraves@ngraves.fr Received: via spool by 62202-submit@debbugs.gnu.org id=B62202.16788847065825 (code B ref 62202); Wed, 15 Mar 2023 12:52:03 +0000 Received: (at 62202) by debbugs.gnu.org; 15 Mar 2023 12:51:46 +0000 Received: from localhost ([127.0.0.1]:39295 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcQbZ-0001Vh-9L for submit@debbugs.gnu.org; Wed, 15 Mar 2023 08:51:45 -0400 Received: from 7.mo560.mail-out.ovh.net ([188.165.48.182]:58983) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcQbV-0001VN-GV for 62202@debbugs.gnu.org; Wed, 15 Mar 2023 08:51:42 -0400 Received: from director9.ghost.mail-out.ovh.net (unknown [10.108.4.60]) by mo560.mail-out.ovh.net (Postfix) with ESMTP id C19E420C7E for <62202@debbugs.gnu.org>; Wed, 15 Mar 2023 12:51:39 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-lqxrt (unknown [10.110.115.9]) by director9.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 114611FE98; Wed, 15 Mar 2023 12:51:38 +0000 (UTC) Received: from ngraves.fr ([37.59.142.103]) by ghost-submission-6684bf9d7b-lqxrt with ESMTPSA id lnghCFq/EWTd1wAA847UKw (envelope-from ); Wed, 15 Mar 2023 12:51:38 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-103G005a188a3de-ed7c-44b7-9f37-8c222b24d13f, F74D9BBE9ED44B45FF66447495DD0B0753EB5D4A) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 81.67.140.142 Date: Wed, 15 Mar 2023 13:51:11 +0100 Message-Id: <20230315125130.23041-2-ngraves@ngraves.fr> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315125130.23041-1-ngraves@ngraves.fr> References: <20230315125130.23041-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 13788614688387621602 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvddvkedggeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepfefgvdfhuedtffelffdvfefftdeffeefudfgfeegheffieeuueegvdduheefteffnecuffhomhgrihhnpehsphgugidrohhrghenucfkphepuddvjedrtddrtddruddpfeejrdehledrudegvddruddtfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqpdhnsggprhgtphhtthhopedupdhrtghpthhtohepiedvvddtvdesuggvsggsuhhgshdrghhnuhdrohhrghdpoffvtefjohhsthepmhhoheeitddpmhhouggvpehsmhhtphhouhht 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: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches --- guix/import/go.scm | 2 +- guix/import/utils.scm | 50 +++++++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index f264715fbd..3be82ed164 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -510,7 +510,7 @@ (define* (vcs->origin vcs-type vcs-repo-url version which takes version as an input." (case vcs-type ((git) - (git->origin vcs-repo-url `(tag-or-commit . ,version) transform-version)) + (git->origin vcs-repo-url `(tag-or-commit . ,version) transform-version)) ((hg) `(origin (method hg-fetch) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 529d7f11f8..171dca54e8 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -65,6 +65,7 @@ (define-module (guix import utils) url-fetch guix-hash-url + git->origin+dir git->origin package-names->package-inputs @@ -156,9 +157,12 @@ (define (guix-hash-url filename) "Return the hash of FILENAME in nix-base32 format." (bytevector->nix-base32-string (file-sha256 filename))) -(define* (git->origin repo-url ref #:optional ref->commit) - "Generate the `origin' block of a package depending on the git source -control system. REPO-URL or REF can be null." +(define* (git->origin+dir repo-url ref #:optional ref->commit) + "Returns a generated `origin' block of a package depending on the git source +control system, and the directory in the store where the package has been +downloaded, in case further processing is necessary. REPO-URL or REF can be +null. REF->COMMIT can be a function or #t, in which case the commit matching +ref is used. If REF->COMMIT is not used, the value inside REF is used." (let-values (((directory commit) (with-store store (latest-repository-commit store repo-url #:ref ref)))) @@ -172,21 +176,31 @@ (define* (git->origin repo-url ref #:optional ref->commit) version) (_ (ref->commit version))))) - `(origin - (method git-fetch) - (uri (git-reference - (url ,(and (not (eq? repo-url 'null)) repo-url)) - (commit ,vcommit))) - (file-name (git-file-name name version)) - (sha256 - (base32 - ,(if (pair? ref) - (bytevector->nix-base32-string - (file-hash* directory - ;; 'git-fetch' already filtered out the '.git' directory. - #:select? (const #true) - #:recursive? #true)) - #f))))))) + (values + `(origin + (method git-fetch) + (uri (git-reference + (url ,(and (not (eq? repo-url 'null)) repo-url)) + (commit ,vcommit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + ,(if (pair? ref) + (bytevector->nix-base32-string + (file-hash* directory + ;; 'git-fetch' already filtered out the '.git' directory. + #:select? (const #true) + #:recursive? #true)) + #f)))) + directory)))) + +(define* (git->origin repo-url ref #:optional ref->commit) + "Returns a generated `origin' block of a package depending on the git source +control system. REPO-URL or REF can be null. REF->COMMIT can be a function or +#t, in which case the commit matching ref is used. If REF->COMMIT is not used, +the value inside REF is used." + (let-values (((origin _) (git->origin+dir repo-url ref ref->commit))) + origin)) (define %spdx-license-identifiers ;; https://spdx.org/licenses/