Message ID | 33ce44c6b5dc4f0c2ea2cf7a8402807d91e849a6.1631791821.git.public@yoctocell.xyz |
---|---|
State | Accepted |
Headers | show |
Series | [bug#50618] import: stackage: Don’t try to update packages not available on Stackage. | expand |
Context | Check | Description |
---|---|---|
cbaines/applying patch | fail | View Laminar job |
cbaines/issue | success | View issue |
Hi, > +(define (stackage-package? package) > + "Whether PACKAGE is available on the default Stackage LTS release." > + (and (hackage-package? package) > + (guard (c ((and (http-get-error? c) > + (= 404 (http-get-error-code c))) > + #f)) > + (let* ((name (guix-package->hackage-name package)) > + (url (string-append (%stackage-url) "/lts-" > + %default-lts-version "/package/" name))) > + (http-fetch url))))) > + since stackage-lts-info-fetch is memoized, wouldn’t it be cheaper to look up the package there? (At least for lots of packages.) Cheers, Lars
On Wed, Sep 22 2021, Lars-Dominik Braun wrote: > Hi, > >> +(define (stackage-package? package) >> + "Whether PACKAGE is available on the default Stackage LTS release." >> + (and (hackage-package? package) >> + (guard (c ((and (http-get-error? c) >> + (= 404 (http-get-error-code c))) >> + #f)) >> + (let* ((name (guix-package->hackage-name package)) >> + (url (string-append (%stackage-url) "/lts-" >> + %default-lts-version "/package/" name))) >> + (http-fetch url))))) >> + > since stackage-lts-info-fetch is memoized, wouldn’t it be cheaper > to look up the package there? (At least for lots of packages.) Ah, good idea! I will test if what the difference is terms of time.
diff --git a/guix/import/stackage.scm b/guix/import/stackage.scm index bbd903a2cd..5b19e2a03a 100644 --- a/guix/import/stackage.scm +++ b/guix/import/stackage.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2017 Federico Beffa <beffa@fbengineering.ch> ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net> +;;; Copyright © 2021 Xinglu Chem <public@yoctocell.xyz> ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,6 +26,7 @@ #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) + #:use-module (guix http-client) #:use-module (guix import json) #:use-module (guix import hackage) #:use-module (guix import utils) @@ -141,11 +143,22 @@ PACKAGE or #f if the package is not included in the Stackage LTS release." (version version) (urls (list url)))))))))) +(define (stackage-package? package) + "Whether PACKAGE is available on the default Stackage LTS release." + (and (hackage-package? package) + (guard (c ((and (http-get-error? c) + (= 404 (http-get-error-code c))) + #f)) + (let* ((name (guix-package->hackage-name package)) + (url (string-append (%stackage-url) "/lts-" + %default-lts-version "/package/" name))) + (http-fetch url))))) + (define %stackage-updater (upstream-updater (name 'stackage) (description "Updater for Stackage LTS packages") - (pred hackage-package?) + (pred stackage-package?) (latest latest-lts-release))) ;;; stackage.scm ends here