guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#58020] [PATCH] import/utils: alist->package: Include properties.


From: itd
Subject: [bug#58020] [PATCH] import/utils: alist->package: Include properties.
Date: Fri, 23 Sep 2022 09:42:53 +0200

* 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(+)

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")

base-commit: 04cad8e29ed85be838921c7fa05f7c5bce94b6d1
-- 
2.37.3






reply via email to

[Prev in Thread] Current Thread [Next in Thread]