GNU bug report logs -
#58020
[PATCH] import/utils: alist->package: Include properties.
Previous Next
Reported by: itd <itd <at> net.in.tum.de>
Date: Fri, 23 Sep 2022 07:44:01 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58020 in the body.
You can then email your comments to 58020 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#58020
; Package
guix-patches
.
(Fri, 23 Sep 2022 07:44:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
itd <itd <at> net.in.tum.de>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Fri, 23 Sep 2022 07:44:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* 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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#58020
; Package
guix-patches
.
(Fri, 23 Sep 2022 14:14:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 58020 <at> debbugs.gnu.org (full text, mbox):
* 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
---
Hi again,
if I'm not mistaken, it is also required to (quasi)quote the value of
properties. This patch updates package->code to achieve this.
Afterward, the following command:
> $ guix import json /dev/stdin <<EOF
> {
> "name": "hello",
> "version": "2.10",
> "source": "mirror://gnu/hello/hello-2.10.tar.gz",
> "build-system": "gnu",
> "home-page": "https://www.gnu.org/software/hello/",
> "synopsis": "Hello, GNU world: An example GNU package",
> "description": "GNU Hello prints a greeting.",
> "license": "GPL-3.0+",
> "native-inputs": ["gettext"],
> "properties": {
> "hidden?": true,
> "upstream-name": "hello-upstream"
> }
> }
> EOF
should produce the following package definition:
> (define-public hello
> (package
> (name "hello")
> (version "2.10")
> (source (origin
> (method url-fetch)
> (uri (string-append "mirror://gnu/hello/hello-" version
> ".tar.gz"))
> (sha256
> (base32
> "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
> (properties `((upstream-name . "hello-upstream") (hidden? . #t)))
> (build-system (@ (guix build-system gnu) gnu-build-system))
> (native-inputs (list (@ (gnu packages gettext) gnu-gettext)))
> (home-page "https://www.gnu.org/software/hello/")
> (synopsis "Hello, GNU world: An example GNU package")
> (description "GNU Hello prints a greeting.")
> (license license:gpl3+)))
> hello
Regards
itd
guix/import/print.scm | 3 ++-
tests/print.scm | 23 +++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/guix/import/print.scm b/guix/import/print.scm
index 66016145cb..2f54adbd8c 100644
--- a/guix/import/print.scm
+++ b/guix/import/print.scm
@@ -200,7 +200,8 @@ (define (package->code package)
(source ,(source->code source version))
,@(match properties
(() '())
- (_ `((properties ,properties))))
+ (_ `((properties
+ ,(list 'quasiquote (object->code properties #t))))))
,@(if replacement
`((replacement ,replacement))
'())
diff --git a/tests/print.scm b/tests/print.scm
index d9710d1ed3..b4f193b905 100644
--- a/tests/print.scm
+++ b/tests/print.scm
@@ -139,6 +139,25 @@ (define-with-source pkg-with-arguments pkg-with-arguments-source
(description "This is a dummy package.")
(license license:gpl3+)))
+(define-with-source pkg-with-properties pkg-with-properties-source
+ (package
+ (name "test")
+ (version "1.2.3")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "file:///tmp/test-"
+ version ".tar.gz"))
+ (sha256
+ (base32
+ "070pwb7brdcn1mfvplkd56vjc7lbz4iznzkqvfsakvgbv68k71ah"))))
+ (properties
+ `((hidden? . #t) (upstream-name "test-upstream")))
+ (build-system (@ (guix build-system gnu) gnu-build-system))
+ (home-page "http://gnu.org")
+ (synopsis "Dummy")
+ (description "This is a dummy package.")
+ (license license:gpl3+)))
+
(test-equal "simple package"
`(define-public test ,pkg-source)
(package->code pkg))
@@ -159,4 +178,8 @@ (define-with-source pkg-with-arguments pkg-with-arguments-source
`(define-public test ,pkg-with-arguments-source)
(package->code pkg-with-arguments))
+(test-equal "package with properties"
+ `(define-public test ,pkg-with-properties-source)
+ (package->code pkg-with-properties))
+
(test-end "print")
--
2.37.3
Reply sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
You have taken responsibility.
(Thu, 29 Sep 2022 20:32:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
itd <itd <at> net.in.tum.de>
:
bug acknowledged by developer.
(Thu, 29 Sep 2022 20:32:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 58020-done <at> debbugs.gnu.org (full text, mbox):
Hi,
itd <itd <at> 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’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 28 Oct 2022 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 180 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.