final.scm 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
  3. ;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (gnu installer newt final)
  20. #:use-module (gnu installer final)
  21. #:use-module (gnu installer parted)
  22. #:use-module (gnu installer steps)
  23. #:use-module (gnu installer utils)
  24. #:use-module (gnu installer newt page)
  25. #:use-module (gnu installer newt utils)
  26. #:use-module (guix i18n)
  27. #:use-module (srfi srfi-34)
  28. #:use-module (srfi srfi-35)
  29. #:use-module (newt)
  30. #:export (run-final-page))
  31. (define* (strip-prefix file #:optional (prefix (%installer-target-dir)))
  32. "Strip PREFIX from FILE, if PREFIX actually is a prefix of FILE."
  33. (if (string-prefix? prefix file)
  34. (string-drop file (string-length prefix))
  35. file))
  36. (define (run-config-display-page)
  37. (let ((width (%configuration-file-width))
  38. (height (nearest-exact-integer
  39. (/ (screen-rows) 2))))
  40. (run-file-textbox-page
  41. #:info-text (format #f (G_ "\
  42. We're now ready to proceed with the installation! \
  43. A system configuration file has been generated, it is displayed below. \
  44. This file will be available as '~a' on the installed system. \
  45. The new system will be created from this file once you've pressed OK. \
  46. This will take a few minutes.")
  47. (strip-prefix (%installer-configuration-file)))
  48. #:title (G_ "Configuration file")
  49. #:file (%installer-configuration-file)
  50. #:info-textbox-width width
  51. #:file-textbox-width width
  52. #:file-textbox-height height
  53. #:exit-button-callback-procedure
  54. (lambda ()
  55. (raise
  56. (condition
  57. (&installer-step-abort)))))))
  58. (define (run-install-success-page)
  59. (message-window
  60. (G_ "Installation complete")
  61. (G_ "Reboot")
  62. (G_ "Congratulations! Installation is now complete. \
  63. You may remove the device containing the installation image and \
  64. press the button to reboot."))
  65. ;; Return success so that the installer happily reboots.
  66. 'success)
  67. (define (run-install-failed-page)
  68. (choice-window
  69. (G_ "Installation failed")
  70. (G_ "Restart installer")
  71. (G_ "Retry system install")
  72. (G_ "The final system installation step failed. You can retry the \
  73. last step, or restart the installer.")))
  74. (define* (run-install-shell locale
  75. #:key (users '()))
  76. (clear-screen)
  77. (newt-suspend)
  78. (let ((install-ok? (install-system locale #:users users)))
  79. (newt-resume)
  80. install-ok?))
  81. (define (run-final-page result prev-steps)
  82. (let* ((configuration (format-configuration prev-steps result))
  83. (user-partitions (result-step result 'partition))
  84. (locale (result-step result 'locale))
  85. (users (result-step result 'user))
  86. (install-ok?
  87. (with-mounted-partitions
  88. user-partitions
  89. (configuration->file configuration)
  90. (run-config-display-page)
  91. (run-install-shell locale #:users users))))
  92. (if install-ok?
  93. (run-install-success-page)
  94. (run-install-failed-page))))