From patchwork Sun Apr 9 04:43:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Deslauriers, Douglas via Guix-patches\" via" X-Patchwork-Id: 49041 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 D3A811748A; Sun, 9 Apr 2023 05:44:24 +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=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable 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 E299F17434 for ; Sun, 9 Apr 2023 05:44:22 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1plMuK-0008Q3-7N; Sun, 09 Apr 2023 00:44:04 -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 1plMuI-0008Pv-Hb for guix-patches@gnu.org; Sun, 09 Apr 2023 00:44:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1plMuI-0002qV-84 for guix-patches@gnu.org; Sun, 09 Apr 2023 00:44:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1plMuH-0004zQ-ST for guix-patches@gnu.org; Sun, 09 Apr 2023 00:44:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62577] [PATCH v2] refresh: Support select packages SUBSET by module name. References: <20230401035930.3877-1-iyzsong@envs.net> In-Reply-To: <20230401035930.3877-1-iyzsong@envs.net> Resent-From: iyzsong@envs.net Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 09 Apr 2023 04:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62577 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62577@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , =?utf-8?b?5a6L5paH5q2m?= Received: via spool by 62577-submit@debbugs.gnu.org id=B62577.168101538219107 (code B ref 62577); Sun, 09 Apr 2023 04:44:01 +0000 Received: (at 62577) by debbugs.gnu.org; 9 Apr 2023 04:43:02 +0000 Received: from localhost ([127.0.0.1]:60058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plMtK-0004xv-8O for submit@debbugs.gnu.org; Sun, 09 Apr 2023 00:43:02 -0400 Received: from mail.envs.net ([5.199.136.28]:56234) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plMtH-0004xg-Uh for 62577@debbugs.gnu.org; Sun, 09 Apr 2023 00:43:01 -0400 Received: from localhost (mail.envs.net [127.0.0.1]) by mail.envs.net (Postfix) with ESMTP id 8B04938A0066; Sun, 9 Apr 2023 04:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=envs.net; s=modoboa; t=1681015377; bh=XiG8AofPlelgotAkEy2FGgu3VG02lXseCo7Y3QOGLFw=; h=From:To:Cc:Subject:Date:From; b=LcdWRX9Ebkt1RBCbehR6GtgURb/2nbX7UWjRp6DGAqfKTrPjwa3+5yWdVs3wXvdtS /Fd3tLb8pl66PjNsiq8nQ6+r1aS84dd5WkdU0qjRQgq4w035qrtfudj2p9MO3i2KEX JtmBFLhFdIi6AAaSpAdaXUIWO5X4Hf/akyR2jNgEFxFa0O8HMRrKRRWEyK0yCNSwVM 6DuokW1joHQk45Ky8QCr44KS/e/3bpNqUm+d7S5hi1VuveBHZw2JHqvl7ZJN6xhcId x1foU6ecTACPOAvwIgBMFSJRR7hb81LVBA6Zu6XQvo2XrBldemsRHDNaYdRIm6UyUd 8THUFCsDvhUkY1LHromAh7iWht7EmW2GZ3tq2Cm+rl7WVHQRlUbgsKM/L9nbkircM3 qhMJyjvz1UzmPVbKgOGNC8bwp3VAqVWG6O7eIc+JPt2GzAtDGj18YJ9aMJi6SktYSB AsPzBUs+g6qF93NK42evDrI2lorSxsakcJSCBcEsKoaO6R52nTcV68aTHPR6gT4ukR WAur3ys4voipfuWXLs/XHJeAlwLjl96V2UwlI86qzs0KYed4mLdkNcG4GA732zqYjP xd8Qbu7w/y3RRYpClnO3/qEyOJf9C8UYXW5q/6egoXJ0CLQVQdwcWoQRcjhCjm6JVI lHTRWdmec6yq+bXX4K/zyXOs= X-Virus-Scanned: Debian amavisd-new at mail.envs.net Received: from mail.envs.net ([127.0.0.1]) by localhost (mail.envs.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id yfO2pBnhU3l2; Sun, 9 Apr 2023 04:42:50 +0000 (UTC) Received: from localhost (unknown [36.170.56.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.envs.net (Postfix) with ESMTPSA; Sun, 9 Apr 2023 04:42:50 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 00d3c0ef; Sun, 9 Apr 2023 04:43:39 +0000 (UTC) Date: Sun, 9 Apr 2023 12:43:30 +0800 Message-Id: <20230409044330.6424-1-iyzsong@envs.net> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 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: iyzsong@envs.net X-ACL-Warn: , iyzsong--- via Guix-patches X-Patchwork-Original-From: iyzsong--- via Guix-patches via From: "Deslauriers, Douglas via Guix-patches\" via" 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 From: 宋文武 * guix/scripts/refresh.scm (%options): Support '--select module:NAME'. (show-help): Adjust accordingly. (options->update-specs): Honor the module passed by '--select'. * doc/guix.texi (Invoking guix refresh): Document it. --- doc/guix.texi | 9 +++++++-- guix/scripts/refresh.scm | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 7 deletions(-) base-commit: c1262edba9118af6507dc47ce6ad61ffdec02384 diff --git a/doc/guix.texi b/doc/guix.texi index ed42488882..711755dbe3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14227,8 +14227,8 @@ $ ./pre-inst-env guix refresh -s non-core -u @item --select=[@var{subset}] @itemx -s @var{subset} -Select all the packages in @var{subset}, one of @code{core} or -@code{non-core}. +Select all the packages in @var{subset}, one of @code{core}, @code{non-core} +or @code{module:NAME}. The @code{core} subset refers to all the packages at the core of the distribution---i.e., packages that are used to build ``everything @@ -14241,6 +14241,11 @@ The @code{non-core} subset refers to the remaining packages. It is typically useful in cases where an update of the core packages would be inconvenient. +The @code{module:NAME} subset refers to all the packages in a specified +guile module. The module can be specified as @code{module:guile} or +@code{module:(gnu packages guile)}, the former is a shorthand for the +later. + @item --manifest=@var{file} @itemx -m @var{file} Select all the packages from the manifest in @var{file}. This is useful to diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index bc6c24967a..47c4d55ec4 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -32,6 +32,7 @@ (define-module (guix scripts refresh) #:use-module ((guix scripts build) #:select (%standard-build-options)) #:use-module (guix store) #:use-module (guix utils) + #:use-module (guix discovery) #:use-module (guix packages) #:use-module (guix profiles) #:use-module (guix upstream) @@ -44,6 +45,7 @@ (define-module (guix scripts refresh) #:use-module ((gnu packages commencement) #:select (%final-inputs)) #:use-module (ice-9 match) #:use-module (ice-9 format) + #:use-module (ice-9 regex) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) @@ -71,8 +73,23 @@ (define %options ((or "core" "non-core") (alist-cons 'select (string->symbol arg) result)) + ((? (cut string-prefix? "module:" <>)) + (let ((mod (cond + ;; Shorthand name: "module:guile". + ((string-match "module:([^\( ]+)$" arg) => + (lambda (m) + `(gnu packages ,(string->symbol + (match:substring m 1))))) + ;; Full name : "module:(gnu packages guile)". + ((string-match "module:\\(([^)]+)\\)$" arg) => + (lambda (m) + (map string->symbol + (string-split + (match:substring m 1) #\space)))) + (else (leave (G_ "invalid module: ~a~%") arg))))) + (alist-cons 'select (cons 'module mod) result))) (x - (leave (G_ "~a: invalid selection; expected `core' or `non-core'~%") + (leave (G_ "~a: invalid selection; expected `core', `non-core' or `module:NAME'~%") arg))))) (option '(#\t "type") #t #f (lambda (opt name arg result) @@ -141,8 +158,10 @@ (define (show-help) (display (G_ " -u, --update update source files in place")) (display (G_ " - -s, --select=SUBSET select all the packages in SUBSET, one of - `core' or `non-core'")) + -s, --select=SUBSET select all the packages in SUBSET, one of `core`, + `non-core' or `module:NAME' (eg: module:guile) + the module can also be fully specified as + 'module:(gnu packages guile)'")) (display (G_ " -m, --manifest=FILE select all the packages from the manifest in FILE")) (display (G_ " @@ -257,13 +276,20 @@ (define update-specs (let ((select? (match (assoc-ref opts 'select) ('core core-package?) ('non-core (negate core-package?)) - (_ (const #t))))) + (_ (const #t)))) + (modules (match (assoc-ref opts 'select) + (('module . mod) + (list (resolve-interface mod))) + (_ (all-modules (%package-module-path) + #:warn + warn-about-load-error))))) (map update-spec (fold-packages (lambda (package result) (if (select? package) (keep-newest package result) result)) - '())))) + '() + modules)))) (some ;user-specified packages some)))