emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#58020: closed ([PATCH] import/utils: alist->package: Include propert


From: GNU bug Tracking System
Subject: bug#58020: closed ([PATCH] import/utils: alist->package: Include properties.)
Date: Thu, 29 Sep 2022 20:32:01 +0000

Your message dated Thu, 29 Sep 2022 22:31:06 +0200
with message-id <87wn9l9b3p.fsf@gnu.org>
and subject line Re: bug#58020: [PATCH] import/utils: alist->package: Include 
properties.
has caused the debbugs.gnu.org bug report #58020,
regarding [PATCH] import/utils: alist->package: Include properties.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
58020: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58020
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [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




--- End Message ---
--- Begin Message --- Subject: Re: bug#58020: [PATCH] import/utils: alist->package: Include properties. Date: Thu, 29 Sep 2022 22:31:06 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)
Hi,

itd <itd@net.in.tum.de> skribis:

> * 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.

[...]

> +  (define (process-properties properties)
> +    (append-map (match-lambda
> +                  ((key . value)
> +                   (acons (string->symbol key) value '())))
> +                properties))

I applied the patch and simplified this one.

> * guix/import/print.scm (package->code): Quasiquote properties.
> * tests/print.scm (pkg-with-properties, pkg-with-properties-source):
>     New variables.
>     ("package with properties"): New test

Applied, thanks!

Ludo’.


--- End Message ---

reply via email to

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