mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
import: utils: Add some utilities.
* guix/import/utils.scm (maybe-inputs, maybe-native-inputs, package->definition): New variables.
This commit is contained in:
parent
4b3cb7f4bc
commit
bb3f36ed4c
1 changed files with 34 additions and 0 deletions
|
@ -22,6 +22,7 @@ (define-module (guix import utils)
|
||||||
#:use-module (guix base32)
|
#:use-module (guix base32)
|
||||||
#:use-module ((guix build download) #:prefix build:)
|
#:use-module ((guix build download) #:prefix build:)
|
||||||
#:use-module (guix hash)
|
#:use-module (guix hash)
|
||||||
|
#:use-module (guix http-client)
|
||||||
#:use-module ((guix licenses) #:prefix license:)
|
#:use-module ((guix licenses) #:prefix license:)
|
||||||
#:use-module (guix utils)
|
#:use-module (guix utils)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
|
@ -36,6 +37,10 @@ (define-module (guix import utils)
|
||||||
url-fetch
|
url-fetch
|
||||||
guix-hash-url
|
guix-hash-url
|
||||||
|
|
||||||
|
maybe-inputs
|
||||||
|
maybe-native-inputs
|
||||||
|
package->definition
|
||||||
|
|
||||||
spdx-string->license
|
spdx-string->license
|
||||||
license->symbol
|
license->symbol
|
||||||
|
|
||||||
|
@ -205,3 +210,32 @@ (define (beautify-description description)
|
||||||
;; Use double spacing between sentences
|
;; Use double spacing between sentences
|
||||||
(regexp-substitute/global #f "\\. \\b"
|
(regexp-substitute/global #f "\\. \\b"
|
||||||
cleaned 'pre ". " 'post)))
|
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))))
|
||||||
|
|
Loading…
Reference in a new issue