all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Hilton Chain via Guix-patches via <guix-patches@gnu.org>
To: 65062@debbugs.gnu.org
Cc: "Hilton Chain" <hako@ultrarare.space>,
	"Hilton Chain" <hako@ultrarare.space>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Josselin Poiret" <dev@jpoiret.xyz>,
	"Christopher Baines" <guix@cbaines.net>,
	"Mathieu Othacehe" <othacehe@gnu.org>,
	"Ricardo Wurmus" <rekado@elephly.net>,
	"Simon Tournier" <zimon.toutoune@gmail.com>,
	"Tobias Geerinckx-Rice" <me@tobias.gr>
Subject: [bug#65062] [PATCH v2 core-updates 1/2] ui: package-specification->name+version+output: Move to (guix packages).
Date: Tue,  3 Oct 2023 17:17:01 +0800	[thread overview]
Message-ID: <2b6bc0121a38d6aecf11536cc7e0c630d8eeaaa9.1696323536.git.hako@ultrarare.space> (raw)
In-Reply-To: <cover.1696323536.git.hako@ultrarare.space>

* 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(-)

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)))
-
 \f
 ;;;
 ;;; 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





  reply	other threads:[~2023-10-03  9:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-05  2:50 [bug#65062] [PATCH core-updates 0/1] Specify output in input label when it's not "out" Hilton Chain via Guix-patches via
2023-08-05  2:53 ` [bug#65062] [PATCH core-updates 1/1] packages: " Hilton Chain via Guix-patches via
2023-08-22 16:00   ` Ludovic Courtès
2023-08-24  3:42     ` Hilton Chain via Guix-patches via
2023-08-25 11:10       ` Josselin Poiret via Guix-patches via
2023-09-08 22:03       ` Ludovic Courtès
2023-10-03  9:13         ` Hilton Chain via Guix-patches via
2023-08-05  3:01 ` [bug#65062] [PATCH core-updates 0/1] " Hilton Chain via Guix-patches via
2023-08-05  3:19   ` Hilton Chain via Guix-patches via
2023-10-03  9:15 ` [bug#65062] [PATCH v2 core-updates 0/2] packages: Lookup inputs by specification Hilton Chain via Guix-patches via
2023-10-03  9:17   ` Hilton Chain via Guix-patches via [this message]
2023-10-03  9:17   ` [bug#65062] [PATCH v2 core-updates 2/2] " Hilton Chain via Guix-patches via
2023-12-20 21:26     ` [bug#65062] [PATCH core-updates] " 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=2b6bc0121a38d6aecf11536cc7e0c630d8eeaaa9.1696323536.git.hako@ultrarare.space \
    --to=guix-patches@gnu.org \
    --cc=65062@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=guix@cbaines.net \
    --cc=hako@ultrarare.space \
    --cc=ludo@gnu.org \
    --cc=me@tobias.gr \
    --cc=othacehe@gnu.org \
    --cc=rekado@elephly.net \
    --cc=zimon.toutoune@gmail.com \
    /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.