summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Craven <david@craven.ch>2016-12-10 18:43:39 +0100
committerDavid Craven <david@craven.ch>2016-12-14 16:30:42 +0100
commitbb3f36ed4ca83f01eb422f9de9c404d53218b382 (patch)
treea3dd788138202798f98cdbc103f066c8417954b0
parent4b3cb7f4bc5d5a265731fe3ecc752a25968cad45 (diff)
downloadguix-bb3f36ed4ca83f01eb422f9de9c404d53218b382.tar.gz
import: utils: Add some utilities.
* guix/import/utils.scm (maybe-inputs, maybe-native-inputs,
  package->definition): New variables.
-rw-r--r--guix/import/utils.scm34
1 files changed, 34 insertions, 0 deletions
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 057c2d9c7d..f304da20e6 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -22,6 +22,7 @@
   #:use-module (guix base32)
   #:use-module ((guix build download) #:prefix build:)
   #:use-module (guix hash)
+  #:use-module (guix http-client)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix utils)
   #:use-module (ice-9 match)
@@ -36,6 +37,10 @@
             url-fetch
             guix-hash-url
 
+            maybe-inputs
+            maybe-native-inputs
+            package->definition
+
             spdx-string->license
             license->symbol
 
@@ -205,3 +210,32 @@ into a proper sentence and by using two spaces between sentences."
     ;; Use double spacing between sentences
     (regexp-substitute/global #f "\\. \\b"
                               cleaned 'pre ".  " 'post)))
+
+(define (package-names->package-inputs names)
+  (map (lambda (input)
+         (list input (list 'unquote (string->symbol input))))
+       names))
+
+(define (maybe-inputs package-names)
+  "Given a list of PACKAGE-NAMES, tries to generate the 'inputs' field of a
+package definition."
+  (match (package-names->package-inputs package-names)
+    (()
+     '())
+    ((package-inputs ...)
+     `((inputs (,'quasiquote ,package-inputs))))))
+
+(define (maybe-native-inputs package-names)
+  "Given a list of PACKAGE-NAMES, tries to generate the 'inputs' field of a
+package definition."
+  (match (package-names->package-inputs package-names)
+    (()
+     '())
+    ((package-inputs ...)
+     `((native-inputs (,'quasiquote ,package-inputs))))))
+
+(define (package->definition guix-package)
+  (match guix-package
+    (('package ('name (? string? name)) _ ...)
+     `(define-public ,(string->symbol name)
+        ,guix-package))))