installer: Display an eventual backtrace in a page.

* gnu/installer.scm (installer-program): Write the backtrace in
"/tmp/last-installer-error" and pass the filename to installer-exit-error.
* gnu/installer/newt.scm (exit-error): Display the file passed above in a textbox.
This commit is contained in:
Mathieu Othacehe 2018-12-06 11:11:04 +09:00 committed by Ludovic Courtès
parent 3d0f6a055c
commit 133c401f77
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 29 additions and 11 deletions

View File

@ -333,16 +333,15 @@ selected keymap."
#:steps steps)) #:steps steps))
(const #f) (const #f)
(lambda (key . args) (lambda (key . args)
((installer-exit-error current-installer) key args) (let ((error-file "/tmp/last-installer-error"))
(call-with-output-file error-file
;; Be sure to call newt-finish, to restore the terminal into (lambda (port)
;; its original state before printing the error report. (display-backtrace (make-stack #t) port)
(call-with-output-file "/tmp/error" (print-exception port
(lambda (port) (stack-ref (make-stack #t) 1)
(display-backtrace (make-stack #t) port) key args)))
(print-exception port ((installer-exit-error current-installer)
(stack-ref (make-stack #t) 1) error-file key args))
key args)))
(primitive-exit 1))) (primitive-exit 1)))
((installer-exit current-installer))))))) ((installer-exit current-installer)))))))

View File

@ -18,6 +18,7 @@
(define-module (gnu installer newt) (define-module (gnu installer newt)
#:use-module (gnu installer record) #:use-module (gnu installer record)
#:use-module (gnu installer utils)
#:use-module (gnu installer newt ethernet) #:use-module (gnu installer newt ethernet)
#:use-module (gnu installer newt final) #:use-module (gnu installer newt final)
#:use-module (gnu installer newt hostname) #:use-module (gnu installer newt hostname)
@ -25,6 +26,7 @@
#:use-module (gnu installer newt locale) #:use-module (gnu installer newt locale)
#:use-module (gnu installer newt menu) #:use-module (gnu installer newt menu)
#:use-module (gnu installer newt network) #:use-module (gnu installer newt network)
#:use-module (gnu installer newt page)
#:use-module (gnu installer newt partition) #:use-module (gnu installer newt partition)
#:use-module (gnu installer newt services) #:use-module (gnu installer newt services)
#:use-module (gnu installer newt timezone) #:use-module (gnu installer newt timezone)
@ -32,6 +34,7 @@
#:use-module (gnu installer newt utils) #:use-module (gnu installer newt utils)
#:use-module (gnu installer newt welcome) #:use-module (gnu installer newt welcome)
#:use-module (gnu installer newt wifi) #:use-module (gnu installer newt wifi)
#:use-module (guix config)
#:use-module (guix discovery) #:use-module (guix discovery)
#:use-module (guix i18n) #:use-module (guix i18n)
#:use-module (srfi srfi-26) #:use-module (srfi srfi-26)
@ -46,7 +49,23 @@
(define (exit) (define (exit)
(newt-finish)) (newt-finish))
(define (exit-error key . args) (define (exit-error file key args)
(newt-set-color COLORSET-ROOT "white" "red")
(let ((width (nearest-exact-integer
(* (screen-columns) 0.8)))
(height (nearest-exact-integer
(* (screen-rows) 0.7))))
(run-file-textbox-page
#:info-text (format #f (G_ "The installer has encountered an unexpected \
problem. The backtrace is displayed below. Please report it by email to \
<~a>.") %guix-bug-report-address)
#:title (G_ "Unexpected problem")
#:file file
#:exit-button? #f
#:info-textbox-width width
#:file-textbox-width width
#:file-textbox-height height))
(newt-set-color COLORSET-ROOT "white" "blue")
(newt-finish)) (newt-finish))
(define (final-page result prev-steps) (define (final-page result prev-steps)