From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: [PATCH 6/7] import cran: Add "recursive" option. Date: Mon, 23 May 2016 17:40:07 +0200 Message-ID: <1464018008-1767-7-git-send-email-ricardo.wurmus@mdc-berlin.de> References: <1464018008-1767-1-git-send-email-ricardo.wurmus@mdc-berlin.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4ryV-0004VQ-4Q for guix-devel@gnu.org; Mon, 23 May 2016 11:41:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4ryP-0003Ce-Ca for guix-devel@gnu.org; Mon, 23 May 2016 11:40:59 -0400 Received: from sinope02.bbbm.mdc-berlin.de ([141.80.25.24]:53749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4ryP-0003CP-5u for guix-devel@gnu.org; Mon, 23 May 2016 11:40:53 -0400 Received: from localhost (localhost [127.0.0.1]) by sinope02.bbbm.mdc-berlin.de (Postfix) with ESMTP id 9F74086071 for ; Mon, 23 May 2016 17:40:52 +0200 (CEST) Received: from sinope02.bbbm.mdc-berlin.de ([127.0.0.1]) by localhost (sinope02.bbbm.mdc-berlin.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aDjEbO4UHa8f for ; Mon, 23 May 2016 17:40:47 +0200 (CEST) Received: from HTCAONE.mdc-berlin.net (puck.citx.mdc-berlin.de [141.80.36.101]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by sinope02.bbbm.mdc-berlin.de (Postfix) with ESMTPS for ; Mon, 23 May 2016 17:40:47 +0200 (CEST) In-Reply-To: <1464018008-1767-1-git-send-email-ricardo.wurmus@mdc-berlin.de> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * guix/scripts/import/cran.scm: (%options): Add "recursive" option. (guix-import-cran): Handle "recursive" option. --- guix/scripts/import/cran.scm | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm index ace1123..4cae9da 100644 --- a/guix/scripts/import/cran.scm +++ b/guix/scripts/import/cran.scm @@ -63,6 +63,9 @@ Import and convert the CRAN package for PACKAGE-NAME.\n")) (lambda (opt name arg result) (alist-cons 'repo (string->symbol arg) (alist-delete 'repo result)))) + (option '(#\r "recursive") #f #f + (lambda (opt name arg result) + (alist-cons 'recursive #t result))) %standard-import-options)) @@ -88,12 +91,23 @@ Import and convert the CRAN package for PACKAGE-NAME.\n")) (reverse opts)))) (match args ((package-name) - (let ((sexp (cran->guix-package package-name - (or (assoc-ref opts 'repo) 'cran)))) - (unless sexp - (leave (_ "failed to download description for package '~a'~%") - package-name)) - sexp)) + (if (assoc-ref opts 'recursive) + ;; Recursive import + (map (match-lambda + ((and (label . (('package ('name name) . rest))) + (label . (pkg))) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) + (recursive-import package-name + (or (assoc-ref opts 'repo) 'cran))) + ;; Single import + (let ((sexp (cran->guix-package package-name + (or (assoc-ref opts 'repo) 'cran)))) + (unless sexp + (leave (_ "failed to download description for package '~a'~%") + package-name)) + sexp))) (() (leave (_ "too few arguments~%"))) ((many ...) -- 2.7.3