GNU bug report logs - #62577
[PATCH] refresh: Support select packages SUBSET by module name.

Previous Next

Package: guix-patches;

Reported by: iyzsong <at> envs.net

Date: Sat, 1 Apr 2023 04:00:02 UTC

Severity: normal

Tags: patch

Done: 宋文武 <iyzsong <at> envs.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62577 in the body.
You can then email your comments to 62577 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#62577; Package guix-patches. (Sat, 01 Apr 2023 04:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to iyzsong <at> envs.net:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 01 Apr 2023 04:00:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: iyzsong <at> envs.net
To: guix-patches <at> gnu.org
Cc: 宋文武 <iyzsong <at> member.fsf.org>
Subject: [PATCH] refresh: Support select packages SUBSET by module name.
Date: Sat,  1 Apr 2023 11:59:30 +0800
From: 宋文武 <iyzsong <at> member.fsf.org>

* guix/scripts/refresh.scm (%options): Support '--select module:NAME'.
(show-help): Adjust accordingly.
(options->update-specs): Honor the module passed by '--select'.
---
 guix/scripts/refresh.scm | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index bc6c24967a..d6ac574b1f 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)
@@ -71,8 +72,15 @@ (define %options
                     ((or "core" "non-core")
                      (alist-cons 'select (string->symbol arg)
                                  result))
+                    ((? (cut string-prefix? "module:" <>))
+                     (alist-cons 'select
+                                 (cons 'module
+                                       (string->symbol
+                                        (string-drop
+                                         arg (string-length "module:"))))
+                                 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 +149,8 @@ (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)"))
   (display (G_ "
   -m, --manifest=FILE    select all the packages from the manifest in FILE"))
   (display (G_ "
@@ -257,13 +265,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 `(gnu packages ,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)))
 

base-commit: 1c6238794b0058003fa6c827ca0d039764ebe699
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#62577; Package guix-patches. (Sat, 08 Apr 2023 21:28:01 GMT) Full text and rfc822 format available.

Message #8 received at 62577 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: iyzsong <at> envs.net
Cc: 62577 <at> debbugs.gnu.org, 宋文武 <iyzsong <at> member.fsf.org>
Subject: Re: bug#62577: [PATCH] refresh: Support select packages SUBSET by
 module name.
Date: Sat, 08 Apr 2023 23:27:48 +0200
Hi,

iyzsong <at> envs.net skribis:

> From: 宋文武 <iyzsong <at> member.fsf.org>
>
> * guix/scripts/refresh.scm (%options): Support '--select module:NAME'.
> (show-help): Adjust accordingly.
> (options->update-specs): Honor the module passed by '--select'.

That looks very useful!

Could you also update ‘doc/guix.texi’?

> +                    ((? (cut string-prefix? "module:" <>))
> +                     (alist-cons 'select
> +                                 (cons 'module
> +                                       (string->symbol
> +                                        (string-drop
> +                                         arg (string-length "module:"))))
> +                                 result))

Perhaps this should support both full module names:

  module:(past packages autotools)

and:

  module:guile

where the latter is short for “module:(gnu packages guile)”.

WDYT?

Otherwise LGTM.

Could you send an updated version?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#62577; Package guix-patches. (Sun, 09 Apr 2023 04:44:01 GMT) Full text and rfc822 format available.

Message #11 received at 62577 <at> debbugs.gnu.org (full text, mbox):

From: iyzsong <at> envs.net
To: 62577 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>,
 宋文武 <iyzsong <at> member.fsf.org>
Subject: [PATCH v2] refresh: Support select packages SUBSET by module name.
Date: Sun,  9 Apr 2023 12:43:30 +0800
From: 宋文武 <iyzsong <at> member.fsf.org>

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

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

base-commit: c1262edba9118af6507dc47ce6ad61ffdec02384
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#62577; Package guix-patches. (Sun, 09 Apr 2023 04:46:02 GMT) Full text and rfc822 format available.

Message #14 received at 62577 <at> debbugs.gnu.org (full text, mbox):

From: 宋文武 <iyzsong <at> envs.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 62577 <at> debbugs.gnu.org, 宋文武 <iyzsong <at> member.fsf.org>
Subject: Re: bug#62577: [PATCH] refresh: Support select packages SUBSET by
 module name.
Date: Sun, 09 Apr 2023 12:46:36 +0800
Ludovic Courtès <ludo <at> gnu.org> writes:

> Could you send an updated version?

v2 patch sent with update guix.texi and support full module name, thank
you for the suggestions!




Information forwarded to guix-patches <at> gnu.org:
bug#62577; Package guix-patches. (Thu, 20 Apr 2023 10:19:01 GMT) Full text and rfc822 format available.

Message #17 received at 62577 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: iyzsong <at> envs.net
Cc: 62577 <at> debbugs.gnu.org, 宋文武 <iyzsong <at> member.fsf.org>
Subject: Re: [PATCH v2] refresh: Support select packages SUBSET by module name.
Date: Thu, 20 Apr 2023 12:18:08 +0200
Hi,

iyzsong <at> envs.net skribis:

> From: 宋文武 <iyzsong <at> member.fsf.org>
>
> * 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.

[...]

> +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

s/@code{module:NAME}/@code{module:@var{name}}/

Otherwise LGTM, thanks!

Ludo’.




Reply sent to 宋文武 <iyzsong <at> envs.net>:
You have taken responsibility. (Sun, 23 Apr 2023 07:37:01 GMT) Full text and rfc822 format available.

Notification sent to iyzsong <at> envs.net:
bug acknowledged by developer. (Sun, 23 Apr 2023 07:37:01 GMT) Full text and rfc822 format available.

Message #22 received at 62577-done <at> debbugs.gnu.org (full text, mbox):

From: 宋文武 <iyzsong <at> envs.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 62577-done <at> debbugs.gnu.org
Subject: Re: bug#62577: [PATCH] refresh: Support select packages SUBSET by
 module name.
Date: Sun, 23 Apr 2023 15:36:02 +0800
Ludovic Courtès <ludo <at> gnu.org> writes:

>> +The @code{module:NAME} subset refers to all the packages in a specified
>
> s/@code{module:NAME}/@code{module:@var{name}}/
>
> Otherwise LGTM, thanks!

Pushed, thank you for review!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 21 May 2023 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 87 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.