all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mathieu Othacehe <othacehe@gnu.org>
To: Josselin Poiret <dev@jpoiret.xyz>
Cc: Florian Hoertlehner <hoertlehner@gmail.com>, 52680@debbugs.gnu.org
Subject: bug#52680: installer error
Date: Mon, 27 Dec 2021 19:18:15 +0100	[thread overview]
Message-ID: <871r1xewt4.fsf@gnu.org> (raw)
In-Reply-To: <87a6gm10cp.fsf@jpoiret.xyz> (Josselin Poiret's message of "Mon,  27 Dec 2021 17:25:26 +0100")

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]


Hey,

>> 1. We should hide vdb as it is an empty drive, maybe by requiring a
>> minimal available space. Josselin, what do you think about it?
>
> Looks good to me.

Here's an attached patch. It seems to work fine, but I am still running
the system tests.

WDYT?

Thanks,

Mathieu

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-installer-Ignore-small-devices.patch --]
[-- Type: text/x-patch, Size: 5066 bytes --]

From d7cc04a71b477d8527b901a66704b28b4e618e04 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe@gnu.org>
Date: Mon, 27 Dec 2021 19:12:54 +0100
Subject: [PATCH 1/1] installer: Ignore small devices.

Filter the devices that are smaller than 10GiB in the device selection list.

* gnu/installer/parted.scm (%min-device-size): New variable.
(non-install-devices): Rename it ...
(eligible-devices): ... this way. Filter the install device as well as the
small devices.
* gnu/installer/newt/partition.scm (run-partitioning-page): Adapt it.
---
 gnu/installer/newt/partition.scm |  9 +++---
 gnu/installer/parted.scm         | 47 +++++++++++++++++++++++---------
 2 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/gnu/installer/newt/partition.scm b/gnu/installer/newt/partition.scm
index 70c11ed8ad..ccc7686906 100644
--- a/gnu/installer/newt/partition.scm
+++ b/gnu/installer/newt/partition.scm
@@ -83,7 +83,8 @@ (define (device-items)
          devices))
 
   (let* ((result (run-listbox-selection-page
-                  #:info-text (G_ "Please select a disk.")
+                  #:info-text (G_ "Please select a \
+disk.  The installation device as well as the small devices are filtered.")
                   #:title (G_ "Disk")
                   #:listbox-items (device-items)
                   #:listbox-item->text cdr
@@ -792,13 +793,13 @@ (define (run-page devices)
            result-user-partitions)))))
 
   (init-parted)
-  (let* ((non-install-devices (non-install-devices))
-         (user-partitions (run-page non-install-devices))
+  (let* ((eligible-devices (eligible-devices))
+         (user-partitions (run-page eligible-devices))
          (user-partitions-with-pass (prompt-luks-passwords
                                      user-partitions))
          (form (draw-formatting-page user-partitions)))
     ;; Make sure the disks are not in use before proceeding to formatting.
-    (free-parted non-install-devices)
+    (free-parted eligible-devices)
     (format-user-partitions user-partitions-with-pass)
     (syslog "formatted ~a user partitions~%"
             (length user-partitions-with-pass))
diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm
index 289cd660fd..77902599d6 100644
--- a/gnu/installer/parted.scm
+++ b/gnu/installer/parted.scm
@@ -81,7 +81,7 @@ (define-module (gnu installer parted)
 
             with-delay-device-in-use?
             force-device-sync
-            non-install-devices
+            eligible-devices
             partition-user-type
             user-fs-type-name
             partition-filesystem-user-type
@@ -356,28 +356,49 @@ (define (installer-root-partition-path)
              (and=> (uuid root)
                     find-partition-by-uuid)))))
 
-(define (non-install-devices)
-  "Return all the available devices, except the install device."
+;; Minimal installation device size.
+(define %min-device-size
+  (* 10 GIBIBYTE-SIZE)) ;10GiB
+
+(define (eligible-devices)
+  "Return all the available device except the install device and the devices
+with are smaller than %MIN-DEVICE-SIZE."
 
   (define the-installer-root-partition-path
     (installer-root-partition-path))
 
+  (define (small-device? device)
+    (let ((length (device-length device))
+          (sector-size (device-sector-size device)))
+      (and (< (* length sector-size) %min-device-size)
+           (syslog "~a is not eligible because it is smaller than ~a.~%"
+                   (device-path device)
+                   (unit-format-custom-byte device
+                                            %min-device-size
+                                            UNIT-GIGABYTE)))))
+
   ;; Read partition table of device and compare each path to the one
   ;; we're booting from to determine if it is the installation
   ;; device.
   (define (installation-device? device)
     ;; When using CDROM based installation, the root partition path may be the
     ;; device path.
-    (or (string=? the-installer-root-partition-path
-                  (device-path device))
-        (let ((disk (disk-new device)))
-          (and disk
-               (any (lambda (partition)
-                      (string=? the-installer-root-partition-path
-                                (partition-get-path partition)))
-                    (disk-partitions disk))))))
-
-  (remove installation-device? (devices)))
+    (and (or (string=? the-installer-root-partition-path
+                       (device-path device))
+             (let ((disk (disk-new device)))
+               (and disk
+                    (any (lambda (partition)
+                           (string=? the-installer-root-partition-path
+                                     (partition-get-path partition)))
+                         (disk-partitions disk)))))
+         (syslog "~a is not eligible because it is the installation device.~%"
+                 (device-path device))))
+
+  (remove
+   (lambda (device)
+     (or (installation-device? device)
+         (small-device? device)))
+   (devices)))
 
 \f
 ;;
-- 
2.34.0


  reply	other threads:[~2021-12-27 18:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20 13:22 bug#52680: installer error Florian Hoertlehner
2021-12-27  8:23 ` Mathieu Othacehe
2021-12-27 12:45   ` Mathieu Othacehe
2021-12-27 16:25     ` Josselin Poiret via Bug reports for GNU Guix
2021-12-27 18:18       ` Mathieu Othacehe [this message]
2022-02-02 16:37         ` Mathieu Othacehe

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=871r1xewt4.fsf@gnu.org \
    --to=othacehe@gnu.org \
    --cc=52680@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=hoertlehner@gmail.com \
    /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.