From patchwork Tue Oct 3 09:17:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 54460 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B0ABE27BBE9; Tue, 3 Oct 2023 10:19:05 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 890E927BBE9 for ; Tue, 3 Oct 2023 10:19:04 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnbYM-00084A-Pk; Tue, 03 Oct 2023 05:18:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qnbYH-00083Z-69 for guix-patches@gnu.org; Tue, 03 Oct 2023 05:18:49 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnbYG-0002ia-Pf; Tue, 03 Oct 2023 05:18:48 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qnbYU-0003S4-I1; Tue, 03 Oct 2023 05:19:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65062] [PATCH v2 core-updates 1/2] ui: package-specification->name+version+output: Move to (guix packages). Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, ludo@gnu.org, dev@jpoiret.xyz, guix@cbaines.net, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 03 Oct 2023 09:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65062 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: moreinfo patch To: 65062@debbugs.gnu.org Cc: Hilton Chain , Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= , Josselin Poiret , Christopher Baines , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= , Josselin Poiret , Christopher Baines , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 65062-submit@debbugs.gnu.org id=B65062.169632471413198 (code B ref 65062); Tue, 03 Oct 2023 09:19:02 +0000 Received: (at 65062) by debbugs.gnu.org; 3 Oct 2023 09:18:34 +0000 Received: from localhost ([127.0.0.1]:38792 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qnbY1-0003Qm-HI for submit@debbugs.gnu.org; Tue, 03 Oct 2023 05:18:33 -0400 Received: from mail.boiledscript.com ([144.168.59.46]:52084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qnbY0-0003Qa-0M for 65062@debbugs.gnu.org; Tue, 03 Oct 2023 05:18:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=dkim; t=1696324581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fLs3ot+6xGwMZp4fkkjFriYktdL5LxxUtFV25loACmQ=; b=wmOQxiTTzEkUPL8DEjbgljUWWH8hlg9akD7aXAaG7ywnpsWsoZOuMC7G5U/hDZDfzai2x3 o78O1f1bbI/QmrRxo01PkVl1PrR7HPDRQ49VRqAyqtZJpDIgqLjxZ1wZgY2rwJtYxFKiVD AhwobJirHzxX9eP4PJA8FeAawkvPZVVYe4C5FaA3bcs1ZV0ife8vm66AbKh4HLNDN2jjzF UuLHY235oCYOJPEO9jXX8aXStyog7rfGVZ3KBRSUscGoWgcLEpgfFjHVQ9TBBNwwp91nW3 9kvaz/4/bfXMfJuBd0P8inJ6wBx6HZ/SelBIR9pSwmdqxu6mz9dBViJtH/cxAg== Authentication-Results: mail.boiledscript.com; auth=pass smtp.mailfrom=hako@ultrarare.space Date: Tue, 3 Oct 2023 17:17:01 +0800 Message-ID: <2b6bc0121a38d6aecf11536cc7e0c630d8eeaaa9.1696323536.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-Spamd-Bar: --- X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Hilton Chain X-ACL-Warn: , Hilton Chain via Guix-patches X-Patchwork-Original-From: Hilton Chain via Guix-patches via From: Hilton Chain Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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))) - ;;; ;;; 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"))