* guix/ui.scm (package-specification->name+version+output): Move it to...
* guix/packages.scm (package-specification->name+version+output): ...here.
* tests/ui.scm (package-specification->name+version+output): Move it to...
* tests/packages.scm (package-specification->name+version+output): ...here.
---
guix/packages.scm | 23 +++++++++++++++++++++++
guix/ui.scm | 21 ---------------------
tests/packages.scm | 17 +++++++++++++++++
tests/ui.scm | 17 -----------------
4 files changed, 40 insertions(+), 38 deletions(-)
Toggle diff (145 lines)
diff --git a/guix/packages.scm b/guix/packages.scm
index f70fad695e..b004882cc6 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -52,6 +52,7 @@ (define-module (guix packages)
#:use-module (ice-9 regex)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9 gnu)
+ #:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
@@ -117,6 +118,8 @@ (define-module (guix packages)
deprecated-package
package-field-location
+ package-specification->name+version+output
+
this-package-input
this-package-native-input
@@ -783,6 +786,26 @@ (define (package-field-location package field)
#f)))
(_ #f)))
+(define* (package-specification->name+version+output spec
+ #:optional (output "out"))
+ "Parse package specification SPEC and return three value: the specified
+package name, version number (or #f), and output name (or OUTPUT). SPEC may
+optionally contain a version number and an output name, as in these examples:
+
+ guile
+ guile@2.0.9
+ guile:debug
+ guile@2.0.9:debug
+"
+ (let*-values (((name sub-drv)
+ (match (string-rindex spec #\:)
+ (#f (values spec output))
+ (colon (values (substring spec 0 colon)
+ (substring spec (+ 1 colon))))))
+ ((name version)
+ (package-name->name+version name)))
+ (values name version sub-drv)))
+
(define-syntax-rule (this-package-input name)
"Return the input NAME of the package being defined--i.e., an input
from the ‘inputs’ or ‘propagated-inputs’ field. Native inputs are not
diff --git a/guix/ui.scm b/guix/ui.scm
index 6f2d4fe245..0cc121f048 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -118,7 +118,6 @@ (define-module (guix ui)
package-synopsis-string
string->recutils
package->recutils
- package-specification->name+version+output
pager-wrapped-port
with-paginated-output-port
@@ -2098,26 +2097,6 @@ (define (delete-generation* store profile generation)
(generation-file-name profile generation))
(delete-generation store profile generation))
-(define* (package-specification->name+version+output spec
- #:optional (output "out"))
- "Parse package specification SPEC and return three value: the specified
-package name, version number (or #f), and output name (or OUTPUT). SPEC may
-optionally contain a version number and an output name, as in these examples:
-
- guile
- guile@2.0.9
- guile:debug
- guile@2.0.9:debug
-"
- (let*-values (((name sub-drv)
- (match (string-rindex spec #\:)
- (#f (values spec output))
- (colon (values (substring spec 0 colon)
- (substring spec (+ 1 colon))))))
- ((name version)
- (package-name->name+version name)))
- (values name version sub-drv)))
-
;;;
;;; Command-line option processing.
diff --git a/tests/packages.scm b/tests/packages.scm
index 2b4f9f8e90..be9188ceb1 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -1926,6 +1926,23 @@ (define compressors '(("gzip" . "gz")
"-p" (derivation->output-path prof2)
"--search-paths"))))))
+(test-equal "package-specification->name+version+output"
+ '(("guile" #f "out")
+ ("guile" "2.0.9" "out")
+ ("guile" #f "debug")
+ ("guile" "2.0.9" "debug")
+ ("guile-cairo" "1.4.1" "out"))
+ (map (lambda (spec)
+ (call-with-values
+ (lambda ()
+ (package-specification->name+version+output spec))
+ list))
+ '("guile"
+ "guile@2.0.9"
+ "guile:debug"
+ "guile@2.0.9:debug"
+ "guile-cairo@1.4.1")))
+
(test-equal "specification->package when not found"
'quit
(catch 'quit
diff --git a/tests/ui.scm b/tests/ui.scm
index 438acae525..7bd948bd14 100644
--- a/tests/ui.scm
+++ b/tests/ui.scm
@@ -100,23 +100,6 @@ (define guile-2.0.9
(package-description-string
(dummy-package "foo" (description "b•ll•t")))))
-(test-equal "package-specification->name+version+output"
- '(("guile" #f "out")
- ("guile" "2.0.9" "out")
- ("guile" #f "debug")
- ("guile" "2.0.9" "debug")
- ("guile-cairo" "1.4.1" "out"))
- (map (lambda (spec)
- (call-with-values
- (lambda ()
- (package-specification->name+version+output spec))
- list))
- '("guile"
- "guile@2.0.9"
- "guile:debug"
- "guile@2.0.9:debug"
- "guile-cairo@1.4.1")))
-
(test-equal "integer"
'(1)
(string->generations "1"))
--
2.41.0