2018-11-16 11:43:55 +00:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2020-03-30 10:24:56 +00:00
|
|
|
;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
|
2018-11-16 11:43:55 +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)
|
2018-11-24 03:25:03 +00:00
|
|
|
#:use-module (gnu installer record)
|
2018-12-06 02:11:04 +00:00
|
|
|
#:use-module (gnu installer utils)
|
2022-01-15 13:50:11 +00:00
|
|
|
#:use-module (gnu installer dump)
|
2018-11-24 03:25:03 +00:00
|
|
|
#:use-module (gnu installer newt ethernet)
|
2018-12-05 05:30:16 +00:00
|
|
|
#:use-module (gnu installer newt final)
|
2020-04-08 08:16:25 +00:00
|
|
|
#:use-module (gnu installer newt parameters)
|
2018-11-24 03:25:03 +00:00
|
|
|
#:use-module (gnu installer newt hostname)
|
|
|
|
#:use-module (gnu installer newt keymap)
|
|
|
|
#:use-module (gnu installer newt locale)
|
|
|
|
#:use-module (gnu installer newt menu)
|
|
|
|
#:use-module (gnu installer newt network)
|
2018-12-06 02:11:04 +00:00
|
|
|
#:use-module (gnu installer newt page)
|
2018-12-05 05:57:28 +00:00
|
|
|
#:use-module (gnu installer newt partition)
|
2018-12-05 05:41:48 +00:00
|
|
|
#:use-module (gnu installer newt services)
|
2020-12-04 10:33:16 +00:00
|
|
|
#:use-module (gnu installer newt substitutes)
|
2018-11-24 03:25:03 +00:00
|
|
|
#:use-module (gnu installer newt timezone)
|
|
|
|
#:use-module (gnu installer newt user)
|
|
|
|
#:use-module (gnu installer newt utils)
|
|
|
|
#:use-module (gnu installer newt welcome)
|
|
|
|
#:use-module (gnu installer newt wifi)
|
2018-12-06 02:11:04 +00:00
|
|
|
#:use-module (guix config)
|
2018-11-16 11:43:55 +00:00
|
|
|
#:use-module (guix discovery)
|
2018-11-24 03:25:03 +00:00
|
|
|
#:use-module (guix i18n)
|
2022-01-15 13:50:11 +00:00
|
|
|
#:use-module (srfi srfi-1)
|
2018-11-24 03:25:03 +00:00
|
|
|
#:use-module (srfi srfi-26)
|
2022-01-15 13:50:08 +00:00
|
|
|
#:use-module (srfi srfi-34)
|
|
|
|
#:use-module (srfi srfi-35)
|
2022-01-15 13:50:11 +00:00
|
|
|
#:use-module (ice-9 ftw)
|
|
|
|
#:use-module (ice-9 match)
|
2018-11-24 03:25:03 +00:00
|
|
|
#:use-module (newt)
|
2018-11-16 11:43:55 +00:00
|
|
|
#:export (newt-installer))
|
|
|
|
|
2018-11-24 03:25:03 +00:00
|
|
|
(define (init)
|
|
|
|
(newt-init)
|
|
|
|
(clear-screen)
|
2020-03-30 10:24:56 +00:00
|
|
|
(set-screen-size!)
|
2022-01-15 13:49:56 +00:00
|
|
|
(installer-log-line "Display is ~ax~a." (screen-columns) (screen-rows))
|
2020-03-30 10:24:56 +00:00
|
|
|
(push-help-line
|
2020-04-08 08:16:25 +00:00
|
|
|
(format #f (G_ "Press <F1> for installation parameters."))))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2018-11-24 03:25:03 +00:00
|
|
|
(define (exit)
|
2018-12-08 01:37:56 +00:00
|
|
|
(newt-finish)
|
|
|
|
(clear-screen))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2022-01-15 13:50:11 +00:00
|
|
|
(define (exit-error error)
|
2022-10-23 13:34:50 +00:00
|
|
|
;; Newt may be suspended in the context of the "install-system"
|
|
|
|
;; procedure. Resume it unconditionnally.
|
|
|
|
(newt-resume)
|
2018-12-06 02:11:04 +00:00
|
|
|
(newt-set-color COLORSET-ROOT "white" "red")
|
2022-01-15 13:50:11 +00:00
|
|
|
(define action
|
|
|
|
(run-textbox-page
|
|
|
|
#:info-text (G_ "The installer has encountered an unexpected problem. \
|
|
|
|
The backtrace is displayed below. You may choose to exit or create a dump \
|
|
|
|
archive.")
|
2018-12-06 02:11:04 +00:00
|
|
|
#:title (G_ "Unexpected problem")
|
2022-01-15 13:50:11 +00:00
|
|
|
#:content error
|
|
|
|
#:buttons-spec
|
|
|
|
(list
|
|
|
|
(cons (G_ "Dump") (const 'dump))
|
|
|
|
(cons (G_ "Exit") (const 'exit)))))
|
2018-12-06 02:11:04 +00:00
|
|
|
(newt-set-color COLORSET-ROOT "white" "blue")
|
2022-01-15 13:50:11 +00:00
|
|
|
action)
|
|
|
|
|
|
|
|
(define (report-page dump-archive)
|
|
|
|
(define text
|
|
|
|
(format #f (G_ "The dump archive was created as ~a. Would you like to \
|
|
|
|
send this archive to the Guix servers?") dump-archive))
|
|
|
|
(define title (G_ "Dump archive created"))
|
|
|
|
(when (run-confirmation-page text title)
|
|
|
|
(let* ((uploaded-name (send-dump-report dump-archive))
|
|
|
|
(text (if uploaded-name
|
|
|
|
(format #f (G_ "The dump was uploaded as ~a. Please \
|
|
|
|
report it by email to ~a.") uploaded-name %guix-bug-report-address)
|
|
|
|
(G_ "The dump could not be uploaded."))))
|
|
|
|
(run-error-page
|
|
|
|
text
|
|
|
|
(G_ "Dump upload result")))))
|
|
|
|
|
|
|
|
(define (dump-page dump-dir)
|
|
|
|
(define files
|
|
|
|
(scandir dump-dir (lambda (x)
|
|
|
|
(not (or (string=? x ".")
|
|
|
|
(string=? x ".."))))))
|
|
|
|
(fold (match-lambda*
|
|
|
|
(((file . enable?) acc)
|
|
|
|
(if enable?
|
|
|
|
(cons file acc)
|
|
|
|
acc)))
|
|
|
|
'()
|
|
|
|
(run-dump-page
|
|
|
|
dump-dir
|
|
|
|
(map (lambda (x)
|
|
|
|
(cons x #f))
|
|
|
|
files))))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2022-01-15 13:50:01 +00:00
|
|
|
(define (newt-run-command . args)
|
2022-01-15 13:50:08 +00:00
|
|
|
(define command-output "")
|
|
|
|
(define (line-accumulator line)
|
|
|
|
(set! command-output
|
2022-12-09 16:47:08 +00:00
|
|
|
(string-append/shared command-output line)))
|
2022-01-15 13:50:08 +00:00
|
|
|
(define result (run-external-command-with-line-hooks (list line-accumulator)
|
|
|
|
args))
|
|
|
|
(define exit-val (status:exit-val result))
|
|
|
|
(define term-sig (status:term-sig result))
|
|
|
|
(define stop-sig (status:stop-sig result))
|
|
|
|
|
|
|
|
(if (and exit-val (zero? exit-val))
|
|
|
|
#t
|
|
|
|
(let ((info-text
|
|
|
|
(cond
|
|
|
|
(exit-val
|
|
|
|
(format #f (G_ "External command ~s exited with code ~a")
|
|
|
|
args exit-val))
|
|
|
|
(term-sig
|
|
|
|
(format #f (G_ "External command ~s terminated by signal ~a")
|
|
|
|
args term-sig))
|
|
|
|
(stop-sig
|
|
|
|
(format #f (G_ "External command ~s stopped by signal ~a")
|
|
|
|
args stop-sig)))))
|
|
|
|
(run-textbox-page #:title (G_ "External command error")
|
|
|
|
#:info-text info-text
|
|
|
|
#:content command-output
|
|
|
|
#:buttons-spec
|
|
|
|
(list
|
|
|
|
(cons "Ignore" (const #t))
|
|
|
|
(cons "Abort"
|
|
|
|
(lambda ()
|
|
|
|
(abort-to-prompt 'installer-step 'abort)))
|
2022-01-15 13:50:11 +00:00
|
|
|
(cons "Report"
|
2022-01-15 13:50:08 +00:00
|
|
|
(lambda ()
|
|
|
|
(raise
|
|
|
|
(condition
|
|
|
|
((@@ (guix build utils)
|
|
|
|
&invoke-error)
|
|
|
|
(program (car args))
|
|
|
|
(arguments (cdr args))
|
|
|
|
(exit-status exit-val)
|
|
|
|
(term-signal term-sig)
|
|
|
|
(stop-signal stop-sig)))))))))))
|
2022-01-15 13:50:01 +00:00
|
|
|
|
2018-12-05 05:30:16 +00:00
|
|
|
(define (final-page result prev-steps)
|
|
|
|
(run-final-page result prev-steps))
|
|
|
|
|
2018-11-24 03:25:03 +00:00
|
|
|
(define* (locale-page #:key
|
|
|
|
supported-locales
|
|
|
|
iso639-languages
|
|
|
|
iso3166-territories)
|
|
|
|
(run-locale-page
|
|
|
|
#:supported-locales supported-locales
|
|
|
|
#:iso639-languages iso639-languages
|
|
|
|
#:iso3166-territories iso3166-territories))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2018-11-24 03:25:03 +00:00
|
|
|
(define (timezone-page zonetab)
|
|
|
|
(run-timezone-page zonetab))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2022-11-03 16:57:51 +00:00
|
|
|
(define* (welcome-page logo #:key pci-database)
|
|
|
|
(run-welcome-page logo #:pci-database pci-database))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2018-11-24 03:25:03 +00:00
|
|
|
(define (menu-page steps)
|
|
|
|
(run-menu-page steps))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2020-03-30 10:24:56 +00:00
|
|
|
(define* (keymap-page layouts context)
|
|
|
|
(run-keymap-page layouts #:context context))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2018-11-24 03:25:03 +00:00
|
|
|
(define (network-page)
|
|
|
|
(run-network-page))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2020-12-04 10:33:16 +00:00
|
|
|
(define (substitutes-page)
|
|
|
|
(run-substitutes-page))
|
|
|
|
|
2018-11-24 03:25:03 +00:00
|
|
|
(define (hostname-page)
|
|
|
|
(run-hostname-page))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2018-11-24 03:25:03 +00:00
|
|
|
(define (user-page)
|
|
|
|
(run-user-page))
|
2018-11-16 11:43:55 +00:00
|
|
|
|
2018-12-05 05:57:28 +00:00
|
|
|
(define (partition-page)
|
2020-09-20 19:09:19 +00:00
|
|
|
(run-partitioning-page))
|
2018-12-05 05:57:28 +00:00
|
|
|
|
2018-12-05 05:41:48 +00:00
|
|
|
(define (services-page)
|
|
|
|
(run-services-page))
|
|
|
|
|
2020-04-08 08:16:25 +00:00
|
|
|
(define (parameters-menu menu-proc)
|
2020-03-30 10:24:56 +00:00
|
|
|
(newt-set-help-callback menu-proc))
|
|
|
|
|
2020-04-08 08:16:25 +00:00
|
|
|
(define (parameters-page keyboard-layout-selection)
|
|
|
|
(run-parameters-page keyboard-layout-selection))
|
2020-03-30 10:24:56 +00:00
|
|
|
|
2018-11-16 11:43:55 +00:00
|
|
|
(define newt-installer
|
|
|
|
(installer
|
|
|
|
(name 'newt)
|
|
|
|
(init init)
|
|
|
|
(exit exit)
|
|
|
|
(exit-error exit-error)
|
2018-12-05 05:30:16 +00:00
|
|
|
(final-page final-page)
|
2018-11-16 11:43:55 +00:00
|
|
|
(keymap-page keymap-page)
|
|
|
|
(locale-page locale-page)
|
|
|
|
(menu-page menu-page)
|
|
|
|
(network-page network-page)
|
2020-12-04 10:33:16 +00:00
|
|
|
(substitutes-page substitutes-page)
|
2018-11-16 11:43:55 +00:00
|
|
|
(timezone-page timezone-page)
|
|
|
|
(hostname-page hostname-page)
|
|
|
|
(user-page user-page)
|
2018-12-05 05:57:28 +00:00
|
|
|
(partition-page partition-page)
|
2018-12-05 05:41:48 +00:00
|
|
|
(services-page services-page)
|
2020-03-30 10:24:56 +00:00
|
|
|
(welcome-page welcome-page)
|
2020-04-08 08:16:25 +00:00
|
|
|
(parameters-menu parameters-menu)
|
2021-12-29 12:45:26 +00:00
|
|
|
(parameters-page parameters-page)
|
2022-01-15 13:50:01 +00:00
|
|
|
(dump-page dump-page)
|
2022-01-15 13:50:11 +00:00
|
|
|
(run-command newt-run-command)
|
|
|
|
(report-page report-page)))
|