| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 |
|
| 21 | (define-module (gnu installer newt final)
|
| 22 | #:use-module (gnu installer final)
|
| 23 | #:use-module (gnu installer parted)
|
| 24 | #:use-module (gnu installer steps)
|
| 25 | #:use-module (gnu installer utils)
|
| 26 | #:use-module (gnu installer newt page)
|
| 27 | #:use-module (gnu installer newt utils)
|
| 28 | #:use-module (guix i18n)
|
| 29 | #:use-module (guix colors)
|
| 30 | #:use-module (srfi srfi-34)
|
| 31 | #:use-module (srfi srfi-35)
|
| 32 | #:use-module (ice-9 match)
|
| 33 | #:use-module ((ice-9 rdelim) #:select (read-line))
|
| 34 | #:use-module (newt)
|
| 35 | #:export (run-final-page))
|
| 36 |
|
| 37 | (define* (strip-prefix file #:optional (prefix (%installer-target-dir)))
|
| 38 | "Strip PREFIX from FILE, if PREFIX actually is a prefix of FILE."
|
| 39 | (if (string-prefix? prefix file)
|
| 40 | (string-drop file (string-length prefix))
|
| 41 | file))
|
| 42 |
|
| 43 | (define* (run-config-display-page #:key locale)
|
| 44 | (let ((width (max 70 (- (screen-columns) 20)))
|
| 45 | (height (default-listbox-height)))
|
| 46 | (run-file-textbox-page
|
| 47 | #:info-text (format #f (G_ "\
|
| 48 | We're now ready to proceed with the installation! \
|
| 49 | A system configuration file has been generated, it is displayed below. \
|
| 50 | This file will be available as '~a' on the installed system. \
|
| 51 | The new system will be created from this file once you've pressed OK. \
|
| 52 | This will take a few minutes.")
|
| 53 | (strip-prefix (%installer-configuration-file)))
|
| 54 | #:title (G_ "Configuration file")
|
| 55 | #:file (%installer-configuration-file)
|
| 56 | #:edit-button? #t
|
| 57 | #:editor-locale locale
|
| 58 | #:info-textbox-width width
|
| 59 | #:file-textbox-width width
|
| 60 | #:file-textbox-height height
|
| 61 | #:exit-button-callback-procedure
|
| 62 | (lambda ()
|
| 63 | (abort-to-prompt 'installer-step 'abort)))))
|
| 64 |
|
| 65 | (define (run-install-success-page)
|
| 66 | (match (current-clients)
|
| 67 | (()
|
| 68 | (message-window
|
| 69 | (G_ "Installation complete")
|
| 70 | (G_ "Reboot")
|
| 71 | (G_ "Congratulations! Installation is now complete. \
|
| 72 | You may remove the device containing the installation image and \
|
| 73 | press the button to reboot.")))
|
| 74 | (_
|
| 75 | |
| 76 | (send-to-clients '(installation-complete))))
|
| 77 |
|
| 78 | |
| 79 | 'success)
|
| 80 |
|
| 81 | (define (run-install-failed-page)
|
| 82 | (match (current-clients)
|
| 83 | (()
|
| 84 | (match (ternary-window
|
| 85 | (G_ "Installation failed")
|
| 86 | (G_ "Resume")
|
| 87 | (G_ "Restart the installer")
|
| 88 | (G_ "Report the failure")
|
| 89 | (G_ "The final system installation step failed. You can resume from \
|
| 90 | a specific step, or restart the installer."))
|
| 91 | (1 (abort-to-prompt 'installer-step 'abort))
|
| 92 | (2
|
| 93 | |
| 94 | #t)
|
| 95 | (3 (raise
|
| 96 | (condition
|
| 97 | (&user-abort-error))))))
|
| 98 | (_
|
| 99 | (send-to-clients '(installation-failure))
|
| 100 | #t)))
|
| 101 |
|
| 102 | (define* (run-install-shell locale
|
| 103 | #:key (users '()))
|
| 104 | (clear-screen)
|
| 105 | (newt-suspend)
|
| 106 | (let ((install-ok? (install-system locale #:users users)))
|
| 107 | (newt-resume)
|
| 108 | install-ok?))
|
| 109 |
|
| 110 | (define (run-final-page-install result prev-steps)
|
| 111 | (define (wait-for-clients)
|
| 112 | (unless (null? (current-clients))
|
| 113 | (installer-log-line "waiting with clients before starting final step")
|
| 114 | (send-to-clients '(starting-final-step))
|
| 115 | (match (select (current-clients) '() '())
|
| 116 | (((port _ ...) _ _)
|
| 117 | (read-line port)))))
|
| 118 |
|
| 119 | |
| 120 | |
| 121 | (wait-for-clients)
|
| 122 |
|
| 123 | (installer-log-line "proceeding with final step")
|
| 124 | (let* ((configuration (format-configuration prev-steps result))
|
| 125 | (user-partitions (result-step result 'partition))
|
| 126 | (locale (result-step result 'locale))
|
| 127 | (users (result-step result 'user))
|
| 128 | (install-ok?
|
| 129 | (with-mounted-partitions
|
| 130 | user-partitions
|
| 131 | (configuration->file configuration)
|
| 132 | (run-config-display-page #:locale locale)
|
| 133 | (run-install-shell locale #:users users))))
|
| 134 | (if install-ok?
|
| 135 | (run-install-success-page)
|
| 136 | (run-install-failed-page))))
|
| 137 |
|
| 138 | (define (dry-run-final-page result prev-steps)
|
| 139 | (installer-log-line "proceeding with final step -- dry-run")
|
| 140 | (let* ((configuration (format-configuration prev-steps result))
|
| 141 | (user-partitions (result-step result 'partition))
|
| 142 | (locale (result-step result 'locale))
|
| 143 | (users (result-step result 'user))
|
| 144 | (file (configuration->file configuration))
|
| 145 | (install-ok? (run-config-display-page #:locale locale)))
|
| 146 | (if install-ok?
|
| 147 | (run-install-success-page)
|
| 148 | (run-install-failed-page))))
|
| 149 |
|
| 150 | (define (run-final-page result prev-steps dry-run?)
|
| 151 | (if dry-run?
|
| 152 | (dry-run-final-page result prev-steps)
|
| 153 | (run-final-page-install result prev-steps)))
|