2018-12-05 05:30:16 +00:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2020-02-10 13:47:56 +00:00
|
|
|
;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
|
2020-01-12 20:59:01 +00:00
|
|
|
;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
|
2018-12-05 05:30:16 +00:00
|
|
|
;;;
|
|
|
|
;;; 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)
|
2020-06-14 11:10:40 +00:00
|
|
|
#:use-module (guix colors)
|
2018-12-05 05:30:16 +00:00
|
|
|
#:use-module (srfi srfi-34)
|
|
|
|
#:use-module (srfi srfi-35)
|
2020-02-10 13:47:56 +00:00
|
|
|
#:use-module (ice-9 match)
|
2020-10-23 09:31:56 +00:00
|
|
|
#:use-module ((ice-9 rdelim) #:select (read-line))
|
2018-12-05 05:30:16 +00:00
|
|
|
#:use-module (newt)
|
|
|
|
#:export (run-final-page))
|
|
|
|
|
2019-04-28 20:55:01 +00:00
|
|
|
(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))
|
|
|
|
|
2020-01-12 20:59:01 +00:00
|
|
|
(define* (run-config-display-page #:key locale)
|
2020-11-06 09:59:54 +00:00
|
|
|
(let ((width (max 70 (- (screen-columns) 20)))
|
|
|
|
(height (default-listbox-height)))
|
2018-12-05 05:30:16 +00:00
|
|
|
(run-file-textbox-page
|
2019-04-28 20:55:01 +00:00
|
|
|
#:info-text (format #f (G_ "\
|
|
|
|
We're now ready to proceed with the installation! \
|
2019-01-16 17:01:38 +00:00
|
|
|
A system configuration file has been generated, it is displayed below. \
|
2019-04-28 20:55:01 +00:00
|
|
|
This file will be available as '~a' on the installed system. \
|
2019-01-16 17:01:38 +00:00
|
|
|
The new system will be created from this file once you've pressed OK. \
|
|
|
|
This will take a few minutes.")
|
2019-04-28 20:55:01 +00:00
|
|
|
(strip-prefix (%installer-configuration-file)))
|
2018-12-05 05:30:16 +00:00
|
|
|
#:title (G_ "Configuration file")
|
|
|
|
#:file (%installer-configuration-file)
|
2020-01-12 20:59:01 +00:00
|
|
|
#:edit-button? #t
|
|
|
|
#:editor-locale locale
|
2018-12-05 05:30:16 +00:00
|
|
|
#:info-textbox-width width
|
|
|
|
#:file-textbox-width width
|
|
|
|
#:file-textbox-height height
|
2018-12-05 10:50:17 +00:00
|
|
|
#:exit-button-callback-procedure
|
2018-12-05 05:30:16 +00:00
|
|
|
(lambda ()
|
|
|
|
(raise
|
|
|
|
(condition
|
|
|
|
(&installer-step-abort)))))))
|
|
|
|
|
|
|
|
(define (run-install-success-page)
|
2020-01-22 21:57:14 +00:00
|
|
|
(match (current-clients)
|
|
|
|
(()
|
|
|
|
(message-window
|
|
|
|
(G_ "Installation complete")
|
|
|
|
(G_ "Reboot")
|
|
|
|
(G_ "Congratulations! Installation is now complete. \
|
2019-01-16 17:01:38 +00:00
|
|
|
You may remove the device containing the installation image and \
|
2020-01-22 21:57:14 +00:00
|
|
|
press the button to reboot.")))
|
|
|
|
(_
|
|
|
|
;; When there are clients connected, send them a message and keep going.
|
|
|
|
(send-to-clients '(installation-complete))))
|
2019-04-26 12:08:39 +00:00
|
|
|
|
|
|
|
;; Return success so that the installer happily reboots.
|
|
|
|
'success)
|
2018-12-05 05:30:16 +00:00
|
|
|
|
|
|
|
(define (run-install-failed-page)
|
2020-01-22 21:57:14 +00:00
|
|
|
(match (current-clients)
|
|
|
|
(()
|
|
|
|
(match (choice-window
|
|
|
|
(G_ "Installation failed")
|
|
|
|
(G_ "Resume")
|
|
|
|
(G_ "Restart the installer")
|
|
|
|
(G_ "The final system installation step failed. You can resume from \
|
2020-02-10 13:47:56 +00:00
|
|
|
a specific step, or restart the installer."))
|
2020-01-22 21:57:14 +00:00
|
|
|
(1 (raise
|
|
|
|
(condition
|
|
|
|
(&installer-step-abort))))
|
|
|
|
(2
|
|
|
|
;; Keep going, the installer will be restarted later on.
|
|
|
|
#t)))
|
|
|
|
(_
|
|
|
|
(send-to-clients '(installation-failure))
|
2020-02-10 13:47:56 +00:00
|
|
|
#t)))
|
2018-12-05 05:30:16 +00:00
|
|
|
|
2019-04-24 15:59:06 +00:00
|
|
|
(define* (run-install-shell locale
|
|
|
|
#:key (users '()))
|
2018-12-05 05:30:16 +00:00
|
|
|
(clear-screen)
|
|
|
|
(newt-suspend)
|
2019-04-24 15:59:06 +00:00
|
|
|
(let ((install-ok? (install-system locale #:users users)))
|
2018-12-05 05:30:16 +00:00
|
|
|
(newt-resume)
|
|
|
|
install-ok?))
|
|
|
|
|
|
|
|
(define (run-final-page result prev-steps)
|
2020-10-23 09:31:56 +00:00
|
|
|
(define (wait-for-clients)
|
|
|
|
(unless (null? (current-clients))
|
|
|
|
(syslog "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)
|
|
|
|
|
|
|
|
(syslog "proceeding with final step~%")
|
2019-04-22 22:08:54 +00:00
|
|
|
(let* ((configuration (format-configuration prev-steps result))
|
2018-12-05 05:30:16 +00:00
|
|
|
(user-partitions (result-step result 'partition))
|
2019-04-22 22:08:54 +00:00
|
|
|
(locale (result-step result 'locale))
|
2019-04-24 15:59:06 +00:00
|
|
|
(users (result-step result 'user))
|
2018-12-05 05:30:16 +00:00
|
|
|
(install-ok?
|
|
|
|
(with-mounted-partitions
|
|
|
|
user-partitions
|
|
|
|
(configuration->file configuration)
|
2020-01-12 20:59:01 +00:00
|
|
|
(run-config-display-page #:locale locale)
|
2019-04-24 15:59:06 +00:00
|
|
|
(run-install-shell locale #:users users))))
|
2018-12-05 05:30:16 +00:00
|
|
|
(if install-ok?
|
|
|
|
(run-install-success-page)
|
|
|
|
(run-install-failed-page))))
|