all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: itd <itd@net.in.tum.de>
To: 58020@debbugs.gnu.org
Subject: [bug#58020] [PATCH] import/utils: alist->package: Include properties.
Date: Fri, 23 Sep 2022 09:42:53 +0200	[thread overview]
Message-ID: <87mtaqilj6.fsf@localhost> (raw)


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

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

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

  git send-email \
    --in-reply-to=87mtaqilj6.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.