From: Ricardo Wurmus <rekado@elephly.net>
To: 40629@debbugs.gnu.org
Cc: Ricardo Wurmus <rekado@elephly.net>
Subject: [bug#40629] [PATCH v2 8/9] import/utils: alist->package: Ignore known inputs.
Date: Wed, 15 Apr 2020 00:59:02 +0200 [thread overview]
Message-ID: <20200414225903.10862-1-rekado@elephly.net> (raw)
In-Reply-To: <87y2qym5v8.fsf@elephly.net>
* 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 08f3ec9c34..471687c0ff 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 94c8cb040b..5fb1322535 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -2,7 +2,7 @@
;;; Copyright © 2012, 2013, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2016 David Craven <david@craven.ch>
-;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2017, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
;;;
@@ -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
--
2.25.1
next prev parent reply other threads:[~2020-04-14 23:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-14 15:44 [bug#40629] Build and install packages from JSON definitions Ricardo Wurmus
2020-04-14 17:19 ` [bug#40629] [PATCH 1/5] import/print: Return license with prefix Ricardo Wurmus
2020-04-14 17:19 ` [bug#40629] [PATCH 2/5] import/print: package->code: Wrap build system value in module reference Ricardo Wurmus
2020-04-14 17:19 ` [bug#40629] [PATCH 3/5] import/json: Add json->scheme-file Ricardo Wurmus
2020-04-14 17:19 ` [bug#40629] [PATCH 4/5] scripts/build: options->things-to-build: Handle .json files Ricardo Wurmus
2020-04-16 21:45 ` Ludovic Courtès
2020-04-16 21:53 ` Ludovic Courtès
2020-04-14 17:19 ` [bug#40629] [PATCH 5/5] scripts/package: Handle JSON files Ricardo Wurmus
2020-04-14 22:48 ` [bug#40629] [PATCH 6/9] import/json: Use json->code Ricardo Wurmus
2020-04-14 22:48 ` [bug#40629] [PATCH 7/9] import/print: package->code: Wrap S-expression in definition Ricardo Wurmus
2020-04-14 22:48 ` [bug#40629] [PATCH 8/9] import/utils: alist->package: Ignore known inputs Ricardo Wurmus
2020-04-14 22:48 ` [bug#40629] [PATCH 9/9] import/json: json->code: Handle files with more than one definition Ricardo Wurmus
2020-04-14 22:59 ` Ricardo Wurmus [this message]
2020-04-14 22:59 ` [bug#40629] [PATCH v2 " Ricardo Wurmus
2020-04-14 23:01 ` Ricardo Wurmus
2020-04-17 5:32 ` Jan Nieuwenhuizen
2020-04-18 20:23 ` Ricardo Wurmus
2020-04-15 18:26 ` [bug#40629] Build and install packages from JSON definitions Christopher Baines
2020-04-15 22:27 ` Ricardo Wurmus
2020-04-16 21:44 ` bug#40629: " Ricardo Wurmus
2020-04-17 17:45 ` [bug#40629] " Christopher Baines
2020-04-16 21:50 ` Ludovic Courtès
2020-04-17 8:25 ` Ricardo Wurmus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200414225903.10862-1-rekado@elephly.net \
--to=rekado@elephly.net \
--cc=40629@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).