From 4332502000bd06a2be900c236666d10f07777807 Mon Sep 17 00:00:00 2001 Message-Id: <4332502000bd06a2be900c236666d10f07777807.1640522590.git.public@yoctocell.xyz> From: Xinglu Chen Date: Thu, 23 Dec 2021 22:08:33 +0100 Subject: [PATCH] import: elpa: Also check NonGNU ELPA for updates. * elpa.scm (latest-release): Determine the repository based on the URL of the source. (package-from-gnu.org?): Rename to ... (elpa-repository): ...this; memoize. (elpa-package?): New procedure. (%elpa-updater): Adjust accordingly. --- guix/import/elpa.scm | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm index edabb88b7a..a03df5167e 100644 --- a/guix/import/elpa.scm +++ b/guix/import/elpa.scm @@ -44,6 +44,7 @@ (define-module (guix import elpa) #:use-module (guix base32) #:use-module (guix upstream) #:use-module (guix packages) + #:use-module (guix memoization) #:use-module ((guix utils) #:select (call-with-temporary-output-file)) #:export (elpa->guix-package guix-package->elpa-name @@ -424,7 +425,7 @@ (define (guix-package->elpa-name package) (define (latest-release package) "Return an for the latest release of PACKAGE." (define name (guix-package->elpa-name package)) - (define repo 'gnu) + (define repo (elpa-repository package)) (match (elpa-package-info name repo) (#f @@ -443,11 +444,20 @@ (define repo 'gnu) (urls (list url)) (signature-urls (list (string-append url ".sig")))))))) -(define package-from-gnu.org? - (url-predicate (lambda (url) - (let ((uri (string->uri url))) - (and uri - (string=? (uri-host uri) "elpa.gnu.org")))))) +(define elpa-repository + (memoize + (url-predicate (lambda (url) + (let ((uri (string->uri url))) + (and uri + (cond + ((string=? (uri-host uri) "elpa.gnu.org") + 'gnu) + ((string=? (uri-host uri) "elpa.nongnu.org") + 'nongnu) + (else #f)))))))) + +(define (elpa-package? package) + (member (elpa-repository package) '(gnu nongnu))) (define %elpa-updater ;; The ELPA updater. We restrict it to packages hosted on elpa.gnu.org @@ -455,7 +465,7 @@ (define %elpa-updater (upstream-updater (name 'elpa) (description "Updater for ELPA packages") - (pred package-from-gnu.org?) + (pred elpa-package?) (latest latest-release))) (define elpa-guix-name (cut guix-name "emacs-" <>)) base-commit: 2495582e08cf411163f0799d290fda5101141949 -- 2.33.1