all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 59003@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#59003] [PATCH 6/7] installer: Report known-unsupported PCI devices.
Date: Thu,  3 Nov 2022 20:19:34 +0100	[thread overview]
Message-ID: <20221103191935.16336-6-ludo@gnu.org> (raw)
In-Reply-To: <20221103191935.16336-1-ludo@gnu.org>

* gnu/installer.scm (installer-steps): Pass #:pci-database to the
'welcome' step procedure.
* gnu/installer/newt.scm (welcome-page): Add #:pci-database and pass it
to 'run-welcome-page'.
* gnu/installer/newt/welcome.scm (%unsupported-linux-modules): New
variable.
(unsupported-pci-device?, pci-device-description): New procedures.
(check-hardware-support): Add #:pci-database.  Enumerate unsupported PCI
devices and run an error page when unsupported devices are found.
(run-welcome-page): Add #:pci-database and pass it to
'check-hardware-support'.
* gnu/installer/record.scm (<installer>)[welcome-page]: Adjust comment.
---
 gnu/installer.scm              |  6 ++-
 gnu/installer/newt.scm         |  4 +-
 gnu/installer/newt/welcome.scm | 78 +++++++++++++++++++++++++++++++---
 gnu/installer/record.scm       |  2 +-
 4 files changed, 80 insertions(+), 10 deletions(-)

