installer: Fix wifi menu crash with hidden SSIDs.
[jackhill/guix/guix.git] / gnu / installer / newt / partition.scm
index 1c3ce80..cd9d463 100644 (file)
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
 (define (run-scheme-page)
   "Run a page asking the user for a partitioning scheme."
   (let* ((items
-          '((root . "Everything is one partition")
-            (root-home . "Separate /home partition")))
+          `((root . ,(G_ "Everything is one partition"))
+            (root-home . ,(G_ "Separate /home partition"))))
          (result (run-listbox-selection-page
                   #:info-text (G_ "Please select a partitioning scheme.")
                   #:title (G_ "Partition scheme")
                   #:listbox-items items
                   #:listbox-item->text cdr
+                  #:listbox-height 4
+                  #:sort-listbox-items? #f       ;keep the 'root' option first
                   #:button-text (G_ "Exit")
                   #:button-callback-procedure button-exit-action)))
     (car result)))
 
-(define (draw-formating-page)
-  "Draw a page to indicate partitions are being formated."
+(define (draw-formatting-page)
+  "Draw a page asking for confirmation, and then indicating that partitions
+are being formatted."
+  (run-confirmation-page (G_ "We are about to format your hard disk.  All \
+its data will be lost.  Do you wish to continue?")
+                         (G_ "Format disk?")
+                         #:exit-button-procedure button-exit-action)
   (draw-info-page
-   (format #f (G_ "Partition formating is in progress, please wait."))
+   (format #f (G_ "Partition formatting is in progress, please wait."))
    (G_ "Preparing partitions")))
 
 (define (run-device-page devices)
@@ -71,6 +79,7 @@ DEVICES list."
                   #:title (G_ "Disk")
                   #:listbox-items (device-items)
                   #:listbox-item->text cdr
+                  #:listbox-height 10
                   #:button-text (G_ "Exit")
                   #:button-callback-procedure button-exit-action))
          (device (car result)))
@@ -111,7 +120,7 @@ Be careful, all data on the disk will be lost.")
   (run-listbox-selection-page
    #:info-text (G_ "Please select the file-system type for this partition.")
    #:title (G_ "File-system type")
-   #:listbox-items '(ext4 btrfs fat32 swap)
+   #:listbox-items '(ext4 btrfs fat16 fat32 swap)
    #:listbox-item->text user-fs-type-name
    #:sort-listbox-items? #f
    #:button-text (G_ "Exit")
@@ -149,13 +158,15 @@ USER-PARTITIONS list. Return this list with password fields filled-in."
                    (run-input-page
                     (format #f (G_ "Please enter the password for the \
 encryption of partition ~a (label: ~a).") file-name crypt-label)
-                    (G_ "Password required"))))
+                    (G_ "Password required")
+                    #:input-hide-checkbox? #t)))
                 (password-confirm-page
                  (lambda ()
                    (run-input-page
                     (format #f (G_ "Please confirm the password for the \
 encryption of partition ~a (label: ~a).") file-name crypt-label)
-                    (G_ "Password confirmation required")))))
+                    (G_ "Password confirmation required")
+                    #:input-hide-checkbox? #t))))
            (if crypt-label
                (let loop ()
                  (let ((password (password-page))
@@ -288,13 +299,13 @@ by USER-PART, if it is applicable for the partition type."
                         (G_ "Encryption label")))))
             (user-partition
              (inherit target-user-partition)
-             (need-formating? #t)
+             (need-formatting? #t)
              (crypt-label new-label))))
-         ((need-formating?)
+         ((need-formatting?)
           (user-partition
            (inherit target-user-partition)
-           (need-formating?
-            (not (user-partition-need-formating?
+           (need-formatting?
+            (not (user-partition-need-formatting?
                   target-user-partition)))))
          ((size)
           (let* ((old-size (user-partition-size target-user-partition))
@@ -392,7 +403,7 @@ partition. Leave this field empty if you don't want to set a mounting point.")
             (and new-partition
                  (user-partition
                   (inherit new-user-partition)
-                  (need-formating? #t)
+                  (need-formatting? #t)
                   (file-name (partition-get-path new-partition))
                   (disk-file-name (device-path device))
                   (parted-object new-partition))))
@@ -418,10 +429,10 @@ partition. Leave this field empty if you don't want to set a mounting point.")
           (run-listbox-selection-page
            #:info-text
            (if creation?
-               (G_ (format #f "Creating ~a partition starting at ~a of ~a."
-                           type-str start file-name))
-               (G_ (format #f "You are currently editing partition ~a."
-                           number-str)))
+               (format #f (G_ "Creating ~a partition starting at ~a of ~a.")
+                       type-str start file-name)
+               (format #f (G_ "You are currently editing partition ~a.")
+                       number-str))
            #:title (if creation?
                        (G_ "Partition creation")
                        (G_ "Partition edit"))
@@ -662,7 +673,8 @@ by pressing the Exit button.~%~%")))
           #:title (if guided?
                       (G_ "Guided partitioning")
                       (G_ "Manual partitioning"))
-          #:info-textbox-width 70
+          #:info-textbox-width 76         ;we need a lot of room for INFO-TEXT
+          #:listbox-height 12
           #:listbox-items (disk-items)
           #:listbox-item->text cdr
           #:sort-listbox-items? #f
@@ -713,14 +725,16 @@ by pressing the Exit button.~%~%")))
   "Run a page asking the user for a partitioning method."
   (define (run-page devices)
     (let* ((items
-            '((entire . "Guided - using the entire disk")
-              (entire-encrypted . "Guided - using the entire disk with encryption")
-              (manual . "Manual")))
+            `((entire . ,(G_ "Guided - using the entire disk"))
+              (entire-encrypted . ,(G_ "Guided - using the entire disk with encryption"))
+              (manual . ,(G_ "Manual"))))
            (result (run-listbox-selection-page
                     #:info-text (G_ "Please select a partitioning method.")
                     #:title (G_ "Partitioning method")
+                    #:listbox-height (+ (length items) 2)
                     #:listbox-items items
                     #:listbox-item->text cdr
+                    #:sort-listbox-items? #f
                     #:button-text (G_ "Exit")
                     #:button-callback-procedure button-exit-action))
            (method (car result)))
@@ -738,14 +752,11 @@ by pressing the Exit button.~%~%")))
                             (disk-commit disk)
                             disk)))
                 (scheme (symbol-append method '- (run-scheme-page)))
-                (user-partitions (append
-                                  (auto-partition disk #:scheme scheme)
-                                  (create-special-user-partitions
-                                   (disk-partitions disk)))))
+                (user-partitions (auto-partition! disk #:scheme scheme)))
            (run-disk-page (list disk) user-partitions
                           #:guided? #t)))
        ((eq? method 'manual)
-         (let* ((disks (map disk-new devices))
+         (let* ((disks (filter-map disk-new devices))
                 (user-partitions (append-map
                                   create-special-user-partitions
                                   (map disk-partitions disks)))
@@ -758,8 +769,8 @@ by pressing the Exit button.~%~%")))
          (user-partitions (run-page non-install-devices))
          (user-partitions-with-pass (prompt-luks-passwords
                                      user-partitions))
-         (form (draw-formating-page)))
-    ;; Make sure the disks are not in use before proceeding to formating.
+         (form (draw-formatting-page)))
+    ;; Make sure the disks are not in use before proceeding to formatting.
     (free-parted non-install-devices)
     (format-user-partitions user-partitions-with-pass)
     (destroy-form-and-pop form)