From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:59176) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyxAX-00043D-MU for guix-patches@gnu.org; Tue, 04 Feb 2020 07:19:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyxAW-0003ST-6i for guix-patches@gnu.org; Tue, 04 Feb 2020 07:19:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:36753) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyxAW-0003Ra-2N for guix-patches@gnu.org; Tue, 04 Feb 2020 07:19:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iyxAV-0003mG-V0 for guix-patches@gnu.org; Tue, 04 Feb 2020 07:19:03 -0500 Subject: [bug#38408] [PATCH v9 4/8] guix: import: utils: allow generation of inputs to be version aware Resent-Message-ID: From: Martin Becze Date: Tue, 4 Feb 2020 07:18:21 -0500 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 38408@debbugs.gnu.org Cc: ludo@gnu.org, efraim@flashner.co.il, jsoo1@asu.edu, Martin Becze * guix/import/utils.scm (package-names->package-inputs): Added the ability to handle (name version) pairs * guix/import/crate.scm (make-crate-sexp): cleaned up input field generation --- guix/import/crate.scm | 17 +++++++++-------- guix/import/utils.scm | 21 ++++++++++++++------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 84b152620c..9128314370 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -151,16 +151,17 @@ record or #f if it was not found." "Return the `package' s-expression for a rust package with the given NAME, VERSION, CARGO-INPUTS, CARGO-DEVELOPMENT-INPUTS, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE." + (define (format-inputs inputs) + (map + (match-lambda + ((name version) (list (crate-name->package-name name) + (version-major+minor version)))) + inputs)) + (let* ((port (http-fetch (crate-uri name version))) (guix-name (crate-name->package-name name)) - (cargo-inputs - (map - (lambda (name-version) - (apply crate-name->package-name name-version)) cargo-inputs)) - (cargo-development-inputs - (map - (lambda (name-version) - (apply crate-name->package-name name-version)) cargo-development-inputs)) + (cargo-inputs (format-inputs cargo-inputs)) + (cargo-development-inputs (format-inputs cargo-development-inputs)) (pkg `(package (name ,guix-name) (version ,version) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 59430d3e66..518877d476 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -233,13 +233,20 @@ into a proper sentence and by using two spaces between sentences." cleaned 'pre ". " 'post))) (define* (package-names->package-inputs names #:optional (output #f)) - "Given a list of PACKAGE-NAMES, and an optional OUTPUT, tries to generate a -quoted list of inputs, as suitable to use in an 'inputs' field of a package -definition." - (map (lambda (input) - (cons* input (list 'unquote (string->symbol input)) - (or (and output (list output)) - '()))) + "Given a list of PACKAGE-NAMES or (PACKAGE-NAME VERSION) pairs, and an +optional OUTPUT, tries to generate a quoted list of inputs, as suitable to +use in an 'inputs' field of a package definition." + (define (make-input input version) + (cons* input (list 'unquote (string->symbol + (if version + (string-append input "-" version) + input))) + (or (and output (list output)) + '()))) + + (map (match-lambda + ((input version) (make-input input version)) + (input (make-input input #f))) names)) (define* (maybe-inputs package-names #:optional (output #f)) -- 2.25.0