import/utils: alist->package: Include properties.
* 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. Signed-off-by: Ludovic Courtès <ludo@gnu.org>master
parent
168a7933c0
commit
61bd7bf469
|
@ -444,10 +444,20 @@ specifications to look up and replace them with plain symbols instead."
|
||||||
((key . value)
|
((key . value)
|
||||||
(list (symbol->keyword (string->symbol key)) value)))
|
(list (symbol->keyword (string->symbol key)) value)))
|
||||||
arguments))
|
arguments))
|
||||||
|
(define (process-properties properties)
|
||||||
|
(map (match-lambda
|
||||||
|
((key . value)
|
||||||
|
(cons (string->symbol key) value)))
|
||||||
|
properties))
|
||||||
|
|
||||||
(package
|
(package
|
||||||
(name (assoc-ref meta "name"))
|
(name (assoc-ref meta "name"))
|
||||||
(version (assoc-ref meta "version"))
|
(version (assoc-ref meta "version"))
|
||||||
(source (source-spec->object (assoc-ref meta "source")))
|
(source (source-spec->object (assoc-ref meta "source")))
|
||||||
|
(properties
|
||||||
|
(or (and=> (assoc-ref meta "properties")
|
||||||
|
process-properties)
|
||||||
|
'()))
|
||||||
(build-system
|
(build-system
|
||||||
(lookup-build-system-by-name
|
(lookup-build-system-by-name
|
||||||
(string->symbol (assoc-ref meta "build-system"))))
|
(string->symbol (assoc-ref meta "build-system"))))
|
||||||
|
|
|
@ -203,4 +203,23 @@
|
||||||
("license" . #f))))
|
("license" . #f))))
|
||||||
(package-native-inputs (alist->package meta))))
|
(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")
|
(test-end "import-utils")
|
||||||
|
|
Reference in New Issue