mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 13:28:12 -05:00
import: cran: Robustify cran-package?.
* guix/import/cran.scm (package->upstream-name): Return #f if url start and end index could not be determined. (cran-package?): Check if the upstream-name can be extracted from given package. * tests/cran.scm: Add "r-minimal is not a cran package" to make sure that r-minimal is not detected as a cran package. This fixes a failure of guix refresh on r-minimal because no upsteam-name can be determined from ".../R-version.tar.gz" uri.
This commit is contained in:
parent
a5e8f5972c
commit
db427602d8
2 changed files with 11 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
|
;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
|
||||||
;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
|
||||||
|
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -374,7 +375,7 @@ (define (package->upstream-name package)
|
||||||
(start (string-rindex url #\/)))
|
(start (string-rindex url #\/)))
|
||||||
;; The URL ends on
|
;; The URL ends on
|
||||||
;; (string-append "/" name "_" version ".tar.gz")
|
;; (string-append "/" name "_" version ".tar.gz")
|
||||||
(substring url (+ start 1) end)))
|
(and start end (substring url (+ start 1) end))))
|
||||||
(_ #f)))
|
(_ #f)))
|
||||||
(_ #f)))))
|
(_ #f)))))
|
||||||
|
|
||||||
|
@ -415,6 +416,9 @@ (define meta
|
||||||
(define (cran-package? package)
|
(define (cran-package? package)
|
||||||
"Return true if PACKAGE is an R package from CRAN."
|
"Return true if PACKAGE is an R package from CRAN."
|
||||||
(and (string-prefix? "r-" (package-name package))
|
(and (string-prefix? "r-" (package-name package))
|
||||||
|
;; Check if the upstream name can be extracted from package uri.
|
||||||
|
(package->upstream-name package)
|
||||||
|
;; Check if package uri(s) are prefixed by "mirror://cran".
|
||||||
(match (and=> (package-source package) origin-uri)
|
(match (and=> (package-source package) origin-uri)
|
||||||
((? string? uri)
|
((? string? uri)
|
||||||
(string-prefix? "mirror://cran" uri))
|
(string-prefix? "mirror://cran" uri))
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
|
;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
|
||||||
|
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
(define-module (test-cran)
|
(define-module (test-cran)
|
||||||
|
#:use-module (gnu packages statistics)
|
||||||
#:use-module (guix import cran)
|
#:use-module (guix import cran)
|
||||||
#:use-module (guix tests)
|
#:use-module (guix tests)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
|
@ -86,6 +88,10 @@ (define simple-alist
|
||||||
'()
|
'()
|
||||||
((@@ (guix import cran) listify) simple-alist "BadList"))
|
((@@ (guix import cran) listify) simple-alist "BadList"))
|
||||||
|
|
||||||
|
(test-equal "r-mininal is not a cran package"
|
||||||
|
#f
|
||||||
|
((@@ (guix import cran) cran-package?) r-minimal))
|
||||||
|
|
||||||
(test-assert "description->package"
|
(test-assert "description->package"
|
||||||
;; Replace network resources with sample data.
|
;; Replace network resources with sample data.
|
||||||
(mock ((guix build download) url-fetch
|
(mock ((guix build download) url-fetch
|
||||||
|
|
Loading…
Reference in a new issue