summaryrefslogtreecommitdiff
path: root/guix/import/cpan.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-07-03 22:45:21 +0200
committerLudovic Courtès <ludo@gnu.org>2020-07-03 23:53:31 +0200
commit00290e7365aed9b34603bfb3cd6e8a4bdc1e7259 (patch)
tree8ae5c67671bb571101eaf25c145dbe31230efed8 /guix/import/cpan.scm
parent37c3e0bbaf2efe137b434f866ca431803d33e0a9 (diff)
downloadguix-patches-00290e7365aed9b34603bfb3cd6e8a4bdc1e7259.tar
guix-patches-00290e7365aed9b34603bfb3cd6e8a4bdc1e7259.tar.gz
upstream: Define 'url-predicate' and use it.
* guix/upstream.scm (url-predicate): New procedure. (url-prefix-predicate): Define in terms of 'url-predicate'. * guix/import/cpan.scm (cpan-package?): Use 'url-predicate'. * guix/import/cran.scm (cran-package?) (bioconductor-package?) (bioconductor-data-package?) (bioconductor-experiment-package?): Likewise. * guix/import/crate.scm (crate-package?): Likewise. * guix/import/elpa.scm (package-from-gnu.org?): Likewise. * guix/import/hackage.scm (hackage-package?): Likewise. * guix/import/pypi.scm (pypi-package?): Likewise. * guix/import/gem.scm (gem-package?): Use 'url-prefix-predicate'.
Diffstat (limited to 'guix/import/cpan.scm')
-rw-r--r--guix/import/cpan.scm26
1 files changed, 7 insertions, 19 deletions
diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm
index 6bcd2ce9eb..085467b871 100644
--- a/guix/import/cpan.scm
+++ b/guix/import/cpan.scm
@@ -316,25 +316,13 @@ in RELEASE, a <cpan-release> record."
(let ((release (cpan-fetch (module->name module-name))))
(and=> release cpan-module->sexp)))
-(define (cpan-package? package)
- "Return #t if PACKAGE is a package from CPAN."
- (define cpan-url?
- (let ((cpan-rx (make-regexp (string-append "("
- "mirror://cpan" "|"
- "https?://www.cpan.org" "|"
- "https?://cpan.metacpan.org"
- ")"))))
- (lambda (url)
- (regexp-exec cpan-rx url))))
-
- (let ((source-url (and=> (package-source package) origin-uri))
- (fetch-method (and=> (package-source package) origin-method)))
- (and (eq? fetch-method url-fetch)
- (match source-url
- ((? string?)
- (cpan-url? source-url))
- ((source-url ...)
- (any cpan-url? source-url))))))
+(define cpan-package?
+ (let ((cpan-rx (make-regexp (string-append "("
+ "mirror://cpan" "|"
+ "https?://www.cpan.org" "|"
+ "https?://cpan.metacpan.org"
+ ")"))))
+ (url-predicate (cut regexp-exec cpan-rx <>))))
(define (latest-release package)
"Return an <upstream-source> for the latest release of PACKAGE."