diff --git a/gnu/installer.scm b/gnu/installer.scm
index df7625e05c..e1b040088b 100644
--- a/gnu/installer.scm
+++ b/gnu/installer.scm
@@ -46,6 +46,7 @@ (define-module (gnu installer)
   #:use-module (gnu packages nano)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages package-management)
+  #:use-module (gnu packages pciutils)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages xorg)
   #:use-module (gnu system locale)
@@ -226,7 +227,9 @@ (define (installer-steps)
           (id 'welcome)
           (compute (lambda _
                      ((installer-welcome-page current-installer)
-                      #$(local-file "installer/aux-files/logo.txt")))))
+                      #$(local-file "installer/aux-files/logo.txt")
+                      #:pci-database
+                      #$(file-append pciutils "/share/hwdata/pci.ids.gz")))))
 
          ;; Ask the user to select a timezone under glibc format.
          (installer-step
@@ -358,6 +361,7 @@ (define installer-builder
     (with-extensions (list guile-gcrypt guile-newt
                            guile-parted guile-bytestructures
                            guile-json-3 guile-git guile-webutils
+                           guile-zlib           ;for (gnu build linux-modules)
                            (current-guix) gnutls)
       (with-imported-modules `(,@(source-module-closure
                                   `(,@modules
diff --git a/gnu/installer/newt.scm b/gnu/installer/newt.scm
index 0bd0856219..60f9e75b81 100644
--- a/gnu/installer/newt.scm
+++ b/gnu/installer/newt.scm
@@ -176,8 +176,8 @@ (define* (locale-page #:key
 (define (timezone-page zonetab)
   (run-timezone-page zonetab))
 
-(define (welcome-page logo)
-  (run-welcome-page logo))
+(define* (welcome-page logo #:key pci-database)
+  (run-welcome-page logo #:pci-database pci-database))
 
 (define (menu-page steps)
   (run-menu-page steps))
diff --git a/gnu/installer/newt/welcome.scm b/gnu/installer/newt/welcome.scm
index 1c7372b3be..e9a4e0bbb4 100644
--- a/gnu/installer/newt/welcome.scm
+++ b/gnu/installer/newt/welcome.scm
@@ -19,7 +19,15 @@
 
 (define-module (gnu installer newt welcome)
   #:use-module ((gnu build linux-modules)
-                #:select (modules-loaded))
+                #:select (modules-loaded
+                          known-module-aliases
+                          matching-modules
+                          pci-devices
+                          pci-device-id
+                          pci-device-vendor
+                          pci-device-module-alias
+                          network-pci-device?
+                          load-pci-device-database))
   #:use-module (gnu installer dump)
   #:use-module (gnu installer steps)
   #:use-module (gnu installer utils)
@@ -30,6 +38,8 @@ (define-module (gnu installer newt welcome)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-71)
+  #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:use-module (ice-9 receive)
   #:use-module (newt)
@@ -121,7 +131,43 @@ (define (choice->item str)
         (lambda ()
           (destroy-form-and-pop form))))))
 
-(define (check-hardware-support)
+(define %unsupported-linux-modules
+  ;; List of Linux modules that are useless without non-free firmware.
+  '("iwlwifi"))
+
+(define unsupported-pci-device?
+  ;; Arrange to load the module alias database only once.
+  (let ((aliases (delay (known-module-aliases))))
+    (lambda (device)
+      "Return true if DEVICE is known to not be supported by free software."
+      (any (lambda (module)
+             (member module %unsupported-linux-modules))
+           (matching-modules (pci-device-module-alias device)
+                             (force aliases))))))
+
+(define (pci-device-description pci-database)
+  "Return a procedure that, given a PCI device, returns a string describing
+it."
+  (define (with-fallback lookup)
+    (lambda (vendor-id id)
+      (let ((vendor name (lookup vendor-id id)))
+        (values (or vendor (number->string vendor-id 16))
+                (or name (number->string id 16))))))
+
+  (define pci-lookup
+    (with-fallback (load-pci-device-database pci-database)))
+
+  (lambda (device)
+    (let ((vendor name (pci-lookup (pci-device-vendor device)
+                                   (pci-device-id device))))
+      (if (network-pci-device? device)
+          ;; TRANSLATORS: The two placeholders are the manufacturer
+          ;; and name of a PCI device.
+          (format #f (G_ "~a ~a (networking device)")
+                  vendor name)
+          (string-append vendor " " name)))))
+
+(define (check-hardware-support pci-database)
   "Warn about unsupported devices."
   (when (member "uvesafb" (modules-loaded))
     (run-error-page (G_ "\
@@ -129,9 +175,28 @@ (define (check-hardware-support)
 work well with only free software.  Expect trouble.  If after installation,
 the system does not boot, perhaps you will need to add nomodeset to the
 kernel arguments and need to configure the uvesafb kernel module.")
-                    (G_ "Pre-install warning"))))
+                    (G_ "Pre-install warning")))
 
-(define (run-welcome-page logo)
+  (let ((devices (pci-devices)))
+    (match (filter unsupported-pci-device? devices)
+      (()                                         ;no unsupported device
+       #t)
+      (unsupported
+       (run-error-page (format #f (G_ "\
+Devices not supported by free software were found on your computer:
+
+~{  - ~a~%~}
+Unfortunately, it means those devices will not be usable.
+
+To address it, we recommend choosing hardware that respects your freedom as a \
+user--hardware for which free drivers and firmware exist.  See \"Hardware \
+Considerations\" in the manual for more information.")
+                               (map (pci-device-description pci-database)
+                                    unsupported))
+                       (G_ "Hardware support warning")
+                       #:width 76)))))
+
+(define* (run-welcome-page logo #:key pci-database)
   "Run a welcome page with the given textual LOGO displayed at the center of
 the page. Ask the user to choose between manual installation, graphical
 installation and reboot."
@@ -161,11 +226,12 @@ (define (run-welcome-page logo)
    #:listbox-items
    `((,(G_ "Graphical install using a terminal based interface")
       .
-      ,check-hardware-support)
+      ,(lambda ()
+         (check-hardware-support pci-database)))
      (,(G_ "Install using the shell based process")
       .
       ,(lambda ()
-         (check-hardware-support)
+         (check-hardware-support pci-database)
          ;; Switch to TTY3, where a root shell is available for shell based
          ;; install. The other root TTY's would have been ok too.
          (system* "chvt" "3")
diff --git a/gnu/installer/record.scm b/gnu/installer/record.scm
index 20519a26c3..5e0264682f 100644
--- a/gnu/installer/record.scm
+++ b/gnu/installer/record.scm
@@ -89,7 +89,7 @@ (define-record-type* <installer>
   (partition-page installer-partition-page)
   ;; procedure void -> void
   (services-page installer-services-page)
-  ;; procedure (logo) -> void
+  ;; procedure (logo #:pci-database) -> void
   (welcome-page installer-welcome-page)
   ;; procedure (menu-proc) -> void
   (parameters-menu installer-parameters-menu)
-- 
2.38.0





  parent reply	other threads:[~2022-11-03 19:21 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 19:17 [bug#59003] [PATCH 0/7] [Installer] Warn about unsupported devices Ludovic Courtès
2022-11-03 19:19 ` [bug#59003] [PATCH 1/7] installer: Warn about hardware support after the welcome page Ludovic Courtès
2022-11-03 19:19   ` [bug#59003] [PATCH 2/7] linux-modules: Add support for listing PCI devices Ludovic Courtès
2022-11-05 15:21     ` pelzflorian (Florian Pelz)
2022-11-03 19:19   ` [bug#59003] [PATCH 3/7] linux-modules: Add 'load-pci-device-database' Ludovic Courtès
2022-11-03 19:19   ` [bug#59003] [PATCH 4/7] installer: Use 'current-guix' for extensions Ludovic Courtès
2022-11-05  9:09     ` pelzflorian (Florian Pelz)
2022-11-05 17:34       ` Ludovic Courtès
2022-11-03 19:19   ` [bug#59003] [PATCH 5/7] installer: Error page width is parameterized Ludovic Courtès
2022-11-03 19:19   ` Ludovic Courtès [this message]
2022-11-05 17:55     ` [bug#59003] [PATCH 6/7] installer: Report known-unsupported PCI devices pelzflorian (Florian Pelz)
2022-11-06 11:20       ` Ludovic Courtès
2022-11-06 19:06         ` pelzflorian (Florian Pelz)
2022-11-05 20:51     ` [bug#59003] [PATCH 0/7] [Installer] Warn about unsupported devices Mathieu Othacehe
2022-11-05 21:11       ` Mathieu Othacehe
2022-11-09 20:26         ` Ludovic Courtès
2022-11-03 19:19   ` [bug#59003] [PATCH 7/7] installer: Remove unused variable Ludovic Courtès
2022-11-05  8:52   ` [bug#59003] [PATCH 1/7] installer: Warn about hardware support after the welcome page pelzflorian (Florian Pelz)
2022-11-05 18:02     ` pelzflorian (Florian Pelz)
2022-11-09 21:56 ` [bug#59003] [PATCH v2 0/6] [Installer] Warn about unsupported devices Ludovic Courtès
2022-11-09 21:56   ` [bug#59003] [PATCH v2 1/6] installer: Warn about hardware support after the welcome page Ludovic Courtès
2022-11-09 21:56   ` [bug#59003] [PATCH v2 2/6] linux-modules: Add support for listing PCI devices Ludovic Courtès
2022-11-09 21:56   ` [bug#59003] [PATCH v2 3/6] linux-modules: Add 'load-pci-device-database' Ludovic Courtès
2022-11-09 21:56   ` [bug#59003] [PATCH v2 4/6] installer: Use 'current-guix' for extensions Ludovic Courtès
2022-11-09 21:56   ` [bug#59003] [PATCH v2 5/6] installer: Error page width is parameterized Ludovic Courtès
2022-11-09 21:56   ` [bug#59003] [PATCH v2 6/6] installer: Report known-unsupported PCI devices Ludovic Courtès
2022-11-11 11:08     ` pelzflorian (Florian Pelz)
2022-11-15 11:24       ` bug#59003: [PATCH 0/7] [Installer] Warn about unsupported devices Ludovic Courtès
2022-11-15 18:28         ` [bug#59003] " pelzflorian (Florian Pelz)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221103191935.16336-6-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=59003@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.