aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu installer newt final)
  #:use-module (gnu installer final)
  #:use-module (gnu installer parted)
  #:use-module (gnu installer steps)
  #:use-module (gnu installer utils)
  #:use-module (gnu installer newt page)
  #:use-module (gnu installer newt utils)
  #:use-module (guix i18n)
  #:use-module (guix colors)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-35)
  #:use-module (ice-9 match)
  #:use-module ((ice-9 rdelim) #:select (read-line))
  #:use-module (newt)
  #:export (run-final-page))

(define* (strip-prefix file #:optional (prefix (%installer-target-dir)))
  "Strip PREFIX from FILE, if PREFIX actually is a prefix of FILE."
  (if (string-prefix? prefix file)
      (string-drop file (string-length prefix))
      file))

(define* (run-config-display-page #:key locale)
  (let ((width (max 70 (- (screen-columns) 20)))
        (height (default-listbox-height)))
    (run-file-textbox-page
     #:info-text (format #f (G_ "\
We're now ready to proceed with the installation! \
A system configuration file has been generated, it is displayed below.  \
This file will be available as '~a' on the installed system.  \
The new system will be created from this file once you've pressed OK.  \
This will take a few minutes.")
                         (strip-prefix (%installer-configuration-file)))
     #:title (G_ "Configuration file")
     #:file (%installer-configuration-file)
     #:edit-button? #t
     #:editor-locale locale
     #:info-textbox-width width
     #:file-textbox-width width
     #:file-textbox-height height
     #:exit-button-callback-procedure
     (lambda ()
       (abort-to-prompt 'installer-step 'abort)))))

(define (run-install-success-page)
  (match (current-clients)
    (()
     (message-window
      (G_ "Installation complete")
      (G_ "Reboot")
      (G_ "Congratulations!  Installation is now complete.  \
You may remove the device containing the installation image and \
press the button to reboot.")))
    (_
     ;; When there are clients connected, send them a message and keep going.
     (send-to-clients '(installation-complete))))

  ;; Return success so that the installer happily reboots.
  'success)

(define (run-install-failed-page)
  (match (current-clients)
    (()
     (match (ternary-window
             (G_ "Installation failed")
             (G_ "Resume")
             (G_ "Restart the installer")
             (G_ "Report the failure")
             (G_ "The final system installation step failed.  You can resume from \
a specific step, or restart the installer."))
       (1 (abort-to-prompt 'installer-step 'abort))
       (2
        ;; Keep going, the installer will be restarted later on.
        #t)
       (3 (raise
            (condition
             (&user-abort-error))))))
    (_
     (send-to-clients '(installation-failure))
     #t)))

(define* (run-install-shell locale
                            #:key (users '()))
  (clear-screen)
  (newt-suspend)
  (let ((install-ok? (install-system locale #:users users)))
    (newt-resume)
    install-ok?))

(define (run-final-page-install result prev-steps)
  (define (wait-for-clients)
    (unless (null? (current-clients))
      (installer-log-line "waiting with clients before starting final step")
      (send-to-clients '(starting-final-step))
      (match (select (current-clients) '() '())
        (((port _ ...) _ _)
         (read-line port)))))

  ;; Before generating the configuration file, give clients a chance to do
  ;; things such as changing the swap partition label.
  (wait-for-clients)

  (installer-log-line "proceeding with final step")
  (let* ((configuration   (format-configuration prev-steps result))
         (user-partitions (result-step result 'partition))
         (locale          (result-step result 'locale))
         (users           (result-step result 'user))
         (install-ok?
          (with-mounted-partitions
           user-partitions
           (configuration->file configuration)
           (run-config-display-page #:locale locale)
           (run-install-shell locale #:users users))))
    (if install-ok?
        (run-install-success-page)
        (run-install-failed-page))))

(define (dry-run-final-page result prev-steps)
  (installer-log-line "proceeding with final step -- dry-run")
  (let* ((configuration   (format-configuration prev-steps result))
         (user-partitions (result-step result 'partition))
         (locale          (result-step result 'locale))
         (users           (result-step result 'user))
         (file            (configuration->file configuration))
         (install-ok?     (run-config-display-page #:locale locale)))
    (if install-ok?
        (run-install-success-page)
        (run-install-failed-page))))

(define (run-final-page result prev-steps dry-run?)
  (if dry-run?
      (dry-run-final-page result prev-steps)
      (run-final-page-install result prev-steps)))
span class='msg-avail'>...Previously 'system-image' would return *unspecified* in that case, leading to a wrong-type-arg error crash down the road. * gnu/system/image.scm (system-image): Add 'else' clause. Ludovic Courtès 2022-06-24image: Add support for 32bit UEFI....* gnu/bootloader/grub.scm (grub-efi32-bootloader): New variable. (install-grub-efi32): New variable. * gnu/build/bootloader.scm (install-efi): Add a 'targets' keyword argument. (install-efi-loader): Likewise. * gnu/build/image.scm (initialize-efi32-partition): New procedure. * gnu/packages/bootloaders.scm (grub-efi32): New variable. * gnu/system/image.scm (esp32-partition): New variable (efi32-disk-image): New variable. (efi32-raw-image-type): New variable. (system-disk-image)[partition-image]: Set '#:grub-efi32' when calling the partition initializer. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Denis 'GNUtoo' Carikli 2022-06-07gnu: install: Add uvesafb service only on targets that support v86d....Fixes <https://issues.guix.gnu.org/55806>. * gnu/system/install.scm (%installation-services): Refactor into a procedure, so that it can capture the system it's installing for. Conditionally add uvesafb-service-type based on whether v86d is supported by the target architecture. (installation-os)[services]: Use the %installation-service procedure. (uvesafb-shepherd-service): Remove %host-type checks. Signed-off-by: Florian Pelz <pelzflorian@pelzflorian.de> Josselin Poiret 2022-05-31gnu: Remove wicd....The last release is from 2017, stuck on Python 2. * gnu/packages/wicd.scm: Delete file. * gnu/packages/patches/wicd-bitrate-none-fix.patch: Delete file. * gnu/packages/patches/wicd-get-selected-profile-fix.patch: Likewise. * gnu/packages/patches/wicd-urwid-1.3.patch: Likewise. * gnu/packages/patches/wicd-wpa2-ttls.patch: Likewise. * gnu/local.mk: De-register them. * gnu/services/networking.scm: Remove wicd service... * doc/guix.texi: ... and its documentation. * gnu/system/linux-container.scm (containerized-operating-system) <services-to-drop>: Remove wicd-service-type. Maxim Cournoyer 2022-05-31image: Add fat32 support....* gnu/build/image.scm (make-vfat-image): Pass fs-bits as an argument and force 1kb logical sector size only if "ESP" flag is set. (make-partition-image): Add "fat32" partition type, support explicit "fat16" type with vfat alias. * gnu/system/image.scm (partition->dos-type partition): Return file system IDs for "fat16" and "fat32" partitions. (partition->gpt-type partition): Ditto. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Pavel Shlyak 2022-05-25images: hurd: Adjust module imports....Follow-up to a9dcd60bc11afb3934c11fbad159a16f0f223fd1. * gnu/system/images/hurd.scm: Adjust module imports to changes in code structure. Efraim Flashner 2022-05-25Move (gnu platform) and (gnu platforms ...) to guix/....* gnu/platform.scm: * gnu/platforms/arm.scm: * gnu/platforms/hurd.scm: * gnu/platforms/mips.scm: * gnu/platforms/powerpc.scm: * gnu/platforms/riscv.scm: * gnu/platforms/s390.scm: * gnu/platforms/x86.scm: Move to guix/. * Makefile.am: * doc/guix.texi (Porting to a New Platform): * etc/release-manifest.scm: * gnu/ci.scm: * gnu/image.scm: * gnu/local.mk: * gnu/packages/bioinformatics.scm: * gnu/packages/bootstrap.scm: * gnu/packages/cross-base.scm: * gnu/packages/instrumentation.scm: * gnu/packages/linux.scm: * gnu/system/image.scm: * gnu/system/images/hurd.scm: * gnu/system/images/novena.scm: * gnu/system/images/pine64.scm: * gnu/system/images/pinebook-pro.scm: * gnu/system/images/rock64.scm: * guix/scripts/build.scm: * guix/scripts/system.scm: * guix/self.scm: Update (gnu platform...) to (guix platform...). Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Josselin Poiret 2022-05-23image: Add bootable flag support....* gnu/build/image.scm (sexp->partition): Add flags support. * gnu/system/image.scm (partition->gexp): Ditto. (system-disk-image): Set the genimage bootable flag if it is part of the partition flags. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Pavel Shlyak 2022-05-23system: image: Support GPT vfat partitions....* gnu/system/image.scm (system-disk-image): Support them. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Pavel Shlyak 2022-05-23system: image: Support MBR vfat partitions....* gnu/system/image.scm (system-disk-image): Support them. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Pavel Shlyak 2022-05-23system: image: Tweak error message....* gnu/system/image.scm (system-disk-image): Tweak it. Mathieu Othacehe 2022-05-23system: image: Fix indentation....* gnu/system/image.scm: Fix it. Mathieu Othacehe 2022-05-18services: Add more description fields....* gnu/services.scm (simple-service): Add 'description' field. * gnu/services/base.scm (udev-rules-service): Likewise. * gnu/system/install.scm (configuration-template-service-type): Likewise. * gnu/tests.scm (marionette-service-type): Likewise. Ludovic Courtès 2022-05-01file-systems: Avoid load-time warnings when attempting to load (guix store)....This makes sure warnings like "incompatible bytecode version" don't go through when looking for (guix store). * gnu/system/file-systems.scm (%store-prefix): Parameterize 'current-warning-port' around 'resolve-module' call. Ludovic Courtès 2022-04-08mapped-devices: Ensure 'cryptsetup open' gets a tty....Fixes <https://issues.guix.gnu.org/54770>. Regression introduced in 400c9ed3d779308e56038305d40cd93acb496180. Previously, for an encrypted /home (say), "cryptsetup open" would be invoked by shepherd, with /dev/null as its standard input. It would thus run in non-interactive mode and, instead of asking for a passphrase, fail with: Nothing to read on input. This change ensures it runs in interactive mode. * gnu/build/file-systems.scm (system*/console, system*/tty): New procedures. * gnu/system/mapped-devices.scm (open-luks-device): Use 'system*/tty' instead of 'system*'. Ludovic Courtès 2022-04-08system: hurd: Fix bogus 'initrd-modules' field....Reported by kitzman on #guix. * gnu/system/hurd.scm (%hurd-default-operating-system)[initrd-modules]: Set to the empty list. Ludovic Courtès 2022-03-19linux-container: Add #:guest-uid and #:guest-gid to 'eval/container'....* gnu/system/linux-container.scm (eval/container): Add #:guest-uid and #:guest-gid and honor them. Ludovic Courtès 2022-03-19linux-container: 'eval/container' honors #:namespaces....* gnu/system/linux-container.scm (eval/container): Pass #:namespaces to 'call-with-container'. Ludovic Courtès 2022-03-15images: novena: Fix build....* gnu/system/images/novena.scm (novena-barebones-os)[kernel]: Use the linux-libre-arm-generic kernel. [initrd-modules]: Do not specify any modules as sdhci-esdhc-imx, ahci_imx and i2c-dev are built-in in the arm-generic kernel. Mathieu Othacehe 2022-03-09system: hurd: Move the Shepherd before the Hurd in %BASE-PACKAGES/HURD....* gnu/system/hurd.scm (%base-packages/hurd): Move SHEPHERD before HURD. Ludovic Courtès 2022-03-01initrd: Use non-hyphenated kernel command-line parameter names....This is to make it less surprising, given the common convention sets forth by the kernel Linux command-line parameters. * gnu/build/linux-boot.scm (boot-system): Rename '--load', '--repl', '--root' and '--system' to 'gnu.load', 'gnu.repl', 'root' and 'gnu.system', respectively. Adjust doc. (find-long-option): Adjust doc. * gnu/installer/parted.scm (installer-root-partition-path): Adjust accordingly. * gnu/system.scm (bootable-kernel-arguments): Add a VERSION argument and update doc. Use VERSION to conditionally return old style vs new style initrd arguments. (%boot-parameters-version): Increment to 1. (operating-system-boot-parameters): Adjust doc. (operating-system-boot-parameters-file): Likewise. * gnu/system/linux-initrd.scm (raw-initrd, base-initrd): Likewise. * doc/guix.texi: Adjust doc. * gnu/build/activation.scm (boot-time-system): Adjust accordingly. * gnu/build/hurd-boot.scm (boot-hurd-system): Likewise. * gnu/packages/commencement.scm (%final-inputs-riscv64): Adjust comment. Maxim Cournoyer 2022-02-15system: Add helper file-system-mount-point-predicate....* gnu/system/file-systems.scm (file-system-mount-point-predicate): Add it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Josselin Poiret