diff mbox series

[bug#48243] weather: '--display-missing' shows the system type of missing items.

Message ID 20210505195819.10924-1-ludo@gnu.org
State Accepted
Headers show
Series [bug#48243] weather: '--display-missing' shows the system type of missing items. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Ludovic Courtès May 5, 2021, 7:58 p.m. UTC
* guix/scripts/weather.scm (store-item-system): New procedure.
(report-server-coverage): Use it to print the system type of each
missing item.
---
 guix/scripts/weather.scm | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

Hi!

The result of this change is an extra column, when using
‘--display-missing’, that shows the system type of missing items:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env  guix weather --display-missing guix libreoffice inkscape linux-libre -s armhf-linux -s powerpc64le-linux -s x86_64-linux -s aarch64-linux

[...]

Substitutes are missing for the following items:
  /gnu/store/n317afb5f14h7hkxz7ycscd6mhda9plm-libreoffice-6.4.7.2                aarch64-linux
  /gnu/store/xwx5qsalgp3v7vyn6hpvsdy2j59b1973-inkscape-1.0.2                     aarch64-linux
  /gnu/store/8zvik3qkh24jrp1dxqmqg17cw002xs90-linux-libre-5.11.18                aarch64-linux
  /gnu/store/463m6ikbvi071jq5m8cj4gpgcgd0lw6a-guix-1.2.0-21.4dff6ec              powerpc64le-linux
  /gnu/store/lblmg73hbrf051zmzicdp8pfzc47knnx-libreoffice-6.4.7.2                powerpc64le-linux
  /gnu/store/rbf85wfw1v59035l8jz1rcxf72ajbhsp-inkscape-1.0.2                     powerpc64le-linux
  /gnu/store/mxjlc83k40xgjq5qilvp65v82794p1jd-guix-1.2.0-21.4dff6ec              armhf-linux
  /gnu/store/d2ap2kdv1rm39awc4lz5psrsq7l3mklc-libreoffice-6.4.7.2                armhf-linux
  /gnu/store/mvdwc2zyg5brkxfp7cazba8bxn9fp4wk-inkscape-1.0.2                     armhf-linux
  /gnu/store/d5ximwvsizr4my1ib4i4mnwk0hdzmn00-linux-libre-5.11.18                armhf-linux
--8<---------------cut here---------------end--------------->8---

I find the extra info to be very useful, in particular when looking
at the weather of ‘etc/release-manifest.scm’, which targets all the
supported architectures.

Thoughts?

Ludo’.

Comments

Ludovic Courtès May 8, 2021, 1:09 p.m. UTC | #1
Ludovic Courtès <ludo@gnu.org> skribis:

> * guix/scripts/weather.scm (store-item-system): New procedure.
> (report-server-coverage): Use it to print the system type of each
> missing item.

Pushed as 5b0afe2420fcc9542328da4347f9e79490625d99.
diff mbox series

Patch

diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm
index 5164fe0494..6d925d416c 100644
--- a/guix/scripts/weather.scm
+++ b/guix/scripts/weather.scm
@@ -1,5 +1,5 @@ 
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2018 Kyle Meyer <kyle@kyleam.com>
 ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
@@ -171,6 +171,16 @@  about the derivations queued, as is the case with Hydra."
       #f                                          ;no derivation information
       (lset-intersection string=? queued items)))
 
+(define (store-item-system store item)
+  "Return the system (a string such as \"aarch64-linux\")) ITEM targets,
+or #f if it could not be determined."
+  (match (valid-derivers store item)
+    ((drv . _)
+     (and=> (false-if-exception (read-derivation-from-file drv))
+            derivation-system))
+    (()
+     #f)))
+
 (define* (report-server-coverage server items
                                  #:key display-missing?)
   "Report the subset of ITEMS available as substitutes on SERVER.
@@ -270,7 +280,22 @@  are queued~%")
       (when (and display-missing? (not (null? missing)))
         (newline)
         (format #t (G_ "Substitutes are missing for the following items:~%"))
-        (format #t "~{  ~a~%~}" missing))
+
+        ;; Display two columns: store items, and their system type.
+        (format #t "~:{  ~a ~a~%~}"
+                (zip (map (let ((width (max (- (current-terminal-columns)
+                                               20)
+                                            0)))
+                            (lambda (item)
+                              (if (> (string-length item) width)
+                                  item
+                                  (string-pad-right item width))))
+                          missing)
+                     (with-store store
+                       (map (lambda (item)
+                              (or (store-item-system store item)
+                                  (G_ "unknown system")))
+                            missing)))))
 
       ;; Return the coverage ratio.
       (let ((total (length items)))