[PATCH] guix: import: hackage: Support updating to a specific version.

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Nicolas Graves
Owner
unassigned
Submitted by
Nicolas Graves
Severity
normal
N
N
Nicolas Graves wrote on 29 Oct 14:53 +0100
(address . guix-patches@gnu.org)(name . Nicolas Graves)(address . ngraves@ngraves.fr)
20241029135354.17423-1-ngraves@ngraves.fr
* 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(-)

Toggle diff (75 lines)
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 <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2023-2024 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
;;;
;;; 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 <upstream-source> 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
--
2.46.0
L
L
Ludovic Courtès wrote on 14 Nov 15:52 +0100
(name . Nicolas Graves)(address . ngraves@ngraves.fr)(address . 74086-done@debbugs.gnu.org)
87ed3doojd.fsf@gnu.org
Hi,

Nicolas Graves <ngraves@ngraves.fr> skribis:

Toggle quote (6 lines)
> * 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.

Nice. Applied with the fix below (spotted a compiler warning).

Thanks,
Ludo’.
Toggle diff (13 lines)
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index e3ed98c089..422887d435 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -357,7 +357,7 @@ (define* (hackage->guix-package package-name #:key
(let ((cabal-meta cabal-hash
(if port
(read-cabal-and-hash port)
- (hackage-fetch-and-hash package-name))))
+ (hackage-fetch-and-hash package-name #f))))
(if cabal-meta
(hackage-module->sexp (eval-cabal cabal-meta cabal-environment)
cabal-hash
Closed
N
N
Nicolas Graves wrote on 14 Nov 18:07 +0100
Re: bug#74086: [PATCH] guix: import: hackage: Support updating to a specific version.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 74086-done@debbugs.gnu.org)
87cyixn3qd.fsf@ngraves.fr
On 2024-11-14 15:52, Ludovic Courtès wrote:

Toggle quote (12 lines)
> Hi,
>
> Nicolas Graves <ngraves@ngraves.fr> skribis:
>
>> * 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.
>
> Nice. Applied with the fix below (spotted a compiler warning).

Oh there's also one call in stackage.scm that would require a trailing
#f too.

I've got a couple more patches on hackage/stackage updates, but I'll
first wait on the import/composer and cve/cpe-vendor discussions ;)

--
Best regards,
Nicolas Graves
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 74086@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 74086
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch