me
/
guix
Archived
1
0
Fork 0

import cran: Refactor "needs-zlib?".

* guix/import/cran.scm (tarball-files-match-pattern?): New procedure.
(needs-zlib?): Implement in terms of "tarball-files-match-pattern?".
master
Ricardo Wurmus 2017-04-05 18:42:07 +02:00
parent ff8c179ab6
commit a0f43208cb
No known key found for this signature in database
GPG Key ID: 197A5888235FACAC
1 changed files with 15 additions and 10 deletions

View File

@ -207,17 +207,16 @@ empty list when the FIELD cannot be found."
(check "*.f95") (check "*.f95")
(check "*.f"))) (check "*.f")))
(define (needs-zlib? tarball) (define (tarball-files-match-pattern? tarball regexp . file-patterns)
"Return #T if any of the Makevars files in the src directory of the TARBALL "Return #T if any of the files represented by FILE-PATTERNS in the TARBALL
contain a zlib linker flag." match the given REGEXP."
(call-with-temporary-directory (call-with-temporary-directory
(lambda (dir) (lambda (dir)
(let ((pattern (make-regexp "-lz"))) (let ((pattern (make-regexp regexp)))
(parameterize ((current-error-port (%make-void-port "rw+"))) (parameterize ((current-error-port (%make-void-port "rw+")))
(system* "tar" (apply system* "tar"
"xf" tarball "-C" dir "xf" tarball "-C" dir
"--wildcards" `("--wildcards" ,@file-patterns)))
"*/src/Makevars*" "*/src/configure*" "*/configure*"))
(any (lambda (file) (any (lambda (file)
(call-with-input-file file (call-with-input-file file
(lambda (port) (lambda (port)
@ -226,10 +225,16 @@ contain a zlib linker flag."
(cond (cond
((eof-object? line) #f) ((eof-object? line) #f)
((regexp-exec pattern line) #t) ((regexp-exec pattern line) #t)
(else (loop))))))) (else (loop))))))))
#t)
(find-files dir)))))) (find-files dir))))))
(define (needs-zlib? tarball)
"Return #T if any of the Makevars files in the src directory of the TARBALL
contain a zlib linker flag."
(tarball-files-match-pattern?
tarball "-lz"
"*/src/Makevars*" "*/src/configure*" "*/configure*"))
(define (description->package repository meta) (define (description->package repository meta)
"Return the `package' s-expression for an R package published on REPOSITORY "Return the `package' s-expression for an R package published on REPOSITORY
from the alist META, which was derived from the R package's DESCRIPTION file." from the alist META, which was derived from the R package's DESCRIPTION file."