unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: itd <itd@net.in.tum.de>
To: 58020@debbugs.gnu.org
Subject: [bug#58020] [PATCH] import: print: Quasiquote properties
Date: Fri, 23 Sep 2022 16:11:52 +0200	[thread overview]
Message-ID: <874jwyi3iv.fsf@localhost> (raw)
In-Reply-To: <87mtaqilj6.fsf@localhost>


* 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	other threads:[~2022-09-23 14:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-23  7:42 [bug#58020] [PATCH] import/utils: alist->package: Include properties itd
2022-09-23 14:11 ` itd [this message]
2022-09-29 20:31 ` bug#58020: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jwyi3iv.fsf@localhost \
    --to=itd@net.in.tum.de \
    --cc=58020@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).