From patchwork Fri Sep 23 07:42:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: itd X-Patchwork-Id: 42875 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C7BFC27BBEA; Fri, 23 Sep 2022 08:49:02 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 7D69B27BBE9 for ; Fri, 23 Sep 2022 08:49:02 +0100 (BST) Received: from localhost ([::1]:44984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obdQj-0000cv-K4 for patchwork@mira.cbaines.net; Fri, 23 Sep 2022 03:49:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obdLv-00075T-TX for guix-patches@gnu.org; Fri, 23 Sep 2022 03:44:09 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40205) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obdLu-0006Tf-Ff for guix-patches@gnu.org; Fri, 23 Sep 2022 03:44:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1obdLu-000391-0W for guix-patches@gnu.org; Fri, 23 Sep 2022 03:44:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58020] [PATCH] import/utils: alist->package: Include properties. Resent-From: itd Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 23 Sep 2022 07:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58020 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58020@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.166391899712024 (code B ref -1); Fri, 23 Sep 2022 07:44:01 +0000 Received: (at submit) by debbugs.gnu.org; 23 Sep 2022 07:43:17 +0000 Received: from localhost ([127.0.0.1]:39283 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obdLA-00037s-RT for submit@debbugs.gnu.org; Fri, 23 Sep 2022 03:43:17 -0400 Received: from lists.gnu.org ([209.51.188.17]:46002) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obdL9-00037k-Aa for submit@debbugs.gnu.org; Fri, 23 Sep 2022 03:43:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obdL8-0006dK-TD for guix-patches@gnu.org; Fri, 23 Sep 2022 03:43:15 -0400 Received: from mailout3.rbg.tum.de ([131.159.0.8]:33707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obdL6-0006IN-Gd for guix-patches@gnu.org; Fri, 23 Sep 2022 03:43:14 -0400 Received: from mailrelay1.rbg.tum.de (mailrelay1.in.tum.de [131.159.254.14]) by mailout3.rbg.tum.de (Postfix) with ESMTPS id 6C73E1003CA for ; Fri, 23 Sep 2022 09:42:56 +0200 (CEST) Received: by mailrelay1.rbg.tum.de (Postfix, from userid 112) id 691FA1A8; Fri, 23 Sep 2022 09:42:56 +0200 (CEST) Received: from mailrelay1.rbg.tum.de (localhost [127.0.0.1]) by mailrelay1.rbg.tum.de (Postfix) with ESMTP id D042B1A1 for ; Fri, 23 Sep 2022 09:42:54 +0200 (CEST) Received: from mail.net.in.tum.de (mail.net.in.tum.de [IPv6:2001:4ca0:2001:14:216:3eff:fe52:ed14]) by mailrelay1.rbg.tum.de (Postfix) with ESMTP id CE84BCD for ; Fri, 23 Sep 2022 09:42:54 +0200 (CEST) Received: from amnesix.net.in.tum.de (amnesix.net.in.tum.de [IPv6:2001:4ca0:2001:11:e2d5:5eff:fea9:55ca]) by mail.net.in.tum.de (Postfix) with ESMTP id 8A0AC28C100B; Fri, 23 Sep 2022 09:42:54 +0200 (CEST) From: itd Date: Fri, 23 Sep 2022 09:42:53 +0200 Message-ID: <87mtaqilj6.fsf@localhost> MIME-Version: 1.0 Received-SPF: pass client-ip=131.159.0.8; envelope-from=itd@net.in.tum.de; helo=mailout3.rbg.tum.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/import/utils.scm (alist->package): Process properties field in input data and include it in the generated package. * tests/import-utils.scm ("alist->package with properties"): New test. --- Hi, this patch enables the JSON importer to include package properties in its output and a test to check that the modified function's result is consumable by functions that use these properties. Please consider applying it. Thanks! Regards itd guix/import/utils.scm | 9 +++++++++ tests/import-utils.scm | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) base-commit: 04cad8e29ed85be838921c7fa05f7c5bce94b6d1 diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 7e7d116d1d..8ae04e3cfb 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -428,10 +428,19 @@ (define* (alist->package meta #:optional (known-inputs '())) ((key . value) (list (symbol->keyword (string->symbol key)) value))) arguments)) + (define (process-properties properties) + (append-map (match-lambda + ((key . value) + (acons (string->symbol key) value '()))) + properties)) (package (name (assoc-ref meta "name")) (version (assoc-ref meta "version")) (source (source-spec->object (assoc-ref meta "source"))) + (properties + (or (and=> (assoc-ref meta "properties") + process-properties) + '())) (build-system (lookup-build-system-by-name (string->symbol (assoc-ref meta "build-system")))) diff --git a/tests/import-utils.scm b/tests/import-utils.scm index 7c6c782917..c47348fc60 100644 --- a/tests/import-utils.scm +++ b/tests/import-utils.scm @@ -203,4 +203,23 @@ (define-module (test-import-utils) ("license" . #f)))) (package-native-inputs (alist->package meta)))) +(test-assert "alist->package with properties" + (let* ((meta '(("name" . "hello") + ("version" . "2.10") + ("source" . + ;; Use a 'file://' URI so that we don't cause a download. + ,(string-append "file://" + (search-path %load-path "guix.scm"))) + ("build-system" . "gnu") + ("properties" . (("hidden?" . #t) + ("upstream-name" . "hello-upstream"))) + ("home-page" . "https://gnu.org") + ("synopsis" . "Say hi") + ("description" . "This package says hi.") + ("license" . "GPL-3.0+"))) + (pkg (alist->package meta))) + (and (package? pkg) + (equal? (package-upstream-name pkg) "hello-upstream") + (hidden-package? pkg)))) + (test-end "import-utils")