diff options
author | Josselin Poiret <dev@jpoiret.xyz> | 2022-01-15 14:50:11 +0100 |
---|---|---|
committer | Mathieu Othacehe <othacehe@gnu.org> | 2022-02-02 16:46:44 +0100 |
commit | ad55ccf9b18000144a4e0f28a0f9e57132f94edc (patch) | |
tree | 790d6fda13fb7c0bb88106ce8c944988e5d45afb /gnu/installer/newt | |
parent | 112ef30b84744872b3a7617d9e54b3df5db95560 (diff) |
installer: Make dump archive creation optional and selective.
* gnu/installer.scm (installer-program): Let the installer customize
the dump archive.
* gnu/installer/dump.scm (prepare-dump, make-dump): Split make-dump in
prepare-dump, which copies the files necessary for the dump, and
make-dump which creates the archive.
* gnu/installer/record.scm (installer): Add report-page field. Change
documented return value of exit-error.
* gnu/installer/newt.scm (exit-error): Change arguments to be a string
containing the error. Let the user choose between exiting and
initiating a dump.
(report-page): Add new variable.
* gnu/installer/newt/page.scm (run-dump-page): New variable.
* gnu/installer/newt/dump.scm: Delete it.
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
Diffstat (limited to 'gnu/installer/newt')
-rw-r--r-- | gnu/installer/newt/dump.scm | 36 | ||||
-rw-r--r-- | gnu/installer/newt/page.scm | 65 |
2 files changed, 65 insertions, 36 deletions
diff --git a/gnu/installer/newt/dump.scm b/gnu/installer/newt/dump.scm deleted file mode 100644 index 64f0d58237..0000000000 --- a/gnu/installer/newt/dump.scm +++ /dev/null @@ -1,36 +0,0 @@ -;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2021 Mathieu Othacehe <othacehe@gnu.org> -;;; -;;; 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 dump) - #:use-module (gnu installer dump) - #:use-module (gnu installer newt page) - #:use-module (guix i18n) - #:use-module (newt) - #:export (run-dump-page)) - -(define (run-dump-page dump) - "Run a dump page, proposing the user to upload the crash dump to Guix -servers." - (case (choice-window - (G_ "Crash dump upload") - (G_ "Yes") - (G_ "No") - (G_ "The installer failed. Do you accept to upload the crash dump \ -to Guix servers, so that we can investigate the issue?")) - ((1) (send-dump-report dump)) - ((2) #f))) diff --git a/gnu/installer/newt/page.scm b/gnu/installer/newt/page.scm index b5d7c98094..0f508a31c0 100644 --- a/gnu/installer/newt/page.scm +++ b/gnu/installer/newt/page.scm @@ -47,6 +47,7 @@ %ok-button %exit-button run-textbox-page + run-dump-page run-form-with-clients)) @@ -899,3 +900,67 @@ component ~a." argument)))))))) ;; TODO ('exit-fd-ready (raise (condition (&serious))))))) + +(define* (run-dump-page base-dir file-choices) + (define info-textbox + (make-reflowed-textbox -1 -1 "Please select files you wish to include in \ +the dump." + 50 + #:flags FLAG-BORDER)) + (define components + (map (match-lambda ((file . enabled) + (list + (make-compact-button -1 -1 "Edit") + (make-checkbox -1 -1 file (if enabled #\x #\ ) " x") + file))) + file-choices)) + + (define sub-grid (make-grid 2 (length components))) + + (for-each + (match-lambda* (((button checkbox _) index) + (set-grid-field sub-grid 0 index + GRID-ELEMENT-COMPONENT checkbox + #:anchor ANCHOR-LEFT) + (set-grid-field sub-grid 1 index + GRID-ELEMENT-COMPONENT button + #:anchor ANCHOR-LEFT))) + components (iota (length components))) + + (define grid + (vertically-stacked-grid + GRID-ELEMENT-COMPONENT info-textbox + GRID-ELEMENT-SUBGRID sub-grid + GRID-ELEMENT-COMPONENT (make-button -1 -1 "Create"))) + + (define form (make-form #:flags FLAG-NOF12)) + + (add-form-to-grid grid form #t) + (make-wrapped-grid-window grid "Installer dump") + + (define prompt-tag (make-prompt-tag)) + + (let loop () + (call-with-prompt prompt-tag + (lambda () + (receive (exit-reason argument) + (run-form-with-clients form + `(dump-page)) + (match exit-reason + ('exit-component + (let ((result + (map (match-lambda + ((edit checkbox filename) + (if (components=? edit argument) + (abort-to-prompt prompt-tag filename) + (cons filename (eq? #\x + (checkbox-value checkbox)))))) + components))) + (destroy-form-and-pop form) + result)) + ;; TODO + ('exit-fd-ready + (raise (condition (&serious))))))) + (lambda (k file) + (edit-file (string-append base-dir "/" file)) + (loop))))) |