guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: scripts: refresh: Allow searching recursively.


From: guix-commits
Subject: 01/01: scripts: refresh: Allow searching recursively.
Date: Mon, 24 Dec 2018 05:33:05 -0500 (EST)

efraim pushed a commit to branch master
in repository guix.

commit c39491829a0c1d870f8133b8f7a699152fc71503
Author: Efraim Flashner <address@hidden>
Date:   Wed Dec 19 22:08:18 2018 +0200

    scripts: refresh: Allow searching recursively.
    
    * guix/scripts/refresh.scm (refresh-recursive, list-transitive): New
    procedures.
    (show-help): Document it.
    (guix-refresh): Add flags and checks for new options.
    * doc/guix.texi (Invoking guix refresh): Document new options.
---
 doc/guix.texi            | 32 ++++++++++++++++++++++++++++
 guix/scripts/refresh.scm | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 2553ba7..514ee3e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -7392,6 +7392,22 @@ are many packages, though, for which it lacks a method 
to determine
 whether a new upstream release is available.  However, the mechanism is
 extensible, so feel free to get in touch with us to add a new method!
 
address@hidden @code
+
address@hidden --recursive
+Consider the packages specified, and all the packages upon which they depend.
+
address@hidden
+$ guix refresh --recursive coreutils
+gnu/packages/acl.scm:35:2: warning: no updater for acl
+gnu/packages/m4.scm:30:12: info: 1.4.18 is already the latest version of m4
+gnu/packages/xml.scm:68:2: warning: no updater for expat
+gnu/packages/multiprecision.scm:40:12: info: 6.1.2 is already the latest 
version of gmp
address@hidden
address@hidden example
+
address@hidden table
+
 Sometimes the upstream name differs from the package name used in Guix,
 and @command{guix refresh} needs a little help.  Most updaters honor the
 @code{upstream-name} property in package definitions, which can be used
@@ -7565,6 +7581,22 @@ hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 
cflow@@1.4 idutils@@4.6 @dots{}
 The command above lists a set of packages that could be built to check
 for compatibility with an upgraded @code{flex} package.
 
address@hidden @code
+
address@hidden --list-transitive
+List all the packages which one or more packages depend upon.
+
address@hidden
+$ guix refresh --list-transitive flex
address@hidden depends on the following 25 packages: address@hidden 
address@hidden
address@hidden address@hidden address@hidden address@hidden address@hidden 
address@hidden address@hidden @dote{}
address@hidden example
+
address@hidden table
+
+The command above lists a set of packages which, when changed, would cause
address@hidden to be rebuilt.
+
 The following options can be used to customize GnuPG operation:
 
 @table @code
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 1d86f94..003c915 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2015 Alex Kost <address@hidden>
 ;;; Copyright © 2016 Ben Woodcroft <address@hidden>
 ;;; Copyright © 2017 Mathieu Othacehe <address@hidden>
+;;; Copyright © 2018 Efraim Flashner <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -40,6 +41,7 @@
   #:use-module (ice-9 regex)
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 format)
+  #:use-module (ice-9 threads) ; par-for-each
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-26)
@@ -88,6 +90,12 @@
         (option '(#\l "list-dependent") #f #f
                 (lambda (opt name arg result)
                   (alist-cons 'list-dependent? #t result)))
+        (option '(#\r "recursive") #f #f
+                (lambda (opt name arg result)
+                  (alist-cons 'recursive? #t result)))
+        (option '("list-transitive") #f #f
+                (lambda (opt name arg result)
+                  (alist-cons 'list-transitive? #t result)))
 
         (option '("keyring") #t #f
                 (lambda (opt name arg result)
@@ -140,6 +148,10 @@ specified with `--select'.\n"))
   (display (G_ "
   -l, --list-dependent   list top-level dependent packages that would need to
                          be rebuilt as a result of upgrading PACKAGE..."))
+  (display (G_ "
+  -r, --recursive        check the PACKAGE and its inputs for upgrades"))
+  (display (G_ "
+      --list-transitive  list all the packages that PACKAGE depends on"))
   (newline)
   (display (G_ "
       --keyring=FILE     use FILE as the keyring of upstream OpenPGP keys"))
@@ -323,6 +335,43 @@ dependent packages are rebuilt: ~{~a~^ ~}~%"
                  (map full-name covering))))
       (return #t))))
 
+(define (refresh-recursive packages)
+  "Check all of the package inputs of PACKAGES for newer upstream versions."
+  (mlet %store-monad ((edges (node-edges %bag-node-type
+                                         ;; Here we don't want the -boot0 
packages.
+                                         (fold-packages cons '()))))
+    (let ((dependent (node-transitive-edges packages edges)))
+      ;; par-for-each has an undefined return value, so packages which cause
+      ;; errors can be ignored.
+      (par-for-each (lambda (package)
+                      (guix-refresh package))
+                    (map package-name dependent)))
+    (return #t)))
+
+(define (list-transitive packages)
+  "List all the packages that would cause PACKAGES to be rebuilt if they are 
changed."
+  ;; Using %BAG-NODE-TYPE is more accurate than using %PACKAGE-NODE-TYPE
+  ;; because it includes implicit dependencies.
+  (define (full-name package)
+    (string-append (package-name package) "@"
+                   (package-version package)))
+
+  (mlet %store-monad ((edges (node-edges %bag-node-type
+                                         ;; Here we don't want the -boot0 
packages.
+                                         (fold-packages cons '()))))
+    (let ((dependent (node-transitive-edges packages edges)))
+      (match packages
+        ((x)
+         (format (current-output-port)
+                 (G_ "~a depends on the following ~d packages: ~{~a~^ ~}~%.")
+                 (full-name x) (length dependent) (map full-name dependent)))
+        (lst
+         (format (current-output-port)
+                 (G_ "The following ~d packages \
+all are dependent packages: ~{~a~^ ~}~%")
+                 (length dependent) (map full-name dependent))))
+      (return #t))))
+
 
 ;;;
 ;;; Manifest.
@@ -402,7 +451,9 @@ update would trigger a complete rebuild."
   (let* ((opts            (parse-options))
          (update?         (assoc-ref opts 'update?))
          (updaters        (options->updaters opts))
+         (recursive?      (assoc-ref opts 'recursive?))
          (list-dependent? (assoc-ref opts 'list-dependent?))
+         (list-transitive? (assoc-ref opts 'list-transitive?))
          (key-download    (assoc-ref opts 'key-download))
 
          ;; Warn about missing updaters when a package is explicitly given on
@@ -441,6 +492,10 @@ update would trigger a complete rebuild."
           (cond
            (list-dependent?
             (list-dependents packages))
+           (list-transitive?
+            (list-transitive packages))
+           (recursive?
+            (refresh-recursive packages))
            (update?
             (parameterize ((%openpgp-key-server
                             (or (assoc-ref opts 'key-server)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]