summary refs log tree commit diff
path: root/gnu/installer
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/installer')
-rw-r--r--gnu/installer/final.scm61
-rw-r--r--gnu/installer/newt/network.scm21
-rw-r--r--gnu/installer/newt/partition.scm9
-rw-r--r--gnu/installer/parted.scm47
-rw-r--r--gnu/installer/utils.scm18
5 files changed, 89 insertions, 67 deletions
diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm
index fc0b7803fa..276af908f7 100644
--- a/gnu/installer/final.scm
+++ b/gnu/installer/final.scm
@@ -105,36 +105,6 @@ USERS."
   (write-passwd password (string-append etc "/passwd"))
   (write-shadow shadow (string-append etc "/shadow")))
 
-(define* (kill-cow-users cow-path #:key (spare '("udevd")))
-  "Kill all processes that have references to the given COW-PATH in their
-'maps' file.  The process whose names are in SPARE list are spared."
-  (define %not-nul
-    (char-set-complement (char-set #\nul)))
-
-  (let ((pids
-         (filter-map (lambda (pid)
-                       (false-if-exception
-                        (call-with-input-file
-                            (string-append "/proc/" pid "/maps")
-                          (lambda (port)
-                            (and (string-contains (get-string-all port)
-                                                  cow-path)
-                                 (string->number pid))))))
-                     (scandir "/proc" string->number))))
-    (for-each (lambda (pid)
-                ;; cmdline does not always exist.
-                (false-if-exception
-                 (call-with-input-file
-                     (string-append "/proc/" (number->string pid) "/cmdline")
-                   (lambda (port)
-                     (match (string-tokenize (read-string port) %not-nul)
-                       ((argv0 _ ...)
-                        (unless (member (basename argv0) spare)
-                          (syslog "Killing process ~a (~a)~%" pid argv0)
-                          (kill pid SIGKILL)))
-                       (_ #f))))))
-              pids)))
-
 (define (call-with-mnt-container thunk)
   "This is a variant of call-with-container. Run THUNK in a new container
 process, within a separate MNT namespace. The container is not jailed so that
@@ -149,6 +119,28 @@ it can interact with the rest of the system."
     (match (waitpid pid)
       ((_ . status) status))))
 
+(define (install-locale locale)
+  "Install the given LOCALE or the en_US.utf8 locale as a fallback."
+  (let ((supported? (false-if-exception
+                     (setlocale LC_ALL locale))))
+    (if supported?
+        (begin
+          (syslog "install supported locale ~a~%." locale)
+          (setenv "LC_ALL" locale))
+        (begin
+          ;; If the selected locale is not supported, install a default UTF-8
+          ;; locale. This is required to copy some files with UTF-8
+          ;; characters, in the nss-certs package notably. Set LANGUAGE
+          ;; anyways, to have translated messages if possible.
+          (syslog "~a locale is not supported, installating en_US.utf8 \
+locale instead.~%" locale)
+          (setlocale LC_ALL "en_US.utf8")
+          (setenv "LC_ALL" "en_US.utf8")
+          (setenv "LANGUAGE"
+                  (string-take locale
+                               (or (string-index locale #\_)
+                                   (string-length locale))))))))
+
 (define* (install-system locale #:key (users '()))
   "Create /etc/shadow and /etc/passwd on the installation target for USERS.
 Start COW-STORE service on target directory and launch guix install command in
@@ -199,6 +191,10 @@ or #f.  Return #t on success and #f on failure."
        (lambda ()
          (dynamic-wind
            (lambda ()
+             ;; Install the locale before mounting the cow-store, otherwise
+             ;; the loaded cow-store locale files will prevent umounting.
+             (install-locale locale)
+
              ;; Save the database, so that it can be restored once the
              ;; cow-store is umounted.
              (copy-file database-file saved-database)
@@ -221,9 +217,8 @@ or #f.  Return #t on success and #f on failure."
                          (lambda ()
                            (with-error-to-file "/dev/console"
                              (lambda ()
-                               (run-command install-command
-                                            #:locale locale)))))
-                       (run-command install-command #:locale locale))))
+                               (run-command install-command)))))
+                       (run-command install-command))))
            (lambda ()
              ;; Restart guix-daemon so that it does no keep the MNT namespace
              ;; alive.
diff --git a/gnu/installer/newt/network.scm b/gnu/installer/newt/network.scm
index 4af7143d63..fb221483c3 100644
--- a/gnu/installer/newt/network.scm
+++ b/gnu/installer/newt/network.scm
@@ -30,6 +30,8 @@
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
   #:use-module (ice-9 match)
+  #:use-module (web client)
+  #:use-module (web response)
   #:use-module (newt)
   #:export (run-network-page))
 
@@ -119,8 +121,23 @@ network devices were found. Do you want to continue anyway?"))
 (define (wait-service-online)
   "Display a newt scale until connman detects an Internet access. Do
 FULL-VALUE tentatives, spaced by 1 second."
+  (define (ci-available?)
+    (dynamic-wind
+      (lambda ()
+        (sigaction SIGALRM
+          (lambda _ #f))
+        (alarm 3))
+      (lambda ()
+        (false-if-exception
+         (= (response-code
+             (http-request "https://ci.guix.gnu.org"))
+            200)))
+      (lambda ()
+        (alarm 0))))
+
   (define (online?)
-    (or (connman-online?)
+    (or (and (connman-online?)
+             (ci-available?))
         (file-exists? "/tmp/installer-assume-online")))
 
   (let* ((full-value 5))
@@ -137,7 +154,7 @@ FULL-VALUE tentatives, spaced by 1 second."
     (unless (online?)
       (run-error-page
        (G_ "The selected network does not provide access to the \
-Internet, please try again.")
+Internet and the Guix substitute server, please try again.")
        (G_ "Connection error"))
       (raise
        (condition
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 @@ DEVICES list."
          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 @@ by pressing the Exit button.~%~%")))
            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..66e07574c9 100644
--- a/gnu/installer/parted.scm
+++ b/gnu/installer/parted.scm
@@ -81,7 +81,7 @@
 
             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 @@ fail. See rereadpt function in wipefs.c of util-linux for an explanation."
              (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
+  (* 2 GIBIBYTE-SIZE)) ;2GiB
+
+(define (eligible-devices)
+  "Return all the available devices except the install device and the devices
+which 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)))
 
 
 ;;
diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm
index bb97bc5560..9bd41e2ca0 100644
--- a/gnu/installer/utils.scm
+++ b/gnu/installer/utils.scm
@@ -74,9 +74,9 @@ number. If no percentage is found, return #f"
     (and result
          (string->number (match:substring result 1)))))
 
-(define* (run-command command #:key locale)
-  "Run COMMAND, a list of strings, in the given LOCALE.  Return true if
-COMMAND exited successfully, #f otherwise."
+(define* (run-command command)
+  "Run COMMAND, a list of strings.  Return true if COMMAND exited
+successfully, #f otherwise."
   (define env (environ))
 
   (define (pause)
@@ -90,18 +90,6 @@ COMMAND exited successfully, #f otherwise."
 
   (setenv "PATH" "/run/current-system/profile/bin")
 
-  (when locale
-    (let ((supported? (false-if-exception
-                       (setlocale LC_ALL locale))))
-      ;; If LOCALE is not supported, then set LANGUAGE, which might at
-      ;; least give us translated messages.
-      (if supported?
-          (setenv "LC_ALL" locale)
-          (setenv "LANGUAGE"
-                  (string-take locale
-                               (or (string-index locale #\_)
-                                   (string-length locale)))))))
-
   (guard (c ((invoke-error? c)
              (newline)
              (format (current-error-port)