From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:43826) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOUXD-000724-OX for guix-patches@gnu.org; Tue, 14 Apr 2020 19:00:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jOUXC-0002QM-LF for guix-patches@gnu.org; Tue, 14 Apr 2020 19:00:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51654) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jOUXC-0002QA-Hi for guix-patches@gnu.org; Tue, 14 Apr 2020 19:00:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jOUXC-00023k-Ha for guix-patches@gnu.org; Tue, 14 Apr 2020 19:00:02 -0400 Subject: [bug#40629] [PATCH v2 8/9] import/utils: alist->package: Ignore known inputs. References: <87y2qym5v8.fsf@elephly.net> In-Reply-To: <87y2qym5v8.fsf@elephly.net> Resent-Message-ID: From: Ricardo Wurmus Message-ID: <20200414225903.10862-1-rekado@elephly.net> Date: Wed, 15 Apr 2020 00:59:02 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 40629@debbugs.gnu.org Cc: Ricardo Wurmus * 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 =C2=A9 2012, 2013, 2018, 2019, 2020 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2016 Jelle Licht ;;; Copyright =C2=A9 2016 David Craven -;;; Copyright =C2=A9 2017, 2019 Ricardo Wurmus +;;; Copyright =C2=A9 2017, 2019, 2020 Ricardo Wurmus ;;; Copyright =C2=A9 2018 Oleg Pykhalov ;;; Copyright =C2=A9 2019 Robert Vollmert ;;; @@ -310,7 +310,18 @@ the expected fields of an object." (uri (assoc-ref orig "uri")) (sha256 sha)))))) =20 -(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=3D? + (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 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 --=20 2.25.1