[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
08/12: import/utils: alist->package: Ignore known inputs.
From: |
guix-commits |
Subject: |
08/12: import/utils: alist->package: Ignore known inputs. |
Date: |
Thu, 16 Apr 2020 17:43:21 -0400 (EDT) |
rekado pushed a commit to branch master
in repository guix.
commit 3532fc39fff41eabd061370ee36a1d42b9fac0e6
Author: Ricardo Wurmus <address@hidden>
AuthorDate: Wed Apr 15 00:41:03 2020 +0200
import/utils: alist->package: Ignore known inputs.
* guix/import/utils.scm (alist->package): Accept optional list of known
inputs, which are excluded from the specification lookup.
* guix/import/print.scm (package->code)[package-lists->code]: Handle inputs
which are just symbols.
---
guix/import/print.scm | 2 ++
guix/import/utils.scm | 27 ++++++++++++++++-----------
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/guix/import/print.scm b/guix/import/print.scm
index 08f3ec9..471687c 100644
--- a/guix/import/print.scm
+++ b/guix/import/print.scm
@@ -92,6 +92,8 @@ when evaluated."
(define (package-lists->code lsts)
(list 'quasiquote
(map (match-lambda
+ ((? symbol? s)
+ (list (symbol->string s) (list 'unquote s)))
((label pkg . out)
(let ((mod (package-module-name pkg)))
(cons* label
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 94c8cb0..5fb1322 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -2,7 +2,7 @@
;;; Copyright © 2012, 2013, 2018, 2019, 2020 Ludovic Courtès <address@hidden>
;;; Copyright © 2016 Jelle Licht <address@hidden>
;;; Copyright © 2016 David Craven <address@hidden>
-;;; Copyright © 2017, 2019 Ricardo Wurmus <address@hidden>
+;;; Copyright © 2017, 2019, 2020 Ricardo Wurmus <address@hidden>
;;; Copyright © 2018 Oleg Pykhalov <address@hidden>
;;; Copyright © 2019 Robert Vollmert <address@hidden>
;;;
@@ -310,7 +310,18 @@ the expected fields of an <origin> object."
(uri (assoc-ref orig "uri"))
(sha256 sha))))))
-(define (alist->package meta)
+(define* (alist->package meta #:optional (known-inputs '()))
+ "Return a package value generated from the alist META. If the list of
+strings KNOWN-INPUTS is provided, do not treat the mentioned inputs as
+specifications to look up and replace them with plain symbols instead."
+ (define (process-inputs which)
+ (let-values (((regular known)
+ (lset-diff+intersection
+ string=?
+ (vector->list (or (assoc-ref meta which) #()))
+ known-inputs)))
+ (append (specs->package-lists regular)
+ (map string->symbol known))))
(package
(name (assoc-ref meta "name"))
(version (assoc-ref meta "version"))
@@ -318,15 +329,9 @@ the expected fields of an <origin> object."
(build-system
(lookup-build-system-by-name
(string->symbol (assoc-ref meta "build-system"))))
- (native-inputs
- (specs->package-lists
- (vector->list (or (assoc-ref meta "native-inputs") '#()))))
- (inputs
- (specs->package-lists
- (vector->list (or (assoc-ref meta "inputs") '#()))))
- (propagated-inputs
- (specs->package-lists
- (vector->list (or (assoc-ref meta "propagated-inputs") '#()))))
+ (native-inputs (process-inputs "native-inputs"))
+ (inputs (process-inputs "inputs"))
+ (propagated-inputs (process-inputs "propagated-inputs"))
(home-page
(assoc-ref meta "home-page"))
(synopsis
- 03/12: import/json: Add json->scheme-file., (continued)
- 03/12: import/json: Add json->scheme-file., guix-commits, 2020/04/16
- 07/12: import/print: package->code: Wrap S-expression in definition., guix-commits, 2020/04/16
- 12/12: doc: Document building and installing from JSON files., guix-commits, 2020/04/16
- 05/12: scripts/package: Handle JSON files., guix-commits, 2020/04/16
- 10/12: import/utils: alist->package: Include arguments., guix-commits, 2020/04/16
- 02/12: import/print: package->code: Wrap build system value in module reference., guix-commits, 2020/04/16
- 09/12: import/json: json->code: Handle files with more than one definition., guix-commits, 2020/04/16
- 04/12: scripts/build: options->things-to-build: Handle .json files., guix-commits, 2020/04/16
- 06/12: import/json: Use json->code., guix-commits, 2020/04/16
- 11/12: import/print: Don't factorize URI if there's no version match., guix-commits, 2020/04/16
- 08/12: import/utils: alist->package: Ignore known inputs.,
guix-commits <=