import: cpan: check version bounds on core modules.

Modules may be removed from Perl's core, so we must check for a removal
version.

* guix/import/cpan.scm (cpan-module->sexp)[core-module?]: Also check
version upper bound.
This commit is contained in:
Eric Bavier 2016-04-15 23:52:19 -05:00
parent 5cd25aad3c
commit b77d17d023
1 changed files with 25 additions and 10 deletions

View File

@ -26,6 +26,7 @@
#:use-module (json) #:use-module (json)
#:use-module (guix hash) #:use-module (guix hash)
#:use-module (guix store) #:use-module (guix store)
#:use-module (guix utils)
#:use-module (guix base32) #:use-module (guix base32)
#:use-module ((guix download) #:select (download-to-store)) #:use-module ((guix download) #:select (download-to-store))
#:use-module (guix import utils) #:use-module (guix import utils)
@ -121,16 +122,30 @@ META."
(define version (define version
(assoc-ref meta "version")) (assoc-ref meta "version"))
(define (core-module? name) (define core-module?
(and (force %corelist) (let ((perl-version (package-version perl))
(parameterize ((current-error-port (%make-void-port "w"))) (rx (make-regexp
(let* ((corelist (open-pipe* OPEN_READ (force %corelist) name))) (string-append "released with perl v?([0-9\\.]*)"
(let loop ((line (read-line corelist))) "(.*and removed from v?([0-9\\.]*))?"))))
(if (eof-object? line) (lambda (name)
(begin (close-pipe corelist) #f) (define (version-between? lower version upper)
(if (string-contains line "first released with perl") (and (version>=? version lower)
(begin (close-pipe corelist) #t) (or (not upper)
(loop (read-line corelist))))))))) (version>? upper version))))
(and (force %corelist)
(parameterize ((current-error-port (%make-void-port "w")))
(let* ((corelist (open-pipe* OPEN_READ (force %corelist) name)))
(let loop ()
(let ((line (read-line corelist)))
(if (eof-object? line)
(begin (close-pipe corelist) #f)
(or (and=> (regexp-exec rx line)
(lambda (m)
(let ((first (match:substring m 1))
(last (match:substring m 3)))
(version-between?
first perl-version last))))
(loop)))))))))))
(define (convert-inputs phases) (define (convert-inputs phases)
;; Convert phase dependencies into a list of name/variable pairs. ;; Convert phase dependencies into a list of name/variable pairs.