From patchwork Tue Oct 29 13:53:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 69619 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 7075B27BBE2; Tue, 29 Oct 2024 13:55:23 +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=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, 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 5772927BBE9 for ; Tue, 29 Oct 2024 13:55:20 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5mgb-0000CO-Jq; Tue, 29 Oct 2024 09:55:06 -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 1t5mgY-0000AD-SX for guix-patches@gnu.org; Tue, 29 Oct 2024 09:55:03 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5mgY-0003iy-Bw for guix-patches@gnu.org; Tue, 29 Oct 2024 09:55:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=R3A178bNmJT/jN/X1syVBzPpwIHFtVu5ZqAAdm+sXm4=; b=HRuGiOA8Ks3QWJejTZ9WyxTPp4hESARFKhGMxxJmPphVJ7EHgoq1HIdA/dyg2qeEERkyWphDodHZgfkXc+uz/PCSaB6K4U1O0dqP0muPJKKTVIWcfLhRpIkTXUJvUJZ8soJa77/s8Gw5SXn1GTNIhNwH4hGjAG4ozWSnkOEGOnKj1SexB870ppj/mUbYWcFESmt9p2SZtS6EyLglRWnLHTrNa9LVbZRYddanB/rI/vXnZkwgn1zyItPAmULvS5AITSSJJbyFDct46OgNFk3H6q6AOvIqVr39oZH7Gy3aqOVX1wVosoOyaD8HJDCIY9rrdWaQXzXKnPl3JnFsb/7YLQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t5mgY-0005c0-5U for guix-patches@gnu.org; Tue, 29 Oct 2024 09:55:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#74086] [PATCH] guix: import: hackage: Support updating to a specific version. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 29 Oct 2024 13:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74086 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74086@debbugs.gnu.org Cc: Nicolas Graves X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.173021005021516 (code B ref -1); Tue, 29 Oct 2024 13:55:01 +0000 Received: (at submit) by debbugs.gnu.org; 29 Oct 2024 13:54:10 +0000 Received: from localhost ([127.0.0.1]:56470 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5mfh-0005as-6X for submit@debbugs.gnu.org; Tue, 29 Oct 2024 09:54:09 -0400 Received: from lists.gnu.org ([209.51.188.17]:44782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5mff-0005am-68 for submit@debbugs.gnu.org; Tue, 29 Oct 2024 09:54:08 -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 1t5mfe-00006x-F8 for guix-patches@gnu.org; Tue, 29 Oct 2024 09:54:07 -0400 Received: from 5.mo581.mail-out.ovh.net ([178.32.120.239]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5mfZ-0003dx-J7 for guix-patches@gnu.org; Tue, 29 Oct 2024 09:54:06 -0400 Received: from director11.ghost.mail-out.ovh.net (unknown [10.108.17.183]) by mo581.mail-out.ovh.net (Postfix) with ESMTP id 4XdBYx1lygz1F5f for ; Tue, 29 Oct 2024 13:53:57 +0000 (UTC) Received: from ghost-submission-5b5ff79f4f-nzvfc (unknown [10.108.42.46]) by director11.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 99ADD1FE31; Tue, 29 Oct 2024 13:53:56 +0000 (UTC) Received: from ngraves.fr ([37.59.142.108]) by ghost-submission-5b5ff79f4f-nzvfc with ESMTPSA id BSDNBvToIGeamggAfSYmxw (envelope-from ); Tue, 29 Oct 2024 13:53:56 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-108S002c769bfa9-9b29-46e0-9d9d-af36ced29e4c, 0CE63A758BBAB584BC146B19CC27A6CF98533BD7) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 86.246.19.221 Date: Tue, 29 Oct 2024 14:53:51 +0100 Message-ID: <20241029135354.17423-1-ngraves@ngraves.fr> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Ovh-Tracer-Id: 16786323186188477154 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeftddrvdekuddgheefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffogggtgfesthekredtredtjeenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpedtleelfedvveehuedtveffgeegteeifeffvefftedvleegvdevgeeuieelgeeuveenucffohhmrghinhephhgrshhkvghllhdrohhrghenucfkphepuddvjedrtddrtddruddpkeeirddvgeeirdduledrvddvuddpfeejrdehledrudegvddruddtkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepghhuihigqdhprghttghhvghssehgnhhurdhorhhgpdfovfetjfhoshhtpehmohehkedupdhmohguvgepshhmthhpohhuth DKIM-Signature: a=rsa-sha256; bh=R3A178bNmJT/jN/X1syVBzPpwIHFtVu5ZqAAdm+sXm4=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1730210037; v=1; b=W+fgb9rVwXPM9TeGkUOYSxruiHGS/ccPtlpYH0N9dpN1QimjnNpAKdDnrIrQJjf2NlPCYME3 X7OoiYBY3LM8FYdwwKuQb4ChdNte4LdG0PNwD/q20hM17kfdWZtLGmP0Y8/Sh0qXGQCc6DVSuOX xm52O8JCbZZKzoSizoXjk9saNR/cF4lFdMaBkz7TvGk3j/GCDtzK8osNa4GRTuOivxFlEKB+P7G +q+9W7ao4Wrb9hFl146Dg0qkIr4n7HiSgVkovLZj/oWxZPL+NZSct7z33jbqBkSf1crMXKXJ8IV 7wowiiOmsaaMeurIpcZjwCVHdOdUthulPSEzRwTdSXvtA== Received-SPF: pass client-ip=178.32.120.239; envelope-from=ngraves@ngraves.fr; helo=5.mo581.mail-out.ovh.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 * gnu/import/hackage.scm (hackage-fetch-and-hash, hackage-fetch): Support name and version argument. (import-release): New variable, formerly known as latest-release. Support updating to a specific version. --- guix/import/hackage.scm | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm index 79a51d3300..e3ed98c089 100644 --- a/guix/import/hackage.scm +++ b/guix/import/hackage.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2019 Simon Tournier ;;; Copyright © 2022 Hartmut Goebel ;;; Copyright © 2023-2024 Ludovic Courtès +;;; Copyright © 2024 Nicolas Graves ;;; ;;; This file is part of GNU Guix. ;;; @@ -136,7 +137,7 @@ (define (read-cabal-and-hash port) (values (read-cabal (canonical-newline-port port)) (bytevector->nix-base32-string (get-hash))))) -(define (hackage-fetch-and-hash name-version) +(define (hackage-fetch-and-hash name version) "Fetch the latest Cabal revision for the package NAME-VERSION, and return two values: the parsed Cabal file and its hash in nix-base32 format. If the version part is omitted from the package name, then fetch the latest @@ -144,18 +145,19 @@ (define (hackage-fetch-and-hash name-version) (guard (c ((and (http-get-error? c) (= 404 (http-get-error-code c))) (values #f #f))) ;"expected" if package is unknown - (let* ((name version (package-name->name+version name-version)) - (url (hackage-cabal-url name version)) - (port _ (http-fetch url)) - (cabal hash (read-cabal-and-hash port))) + (let* ((name new-version (package-name->name+version name)) + (version (or version new-version)) + (url (hackage-cabal-url name version)) + (port _ (http-fetch url)) + (cabal hash (read-cabal-and-hash port))) (close-port port) (values cabal hash)))) -(define (hackage-fetch name-version) +(define (hackage-fetch name version) "Return the Cabal file for the package NAME-VERSION, or #f on failure. If the version part is omitted from the package name, then return the latest version." - (let ((cabal hash (hackage-fetch-and-hash name-version))) + (let ((cabal hash (hackage-fetch-and-hash name version))) cabal)) (define string->license @@ -377,15 +379,10 @@ (define hackage-package? (let ((hackage-rx (make-regexp "(https?://hackage.haskell.org|mirror://hackage/)"))) (url-predicate (cut regexp-exec hackage-rx <>)))) -(define* (latest-release package #:key (version #f)) +(define* (import-release package #:key (version #f)) "Return an for the latest release of PACKAGE." - (when version - (raise - (formatted-message - (G_ "~a updater doesn't support updating to a specific version, sorry.") - "hackage"))) (let* ((hackage-name (package-upstream-name* package)) - (cabal-meta (hackage-fetch hackage-name))) + (cabal-meta (hackage-fetch hackage-name version))) (match cabal-meta (#f (format (current-error-port) @@ -407,6 +404,6 @@ (define %hackage-updater (name 'hackage) (description "Updater for Hackage packages") (pred hackage-package?) - (import latest-release))) + (import import-release))) ;;; cabal.scm ends here