From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvo1S-000292-6v for guix-patches@gnu.org; Wed, 05 Apr 2017 12:43:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvo1P-0007gK-3P for guix-patches@gnu.org; Wed, 05 Apr 2017 12:43:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:35686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cvo1P-0007gE-0j for guix-patches@gnu.org; Wed, 05 Apr 2017 12:43:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cvo1O-0003T4-Pl for guix-patches@gnu.org; Wed, 05 Apr 2017 12:43:02 -0400 Subject: bug#26373: [PATCH 3/6] import cran: Refactor "needs-zlib?". Resent-Message-ID: From: Ricardo Wurmus Date: Wed, 5 Apr 2017 18:42:07 +0200 Message-Id: <20170405164210.29428-3-rekado@elephly.net> In-Reply-To: <20170405164210.29428-1-rekado@elephly.net> References: <20170405164210.29428-1-rekado@elephly.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 26373@debbugs.gnu.org Cc: Ricardo Wurmus * guix/import/cran.scm (tarball-files-match-pattern?): New procedure. (needs-zlib?): Implement in terms of "tarball-files-match-pattern?". --- guix/import/cran.scm | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/guix/import/cran.scm b/guix/import/cran.scm index 48ab7355d..be3b678cd 100644 --- a/guix/import/cran.scm +++ b/guix/import/cran.scm @@ -201,17 +201,16 @@ empty list when the FIELD cannot be found." (check "*.f95") (check "*.f"))) -(define (needs-zlib? tarball) - "Return #T if any of the Makevars files in the src directory of the TARBALL -contain a zlib linker flag." +(define (tarball-files-match-pattern? tarball regexp . file-patterns) + "Return #T if any of the files represented by FILE-PATTERNS in the TARBALL +match the given REGEXP." (call-with-temporary-directory (lambda (dir) - (let ((pattern (make-regexp "-lz"))) + (let ((pattern (make-regexp regexp))) (parameterize ((current-error-port (%make-void-port "rw+"))) - (system* "tar" - "xf" tarball "-C" dir - "--wildcards" - "*/src/Makevars*" "*/src/configure*" "*/configure*")) + (apply system* "tar" + "xf" tarball "-C" dir + `("--wildcards" ,@file-patterns))) (any (lambda (file) (call-with-input-file file (lambda (port) @@ -220,10 +219,16 @@ contain a zlib linker flag." (cond ((eof-object? line) #f) ((regexp-exec pattern line) #t) - (else (loop))))))) - #t) + (else (loop)))))))) (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) "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." -- 2.12.2