You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

486 lines
19 KiB

Switch to Guile-Gcrypt. This removes (guix hash) and (guix pk-crypto), which now live as part of Guile-Gcrypt (version 0.1.0.) * guix/gcrypt.scm, guix/hash.scm, guix/pk-crypto.scm, tests/hash.scm, tests/pk-crypto.scm: Remove. * configure.ac: Test for Guile-Gcrypt. Remove LIBGCRYPT and LIBGCRYPT_LIBDIR assignments. * m4/guix.m4 (GUIX_ASSERT_LIBGCRYPT_USABLE): Remove. * README: Add Guile-Gcrypt to the dependencies; move libgcrypt as "required unless --disable-daemon". * doc/guix.texi (Requirements): Likewise. * gnu/packages/bash.scm, guix/derivations.scm, guix/docker.scm, guix/git.scm, guix/http-client.scm, guix/import/cpan.scm, guix/import/cran.scm, guix/import/crate.scm, guix/import/elpa.scm, guix/import/gnu.scm, guix/import/hackage.scm, guix/import/texlive.scm, guix/import/utils.scm, guix/nar.scm, guix/pki.scm, guix/scripts/archive.scm, guix/scripts/authenticate.scm, guix/scripts/download.scm, guix/scripts/hash.scm, guix/scripts/pack.scm, guix/scripts/publish.scm, guix/scripts/refresh.scm, guix/scripts/substitute.scm, guix/store.scm, guix/store/deduplication.scm, guix/tests.scm, tests/base32.scm, tests/builders.scm, tests/challenge.scm, tests/cpan.scm, tests/crate.scm, tests/derivations.scm, tests/gem.scm, tests/nar.scm, tests/opam.scm, tests/pki.scm, tests/publish.scm, tests/pypi.scm, tests/store-deduplication.scm, tests/store.scm, tests/substitute.scm: Adjust imports. * gnu/system/vm.scm: Likewise. (guile-sqlite3&co): Rename to... (gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT. (expression->derivation-in-linux-vm)[config]: Remove. (iso9660-image)[config]: Remove. (qemu-image)[config]: Remove. (system-docker-image)[config]: Remove. * guix/scripts/pack.scm: Adjust imports. (guile-sqlite3&co): Rename to... (gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT. (self-contained-tarball)[build]: Call 'make-config.scm' without #:libgcrypt argument. (squashfs-image)[libgcrypt]: Remove. [build]: Call 'make-config.scm' without #:libgcrypt. (docker-image)[config, json]: Remove. [build]: Add GUILE-GCRYPT to the extensions Remove (guix config) from the imported modules. * guix/self.scm (specification->package): Remove "libgcrypt", add "guile-gcrypt". (compiled-guix): Remove #:libgcrypt. [guile-gcrypt]: New variable. [dependencies]: Add it. [*core-modules*]: Remove #:libgcrypt from 'make-config.scm' call. Add #:extensions. [*config*]: Remove #:libgcrypt from 'make-config.scm' call. (%dependency-variables): Remove %libgcrypt. (make-config.scm): Remove #:libgcrypt. * build-aux/build-self.scm (guile-gcrypt): New variable. (make-config.scm): Remove #:libgcrypt. (build-program)[fake-gcrypt-hash]: New variable. Add (gcrypt hash) to the imported modules. Adjust load path assignments. * gnu/packages/package-management.scm (guix)[propagated-inputs]: Add GUILE-GCRYPT. [arguments]: In 'wrap-program' phase, add GUILE-GCRYPT to the search path.
3 years ago
Use HTTPS for bioconductor.org. * doc/guix.texi (Invoking guix import, Invoking guix refresh): Use HTTPS for bioconductor.org URLs. * gnu/packages/bioinformatics.scm (r-annotate, r-geneplotter, r-genefilter) (r-deseq2, r-dexseq, r-annotationforge, r-rbgl, r-gseabase, r-category) (r-gostats, r-shortread, r-biocgenerics, r-biocinstaller, r-biocviews) (r-biocstyle, r-bioccheck, r-s4vectors, r-iranges, r-genomeinfodbdata) (r-genomeinfodb, r-xvector, r-genomicranges, r-biobase, r-annotationdbi) (r-biomart, r-biocparallel, r-biostrings, r-rsamtools, r-delayedarray) (r-summarizedexperiment, r-genomicalignments, r-rtracklayer) (r-genomicfeatures, r-graph, r-topgo, r-bsgenome, r-impute, r-seqpattern) (r-seqlogo, r-motifrg, r-bamsignals, r-mutationalpatterns, r-tximport) (r-rhdf5, r-chipseq, r-sva, r-affy, r-vsn, r-mzid, r-msnid) (r-interactivedisplaybase, r-annotationhub)[home-page]: Likewise. * gnu/packages/bioinformatics.scm (r-txdb-hsapiens-ucsc-hg19-knowngene) (r-go-db, r-bsgenome-hsapiens-1000genomes-hs37d5, r-org-hs-eg-db) (r-org-ce-eg-db, r-org-dm-eg-db, r-org-mm-eg-db) (r-bsgenome-hsapiens-ucsc-hg19, r-bsgenome-mmusculus-ucsc-mm9) (r-bsgenome-mmusculus-ucsc-mm10, r-txdb-mmusculus-ucsc-mm10-knowngene) (r-bsgenome-celegans-ucsc-ce6, r-bsgenome-celegans-ucsc-ce10) (r-bsgenome-dmelanogaster-ucsc-dm3, r-copyhelper)[source, home-page]: Likewise. * gnu/packages/statistics.scm (r-rcurl)[source]: Likewise. * guix/build-system/r.scm (bioconductor-uri): Likewise. * guix/import/cran.scm (%cran-url, bioconductor-package?) (bioconductor-data-package?, bioconductor-experiment-package?): Likewise.
4 years ago
gnu: r: Do not build recommended packages. * gnu/packages/statistics.scm (r)[arguments]: Rename phase "build-recommended-packages-reproducibly" to "build-reproducibly"; add configure flag "--without-recommended-packages". * guix/import/cran.scm (default-r-packages): Remove recommended packages. * gnu/packages/python.scm (python-rpy2)[inputs]: Add r-survival. * gnu/packages/bioinformatics.scm (r-ape)[propagated-inputs]: Add r-lattice and r-nlme. (r-vegan)[propagated-inputs]: Add r-mass. (r-genefilter)[propagated-inputs]: Add r-survival. (r-grohmm)[propagated-inputs]: Add r-mass. (r-bioccheck)[propagated-inputs]: Add r-codetools. (r-summarizedexperiment)[propagated-inputs]: Add r-matrix. (r-topgo)[propagated-inputs]: Add r-lattice. (r-sva)[propagated-inputs]: Add r-mgcv. (r-raremetals2)[propagated-inputs]: Add r-mass. (r-vsn)[propagated-inputs]: Add r-lattice. (r-pcamethods)[propagated-inputs]: Add r-mass. * gnu/packages/bioinformatics.scm (r-ggplot2)[propagated-inputs]: Add r-mass. (r-locfit)[propagated-inputs]: Add r-lattice. (r-coda)[propagated-inputs]: Add r-lattice. (r-irlba)[propagated-inputs]: Add r-matrix. (r-glmnet)[propagated-inputs]: Add r-matrix. (r-e1071)[propagated-inputs]: Add r-class. (r-spams)[propagated-inputs]: Add r-lattice and r-matrix. (r-hmisc)[propagated-inputs]: Add r-cluster, r-foreign, r-lattice, r-nnet, and r-rpart. (r-zoo)[propagated-inputs]: Add r-lattice. (r-mixtools)[propagated-inputs]: Add r-boot and r-mass. (r-flexmix)[propagated-inputs]: Add r-lattice and r-nnet. (r-prabclus)[propagated-inputs]: Add r-mass. (r-fpc)[propagated-inputs]: Add r-class, r-cluster, and r-mass. (r-rcppeigen)[propagated-inputs]: Add r-matrix. (r-matrixmodels)[propagated-inputs]: Add r-matrix. (r-lme4)[propagated-inputs]: Add r-mass and r-nlme. (r-pbkrtest)[propagated-inputs]: Add r-mass and r-matrix. (r-car)[propagated-inputs]: Add r-mass, r-mgcv, and r-nnet. (r-tclust)[propagated-inputs]: Add r-cluster.
5 years ago
Use HTTPS for bioconductor.org. * doc/guix.texi (Invoking guix import, Invoking guix refresh): Use HTTPS for bioconductor.org URLs. * gnu/packages/bioinformatics.scm (r-annotate, r-geneplotter, r-genefilter) (r-deseq2, r-dexseq, r-annotationforge, r-rbgl, r-gseabase, r-category) (r-gostats, r-shortread, r-biocgenerics, r-biocinstaller, r-biocviews) (r-biocstyle, r-bioccheck, r-s4vectors, r-iranges, r-genomeinfodbdata) (r-genomeinfodb, r-xvector, r-genomicranges, r-biobase, r-annotationdbi) (r-biomart, r-biocparallel, r-biostrings, r-rsamtools, r-delayedarray) (r-summarizedexperiment, r-genomicalignments, r-rtracklayer) (r-genomicfeatures, r-graph, r-topgo, r-bsgenome, r-impute, r-seqpattern) (r-seqlogo, r-motifrg, r-bamsignals, r-mutationalpatterns, r-tximport) (r-rhdf5, r-chipseq, r-sva, r-affy, r-vsn, r-mzid, r-msnid) (r-interactivedisplaybase, r-annotationhub)[home-page]: Likewise. * gnu/packages/bioinformatics.scm (r-txdb-hsapiens-ucsc-hg19-knowngene) (r-go-db, r-bsgenome-hsapiens-1000genomes-hs37d5, r-org-hs-eg-db) (r-org-ce-eg-db, r-org-dm-eg-db, r-org-mm-eg-db) (r-bsgenome-hsapiens-ucsc-hg19, r-bsgenome-mmusculus-ucsc-mm9) (r-bsgenome-mmusculus-ucsc-mm10, r-txdb-mmusculus-ucsc-mm10-knowngene) (r-bsgenome-celegans-ucsc-ce6, r-bsgenome-celegans-ucsc-ce10) (r-bsgenome-dmelanogaster-ucsc-dm3, r-copyhelper)[source, home-page]: Likewise. * gnu/packages/statistics.scm (r-rcurl)[source]: Likewise. * guix/build-system/r.scm (bioconductor-uri): Likewise. * guix/import/cran.scm (%cran-url, bioconductor-package?) (bioconductor-data-package?, bioconductor-experiment-package?): Likewise.
4 years ago
Use HTTPS for bioconductor.org. * doc/guix.texi (Invoking guix import, Invoking guix refresh): Use HTTPS for bioconductor.org URLs. * gnu/packages/bioinformatics.scm (r-annotate, r-geneplotter, r-genefilter) (r-deseq2, r-dexseq, r-annotationforge, r-rbgl, r-gseabase, r-category) (r-gostats, r-shortread, r-biocgenerics, r-biocinstaller, r-biocviews) (r-biocstyle, r-bioccheck, r-s4vectors, r-iranges, r-genomeinfodbdata) (r-genomeinfodb, r-xvector, r-genomicranges, r-biobase, r-annotationdbi) (r-biomart, r-biocparallel, r-biostrings, r-rsamtools, r-delayedarray) (r-summarizedexperiment, r-genomicalignments, r-rtracklayer) (r-genomicfeatures, r-graph, r-topgo, r-bsgenome, r-impute, r-seqpattern) (r-seqlogo, r-motifrg, r-bamsignals, r-mutationalpatterns, r-tximport) (r-rhdf5, r-chipseq, r-sva, r-affy, r-vsn, r-mzid, r-msnid) (r-interactivedisplaybase, r-annotationhub)[home-page]: Likewise. * gnu/packages/bioinformatics.scm (r-txdb-hsapiens-ucsc-hg19-knowngene) (r-go-db, r-bsgenome-hsapiens-1000genomes-hs37d5, r-org-hs-eg-db) (r-org-ce-eg-db, r-org-dm-eg-db, r-org-mm-eg-db) (r-bsgenome-hsapiens-ucsc-hg19, r-bsgenome-mmusculus-ucsc-mm9) (r-bsgenome-mmusculus-ucsc-mm10, r-txdb-mmusculus-ucsc-mm10-knowngene) (r-bsgenome-celegans-ucsc-ce6, r-bsgenome-celegans-ucsc-ce10) (r-bsgenome-dmelanogaster-ucsc-dm3, r-copyhelper)[source, home-page]: Likewise. * gnu/packages/statistics.scm (r-rcurl)[source]: Likewise. * guix/build-system/r.scm (bioconductor-uri): Likewise. * guix/import/cran.scm (%cran-url, bioconductor-package?) (bioconductor-data-package?, bioconductor-experiment-package?): Likewise.
4 years ago
Use HTTPS for bioconductor.org. * doc/guix.texi (Invoking guix import, Invoking guix refresh): Use HTTPS for bioconductor.org URLs. * gnu/packages/bioinformatics.scm (r-annotate, r-geneplotter, r-genefilter) (r-deseq2, r-dexseq, r-annotationforge, r-rbgl, r-gseabase, r-category) (r-gostats, r-shortread, r-biocgenerics, r-biocinstaller, r-biocviews) (r-biocstyle, r-bioccheck, r-s4vectors, r-iranges, r-genomeinfodbdata) (r-genomeinfodb, r-xvector, r-genomicranges, r-biobase, r-annotationdbi) (r-biomart, r-biocparallel, r-biostrings, r-rsamtools, r-delayedarray) (r-summarizedexperiment, r-genomicalignments, r-rtracklayer) (r-genomicfeatures, r-graph, r-topgo, r-bsgenome, r-impute, r-seqpattern) (r-seqlogo, r-motifrg, r-bamsignals, r-mutationalpatterns, r-tximport) (r-rhdf5, r-chipseq, r-sva, r-affy, r-vsn, r-mzid, r-msnid) (r-interactivedisplaybase, r-annotationhub)[home-page]: Likewise. * gnu/packages/bioinformatics.scm (r-txdb-hsapiens-ucsc-hg19-knowngene) (r-go-db, r-bsgenome-hsapiens-1000genomes-hs37d5, r-org-hs-eg-db) (r-org-ce-eg-db, r-org-dm-eg-db, r-org-mm-eg-db) (r-bsgenome-hsapiens-ucsc-hg19, r-bsgenome-mmusculus-ucsc-mm9) (r-bsgenome-mmusculus-ucsc-mm10, r-txdb-mmusculus-ucsc-mm10-knowngene) (r-bsgenome-celegans-ucsc-ce6, r-bsgenome-celegans-ucsc-ce10) (r-bsgenome-dmelanogaster-ucsc-dm3, r-copyhelper)[source, home-page]: Likewise. * gnu/packages/statistics.scm (r-rcurl)[source]: Likewise. * guix/build-system/r.scm (bioconductor-uri): Likewise. * guix/import/cran.scm (%cran-url, bioconductor-package?) (bioconductor-data-package?, bioconductor-experiment-package?): Likewise.
4 years ago
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. (define-module (guix import cran)
  21. #:use-module (ice-9 match)
  22. #:use-module (ice-9 regex)
  23. #:use-module ((ice-9 rdelim) #:select (read-string read-line))
  24. #:use-module (srfi srfi-1)
  25. #:use-module (srfi srfi-26)
  26. #:use-module (srfi srfi-34)
  27. #:use-module (ice-9 receive)
  28. #:use-module (web uri)
  29. #:use-module (guix memoization)
  30. #:use-module (guix http-client)
  31. #:use-module (gcrypt hash)
  32. #:use-module (guix store)
  33. #:use-module (guix base32)
  34. #:use-module ((guix download) #:select (download-to-store))
  35. #:use-module (guix import utils)
  36. #:use-module ((guix build utils) #:select (find-files))
  37. #:use-module (guix utils)
  38. #:use-module ((guix build-system r) #:select (cran-uri bioconductor-uri))
  39. #:use-module (guix upstream)
  40. #:use-module (guix packages)
  41. #:use-module (gnu packages)
  42. #:export (cran->guix-package
  43. bioconductor->guix-package
  44. cran-recursive-import
  45. %cran-updater
  46. %bioconductor-updater
  47. cran-package?
  48. bioconductor-package?
  49. bioconductor-data-package?
  50. bioconductor-experiment-package?))
  51. ;;; Commentary:
  52. ;;;
  53. ;;; Generate a package declaration template for the latest version of an R
  54. ;;; package on CRAN, using the DESCRIPTION file downloaded from
  55. ;;; cran.r-project.org.
  56. ;;;
  57. ;;; Code:
  58. (define string->license
  59. (match-lambda
  60. ("AGPL-3" 'agpl3+)
  61. ("Artistic-2.0" 'artistic2.0)
  62. ("Apache License 2.0" 'asl2.0)
  63. ("BSD_2_clause" 'bsd-2)
  64. ("BSD_2_clause + file LICENSE" 'bsd-2)
  65. ("BSD_3_clause" 'bsd-3)
  66. ("BSD_3_clause + file LICENSE" 'bsd-3)
  67. ("GPL" '(list gpl2+ gpl3+))
  68. ("GPL (>= 2)" 'gpl2+)
  69. ("GPL (>= 3)" 'gpl3+)
  70. ("GPL-2" 'gpl2)
  71. ("GPL-3" 'gpl3)
  72. ("LGPL-2" 'lgpl2.0)
  73. ("LGPL-2.1" 'lgpl2.1)
  74. ("LGPL-3" 'lgpl3)
  75. ("LGPL (>= 2)" 'lgpl2.0+)
  76. ("LGPL (>= 3)" 'lgpl3+)
  77. ("MIT" 'expat)
  78. ("MIT + file LICENSE" 'expat)
  79. ((x) (string->license x))
  80. ((lst ...) `(list ,@(map string->license lst)))
  81. (_ #f)))
  82. (define (description->alist description)
  83. "Convert a DESCRIPTION string into an alist."
  84. (let ((lines (string-split description #\newline))
  85. (parse (lambda (line acc)
  86. (if (string-null? line) acc
  87. ;; Keys usually start with a capital letter and end with
  88. ;; ":". There are some exceptions, unfortunately (such
  89. ;; as "biocViews"). There are no blanks in a key.
  90. (if (string-match "^[A-Za-z][^ :]+:( |\n|$)" line)
  91. ;; New key/value pair
  92. (let* ((pos (string-index line #\:))
  93. (key (string-take line pos))
  94. (value (string-drop line (+ 1 pos))))
  95. (cons (cons key
  96. (string-trim-both value))
  97. acc))
  98. ;; This is a continuation of the previous pair
  99. (match-let ((((key . value) . rest) acc))
  100. (cons (cons key (string-join
  101. (list value
  102. (string-trim-both line))))
  103. rest)))))))
  104. (fold parse '() lines)))
  105. (define (format-inputs names)
  106. "Generate a sorted list of package inputs from a list of package NAMES."
  107. (map (lambda (name)
  108. (list name (list 'unquote (string->symbol name))))
  109. (sort names string-ci<?)))
  110. (define* (maybe-inputs package-inputs #:optional (type 'inputs))
  111. "Given a list of PACKAGE-INPUTS, tries to generate the TYPE field of a
  112. package definition."
  113. (match package-inputs
  114. (()
  115. '())
  116. ((package-inputs ...)
  117. `((,type (,'quasiquote ,(format-inputs package-inputs)))))))
  118. (define %cran-url "http://cran.r-project.org/web/packages/")
  119. (define %bioconductor-url "https://bioconductor.org/packages/")
  120. ;; The latest Bioconductor release is 3.7. Bioconductor packages should be
  121. ;; updated together.
  122. (define %bioconductor-version "3.7")
  123. (define %bioconductor-packages-list-url
  124. (string-append "https://bioconductor.org/packages/"
  125. %bioconductor-version "/bioc/src/contrib/PACKAGES"))
  126. (define (bioconductor-packages-list)
  127. "Return the latest version of package NAME for the current bioconductor
  128. release."
  129. (let ((url (string->uri %bioconductor-packages-list-url)))
  130. (guard (c ((http-get-error? c)
  131. (format (current-error-port)
  132. "error: failed to retrieve list of packages from ~s: ~a (~s)~%"
  133. (uri->string (http-get-error-uri c))
  134. (http-get-error-code c)
  135. (http-get-error-reason c))
  136. #f))
  137. ;; Split the big list on empty lines, then turn each chunk into an
  138. ;; alist of attributes.
  139. (map (lambda (chunk)
  140. (description->alist (string-join chunk "\n")))
  141. (chunk-lines (read-lines (http-fetch/cached url)))))))
  142. (define (latest-bioconductor-package-version name)
  143. "Return the version string corresponding to the latest release of the
  144. bioconductor package NAME, or #F if the package is unknown."
  145. (and=> (find (lambda (meta)
  146. (string=? (assoc-ref meta "Package") name))
  147. (bioconductor-packages-list))
  148. (cut assoc-ref <> "Version")))
  149. (define (fetch-description repository name)
  150. "Return an alist of the contents of the DESCRIPTION file for the R package
  151. NAME in the given REPOSITORY, or #f in case of failure. NAME is
  152. case-sensitive."
  153. (case repository
  154. ((cran)
  155. (let ((url (string-append %cran-url name "/DESCRIPTION")))
  156. (guard (c ((http-get-error? c)
  157. (format (current-error-port)
  158. "error: failed to retrieve package information \
  159. from ~s: ~a (~s)~%"
  160. (uri->string (http-get-error-uri c))
  161. (http-get-error-code c)
  162. (http-get-error-reason c))
  163. #f))
  164. (description->alist (read-string (http-fetch url))))))
  165. ((bioconductor)
  166. ;; Currently, the bioconductor project does not offer a way to access a
  167. ;; package's DESCRIPTION file over HTTP, so we determine the version,
  168. ;; download the source tarball, and then extract the DESCRIPTION file.
  169. (let* ((version (latest-bioconductor-package-version name))
  170. (url (car (bioconductor-uri name version)))
  171. (tarball (with-store store (download-to-store store url))))
  172. (call-with-temporary-directory
  173. (lambda (dir)
  174. (parameterize ((current-error-port (%make-void-port "rw+"))
  175. (current-output-port (%make-void-port "rw+")))
  176. (and (zero? (system* "tar" "--wildcards" "-x"
  177. "--strip-components=1"
  178. "-C" dir
  179. "-f" tarball "*/DESCRIPTION"))
  180. (description->alist (with-input-from-file
  181. (string-append dir "/DESCRIPTION") read-string))))))))))
  182. (define (listify meta field)
  183. "Look up FIELD in the alist META. If FIELD contains a comma-separated
  184. string, turn it into a list and strip off parenthetic expressions. Return the
  185. empty list when the FIELD cannot be found."
  186. (let ((value (assoc-ref meta field)))
  187. (if (not value)
  188. '()
  189. ;; Strip off parentheses
  190. (let ((items (string-split (regexp-substitute/global
  191. #f "( *\\([^\\)]+\\)) *"
  192. value 'pre 'post)
  193. #\,)))
  194. (remove (lambda (item)
  195. (or (string-null? item)
  196. ;; When there is whitespace inside of items it is
  197. ;; probably because this was not an actual list to
  198. ;; begin with.
  199. (string-any char-set:whitespace item)))
  200. (map string-trim-both items))))))
  201. (define default-r-packages
  202. (list "base"
  203. "compiler"
  204. "grDevices"
  205. "graphics"
  206. "grid"
  207. "methods"
  208. "parallel"
  209. "splines"
  210. "stats"
  211. "stats4"
  212. "tcltk"
  213. "tools"
  214. "translations"
  215. "utils"))
  216. (define cran-guix-name (cut guix-name "r-" <>))
  217. (define (needs-fortran? tarball)
  218. "Check if the TARBALL contains Fortran source files."
  219. (define (check pattern)
  220. (parameterize ((current-error-port (%make-void-port "rw+"))
  221. (current-output-port (%make-void-port "rw+")))
  222. (zero? (system* "tar" "--wildcards" "--list" pattern "-f" tarball))))
  223. (or (check "*.f90")
  224. (check "*.f95")
  225. (check "*.f")))
  226. (define (tarball-files-match-pattern? tarball regexp . file-patterns)
  227. "Return #T if any of the files represented by FILE-PATTERNS in the TARBALL
  228. match the given REGEXP."
  229. (call-with-temporary-directory
  230. (lambda (dir)
  231. (let ((pattern (make-regexp regexp)))
  232. (parameterize ((current-error-port (%make-void-port "rw+")))
  233. (apply system* "tar"
  234. "xf" tarball "-C" dir
  235. `("--wildcards" ,@file-patterns)))
  236. (any (lambda (file)
  237. (call-with-input-file file
  238. (lambda (port)
  239. (let loop ()
  240. (let ((line (read-line port)))
  241. (cond
  242. ((eof-object? line) #f)
  243. ((regexp-exec pattern line) #t)
  244. (else (loop))))))))
  245. (find-files dir))))))
  246. (define (needs-zlib? tarball)
  247. "Return #T if any of the Makevars files in the src directory of the TARBALL
  248. contain a zlib linker flag."
  249. (tarball-files-match-pattern?
  250. tarball "-lz"
  251. "*/src/Makevars*" "*/src/configure*" "*/configure*"))
  252. (define (needs-pkg-config? tarball)
  253. "Return #T if any of the Makevars files in the src directory of the TARBALL
  254. reference the pkg-config tool."
  255. (tarball-files-match-pattern?
  256. tarball "pkg-config"
  257. "*/src/Makevars*" "*/src/configure*" "*/configure*"))
  258. (define (description->package repository meta)
  259. "Return the `package' s-expression for an R package published on REPOSITORY
  260. from the alist META, which was derived from the R package's DESCRIPTION file."
  261. (let* ((base-url (case repository
  262. ((cran) %cran-url)
  263. ((bioconductor) %bioconductor-url)))
  264. (uri-helper (case repository
  265. ((cran) cran-uri)
  266. ((bioconductor) bioconductor-uri)))
  267. (name (assoc-ref meta "Package"))
  268. (synopsis (assoc-ref meta "Title"))
  269. (version (assoc-ref meta "Version"))
  270. (license (string->license (assoc-ref meta "License")))
  271. ;; Some packages have multiple home pages. Some have none.
  272. (home-page (match (listify meta "URL")
  273. ((url rest ...) url)
  274. (_ (string-append base-url name))))
  275. (source-url (match (uri-helper name version)
  276. ((url rest ...) url)
  277. ((? string? url) url)
  278. (_ #f)))
  279. (tarball (with-store store (download-to-store store source-url)))
  280. (sysdepends (append
  281. (if (needs-zlib? tarball) '("zlib") '())
  282. (map string-downcase (listify meta "SystemRequirements"))))
  283. (propagate (filter (lambda (name)
  284. (not (member name default-r-packages)))
  285. (lset-union equal?
  286. (listify meta "Imports")
  287. (listify meta "LinkingTo")
  288. (delete "R"
  289. (listify meta "Depends"))))))
  290. (values
  291. `(package
  292. (name ,(cran-guix-name name))
  293. (version ,version)
  294. (source (origin
  295. (method url-fetch)
  296. (uri (,(procedure-name uri-helper) ,name version))
  297. (sha256
  298. (base32
  299. ,(bytevector->nix-base32-string (file-sha256 tarball))))))
  300. ,@(if (not (equal? (string-append "r-" name)
  301. (cran-guix-name name)))
  302. `((properties ,`(,'quasiquote ((,'upstream-name . ,name)))))
  303. '())
  304. (build-system r-build-system)
  305. ,@(maybe-inputs sysdepends)
  306. ,@(maybe-inputs (map cran-guix-name propagate) 'propagated-inputs)
  307. ,@(maybe-inputs
  308. `(,@(if (needs-fortran? tarball)
  309. '("gfortran") '())
  310. ,@(if (needs-pkg-config? tarball)
  311. '("pkg-config") '()))
  312. 'native-inputs)
  313. (home-page ,(if (string-null? home-page)
  314. (string-append base-url name)
  315. home-page))
  316. (synopsis ,synopsis)
  317. (description ,(beautify-description (or (assoc-ref meta "Description")
  318. "")))
  319. (license ,license))
  320. propagate)))
  321. (define cran->guix-package
  322. (memoize
  323. (lambda* (package-name #:optional (repo 'cran))
  324. "Fetch the metadata for PACKAGE-NAME from REPO and return the `package'
  325. s-expression corresponding to that package, or #f on failure."
  326. (and=> (fetch-description repo package-name)
  327. (cut description->package repo <>)))))
  328. (define* (cran-recursive-import package-name #:optional (repo 'gnu))
  329. (recursive-import package-name repo
  330. #:repo->guix-package cran->guix-package
  331. #:guix-name cran-guix-name))
  332. ;;;
  333. ;;; Updater.
  334. ;;;
  335. (define (package->upstream-name package)
  336. "Return the upstream name of the PACKAGE."
  337. (let* ((properties (package-properties package))
  338. (upstream-name (and=> properties
  339. (cut assoc-ref <> 'upstream-name))))
  340. (if upstream-name
  341. upstream-name
  342. (match (package-source package)
  343. ((? origin? origin)
  344. (match (origin-uri origin)
  345. ((or (? string? url) (url _ ...))
  346. (let ((end (string-rindex url #\_))
  347. (start (string-rindex url #\/)))
  348. ;; The URL ends on
  349. ;; (string-append "/" name "_" version ".tar.gz")
  350. (and start end (substring url (+ start 1) end))))
  351. (_ #f)))
  352. (_ #f)))))
  353. (define (latest-cran-release package)
  354. "Return an <upstream-source> for the latest release of PACKAGE."
  355. (define upstream-name
  356. (package->upstream-name package))
  357. (define meta
  358. (fetch-description 'cran upstream-name))
  359. (and meta
  360. (let ((version (assoc-ref meta "Version")))
  361. ;; CRAN does not provide signatures.
  362. (upstream-source
  363. (package (package-name package))
  364. (version version)
  365. (urls (cran-uri upstream-name version))))))
  366. (define (latest-bioconductor-release package)
  367. "Return an <upstream-source> for the latest release of PACKAGE."
  368. (define upstream-name
  369. (package->upstream-name package))
  370. (define version
  371. (latest-bioconductor-package-version upstream-name))
  372. (and version
  373. ;; Bioconductor does not provide signatures.
  374. (upstream-source
  375. (package (package-name package))
  376. (version version)
  377. (urls (bioconductor-uri upstream-name version)))))
  378. (define (cran-package? package)
  379. "Return true if PACKAGE is an R package from CRAN."
  380. (and (string-prefix? "r-" (package-name package))
  381. ;; Check if the upstream name can be extracted from package uri.
  382. (package->upstream-name package)
  383. ;; Check if package uri(s) are prefixed by "mirror://cran".
  384. (match (and=> (package-source package) origin-uri)
  385. ((? string? uri)
  386. (string-prefix? "mirror://cran" uri))
  387. ((? list? uris)
  388. (any (cut string-prefix? "mirror://cran" <>) uris))
  389. (_ #f))))
  390. (define (bioconductor-package? package)
  391. "Return true if PACKAGE is an R package from Bioconductor."
  392. (let ((predicate (lambda (uri)
  393. (and (string-prefix? "https://bioconductor.org" uri)
  394. ;; Data packages are neither listed in SVN nor on
  395. ;; the Github mirror, so we have to exclude them
  396. ;; from the set of bioconductor packages that can be
  397. ;; updated automatically.
  398. (not (string-contains uri "/data/annotation/"))
  399. ;; Experiment packages are in a separate repository.
  400. (not (string-contains uri "/data/experiment/"))))))
  401. (and (string-prefix? "r-" (package-name package))
  402. (match (and=> (package-source package) origin-uri)
  403. ((? string? uri)
  404. (predicate uri))
  405. ((? list? uris)
  406. (any predicate uris))
  407. (_ #f)))))
  408. (define (bioconductor-data-package? package)
  409. "Return true if PACKAGE is an R data package from Bioconductor."
  410. (let ((predicate (lambda (uri)
  411. (and (string-prefix? "https://bioconductor.org" uri)
  412. (string-contains uri "/data/annotation/")))))
  413. (and (string-prefix? "r-" (package-name package))
  414. (match (and=> (package-source package) origin-uri)
  415. ((? string? uri)
  416. (predicate uri))
  417. ((? list? uris)
  418. (any predicate uris))
  419. (_ #f)))))
  420. (define (bioconductor-experiment-package? package)
  421. "Return true if PACKAGE is an R experiment package from Bioconductor."
  422. (let ((predicate (lambda (uri)
  423. (and (string-prefix? "https://bioconductor.org" uri)
  424. (string-contains uri "/data/experiment/")))))
  425. (and (string-prefix? "r-" (package-name package))
  426. (match (and=> (package-source package) origin-uri)
  427. ((? string? uri)
  428. (predicate uri))
  429. ((? list? uris)
  430. (any predicate uris))
  431. (_ #f)))))
  432. (define %cran-updater
  433. (upstream-updater
  434. (name 'cran)
  435. (description "Updater for CRAN packages")
  436. (pred cran-package?)
  437. (latest latest-cran-release)))
  438. (define %bioconductor-updater
  439. (upstream-updater
  440. (name 'bioconductor)
  441. (description "Updater for Bioconductor packages")
  442. (pred bioconductor-package?)
  443. (latest latest-bioconductor-release)))
  444. ;;; cran.scm ends here