[bug#58020] import/utils: alist->package: Include properties.
Commit Message
* 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
Comments
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’.
@@ -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"))))
@@ -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")