From d0f3a672dcbdfefd3556b6a21985ff0e35eed3be Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 16 Nov 2018 20:43:55 +0900 Subject: gnu: Add graphical installer support. * configure.ac: Require that guile-newt is available. * gnu/installer.scm: New file. * gnu/installer/aux-files/logo.txt: New file. * gnu/installer/build-installer.scm: New file. * gnu/installer/connman.scm: New file. * gnu/installer/keymap.scm: New file. * gnu/installer/locale.scm: New file. * gnu/installer/newt.scm: New file. * gnu/installer/newt/ethernet.scm: New file. * gnu/installer/newt/hostname.scm: New file. * gnu/installer/newt/keymap.scm: New file. * gnu/installer/newt/locale.scm: New file. * gnu/installer/newt/menu.scm: New file. * gnu/installer/newt/network.scm: New file. * gnu/installer/newt/page.scm: New file. * gnu/installer/newt/timezone.scm: New file. * gnu/installer/newt/user.scm: New file. * gnu/installer/newt/utils.scm: New file. * gnu/installer/newt/welcome.scm: New file. * gnu/installer/newt/wifi.scm: New file. * gnu/installer/steps.scm: New file. * gnu/installer/timezone.scm: New file. * gnu/installer/utils.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add previous files. * gnu/system.scm: Export %root-account. * gnu/system/install.scm (%installation-services): Use kmscon instead of linux VT for all tty. (installation-os)[users]: Add the graphical installer as shell of the root account. [packages]: Add font related packages. * po/guix/POTFILES.in: Add installer files. --- gnu/installer/newt/welcome.scm | 122 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 gnu/installer/newt/welcome.scm (limited to 'gnu/installer/newt/welcome.scm') diff --git a/gnu/installer/newt/welcome.scm b/gnu/installer/newt/welcome.scm new file mode 100644 index 0000000000..8ed9f68918 --- /dev/null +++ b/gnu/installer/newt/welcome.scm @@ -0,0 +1,122 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2018 Mathieu Othacehe +;;; +;;; 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 + +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu installer newt welcome) + #:use-module (gnu installer utils) + #:use-module (gnu installer newt utils) + #:use-module (guix build syscalls) + #:use-module (guix i18n) + #:use-module (ice-9 match) + #:use-module (ice-9 receive) + #:use-module (newt) + #:export (run-welcome-page)) + +;; Margin between screen border and newt root window. +(define margin-left (make-parameter 3)) +(define margin-top (make-parameter 3)) + +;; Expected width and height for the logo. +(define logo-width (make-parameter 50)) +(define logo-height (make-parameter 23)) + +(define (nearest-exact-integer x) + "Given a real number X, return the nearest exact integer, with ties going to +the nearest exact even integer." + (inexact->exact (round x))) + +(define* (run-menu-page title logo + #:key + listbox-items + listbox-item->text) + "Run a page with the given TITLE, to ask the user to choose between +LISTBOX-ITEMS displayed in a listbox. The listbox items are converted to text +using LISTBOX-ITEM->TEXT procedure. Display the textual LOGO in the center of +the page. Contrary to other pages, we cannot resort to grid layouts, because +we want this page to occupy all the screen space available." + (define (fill-listbox listbox items) + (map (lambda (item) + (let* ((text (listbox-item->text item)) + (key (append-entry-to-listbox listbox text))) + (cons key item))) + items)) + + (let* ((windows + (make-window (margin-left) + (margin-top) + (- (screen-columns) (* 2 (margin-left))) + (- (screen-rows) (* 2 (margin-top))) + title)) + (logo-textbox + (make-textbox (nearest-exact-integer + (- (/ (screen-columns) 2) + (+ (/ (logo-width) 2) (margin-left)))) + (margin-top) (logo-width) (logo-height) 0)) + (text (set-textbox-text logo-textbox + (read-all logo))) + (options-listbox + (make-listbox (margin-left) + (+ (logo-height) (margin-top)) + (- (screen-rows) (+ (logo-height) + (* (margin-top) 4))) + (logior FLAG-BORDER FLAG-RETURNEXIT))) + (keys (fill-listbox options-listbox listbox-items)) + (form (make-form))) + (set-listbox-width options-listbox (- (screen-columns) + (* (margin-left) 4))) + (add-components-to-form form logo-textbox options-listbox) + + (receive (exit-reason argument) + (run-form form) + (dynamic-wind + (const #t) + (lambda () + (when (eq? exit-reason 'exit-component) + (cond + ((components=? argument options-listbox) + (let* ((entry (current-listbox-entry options-listbox)) + (item (assoc-ref keys entry))) + (match item + ((text . proc) + (proc)))))))) + (lambda () + (destroy-form-and-pop form)))))) + +(define (run-welcome-page logo) + "Run a welcome page with the given textual LOGO displayed at the center of +the page. Ask the user to choose between manual installation, graphical +installation and reboot." + (run-menu-page + (G_ "GNU GuixSD install") + logo + #:listbox-items + `((,(G_ "Install using the unguided shell based process") + . + ,(lambda () + (clear-screen) + (newt-suspend) + (system* "bash" "-l") + (newt-resume))) + (,(G_ "Graphical install using a guided terminal based interface") + . + ,(const #t)) + (,(G_ "Reboot") + . + ,(lambda () + (newt-finish) + (reboot)))) + #:listbox-item->text car)) -- cgit v1.2.3 From 113bdf6ae1819022d8c0d640b78a37c7d6b52723 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 23 Nov 2018 23:23:45 +0900 Subject: installer: Rewrite welcome page. The welcome page is the only page using absolute positioning for the newt components, so that the page occupies all the screen space. This is becoming too hard to manage, so switch to grid management like elsewhere, even if the result is less appealing. Also add an info text to the page with a mention on how to switch back to the original installer. * gnu/installer/newt/welcome.scm (run-menu-page): Use a vertically stacked grid instead of hard window placement. --- gnu/installer/newt/welcome.scm | 58 ++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 31 deletions(-) (limited to 'gnu/installer/newt/welcome.scm') diff --git a/gnu/installer/newt/welcome.scm b/gnu/installer/newt/welcome.scm index 8ed9f68918..3a0e45e198 100644 --- a/gnu/installer/newt/welcome.scm +++ b/gnu/installer/newt/welcome.scm @@ -26,20 +26,14 @@ #:use-module (newt) #:export (run-welcome-page)) -;; Margin between screen border and newt root window. -(define margin-left (make-parameter 3)) -(define margin-top (make-parameter 3)) - ;; Expected width and height for the logo. -(define logo-width (make-parameter 50)) -(define logo-height (make-parameter 23)) +(define logo-width (make-parameter 43)) +(define logo-height (make-parameter 19)) -(define (nearest-exact-integer x) - "Given a real number X, return the nearest exact integer, with ties going to -the nearest exact even integer." - (inexact->exact (round x))) +(define info-textbox-width (make-parameter 70)) +(define options-listbox-height (make-parameter 5)) -(define* (run-menu-page title logo +(define* (run-menu-page title info-text logo #:key listbox-items listbox-item->text) @@ -55,30 +49,27 @@ we want this page to occupy all the screen space available." (cons key item))) items)) - (let* ((windows - (make-window (margin-left) - (margin-top) - (- (screen-columns) (* 2 (margin-left))) - (- (screen-rows) (* 2 (margin-top))) - title)) - (logo-textbox - (make-textbox (nearest-exact-integer - (- (/ (screen-columns) 2) - (+ (/ (logo-width) 2) (margin-left)))) - (margin-top) (logo-width) (logo-height) 0)) - (text (set-textbox-text logo-textbox - (read-all logo))) + (let* ((logo-textbox + (make-textbox -1 -1 (logo-width) (logo-height) 0)) + (info-textbox + (make-reflowed-textbox -1 -1 + info-text + (info-textbox-width))) (options-listbox - (make-listbox (margin-left) - (+ (logo-height) (margin-top)) - (- (screen-rows) (+ (logo-height) - (* (margin-top) 4))) + (make-listbox -1 -1 + (options-listbox-height) (logior FLAG-BORDER FLAG-RETURNEXIT))) (keys (fill-listbox options-listbox listbox-items)) + (grid (vertically-stacked-grid + GRID-ELEMENT-COMPONENT logo-textbox + GRID-ELEMENT-COMPONENT info-textbox + GRID-ELEMENT-COMPONENT options-listbox)) (form (make-form))) - (set-listbox-width options-listbox (- (screen-columns) - (* (margin-left) 4))) - (add-components-to-form form logo-textbox options-listbox) + + (set-textbox-text logo-textbox (read-all logo)) + + (add-form-to-grid grid form #t) + (make-wrapped-grid-window grid title) (receive (exit-reason argument) (run-form form) @@ -102,6 +93,11 @@ the page. Ask the user to choose between manual installation, graphical installation and reboot." (run-menu-page (G_ "GNU GuixSD install") + (G_ "Welcome to GNU GuixSD installer! + +Please note that the present graphical installer is still under heavy \ +development, so you might want to fallback to the classical installer by \ +pressing CTRL-ALT-F3.") logo #:listbox-items `((,(G_ "Install using the unguided shell based process") -- cgit v1.2.3 From 6aa625c2f82332f8987247958fc18955bd8078f3 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Wed, 5 Dec 2018 14:50:16 +0900 Subject: installer: Redirect to TTY3 root shell for unguided install. * gnu/installer/newt/welcome.scm (run-welcome-page): Switch to TTY3 for unguided shell based install. --- gnu/installer/newt/welcome.scm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gnu/installer/newt/welcome.scm') diff --git a/gnu/installer/newt/welcome.scm b/gnu/installer/newt/welcome.scm index 3a0e45e198..658f7bae40 100644 --- a/gnu/installer/newt/welcome.scm +++ b/gnu/installer/newt/welcome.scm @@ -96,18 +96,18 @@ installation and reboot." (G_ "Welcome to GNU GuixSD installer! Please note that the present graphical installer is still under heavy \ -development, so you might want to fallback to the classical installer by \ -pressing CTRL-ALT-F3.") +development, so you might want to prefer using the shell based process. \ +The documentation is accessible at any time by pressing CTRL-ALT-F2.") logo #:listbox-items - `((,(G_ "Install using the unguided shell based process") + `((,(G_ "Install using the shell based process") . ,(lambda () - (clear-screen) - (newt-suspend) - (system* "bash" "-l") - (newt-resume))) - (,(G_ "Graphical install using a guided terminal based interface") + ;; Switch to TTY3, where a root shell is available for shell based + ;; install. The other root TTY's would have been ok too. + (system* "chvt" "3") + (run-welcome-page logo))) + (,(G_ "Graphical install using a terminal based interface") . ,(const #t)) (,(G_ "Reboot") -- cgit v1.2.3 From a8c4b6828810e88db56ab5f0b83fa80e9c962cfa Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Sun, 6 Jan 2019 11:06:51 +0100 Subject: installer: welcome: Put "Graphical installer" ahead. * gnu/installer/newt/welcome.scm (run-welcome-page): Propose "Graphical install" before shell based install. --- gnu/installer/newt/welcome.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gnu/installer/newt/welcome.scm') diff --git a/gnu/installer/newt/welcome.scm b/gnu/installer/newt/welcome.scm index 658f7bae40..eec98e291a 100644 --- a/gnu/installer/newt/welcome.scm +++ b/gnu/installer/newt/welcome.scm @@ -100,16 +100,16 @@ development, so you might want to prefer using the shell based process. \ The documentation is accessible at any time by pressing CTRL-ALT-F2.") logo #:listbox-items - `((,(G_ "Install using the shell based process") + `((,(G_ "Graphical install using a terminal based interface") + . + ,(const #t)) + (,(G_ "Install using the shell based process") . ,(lambda () ;; Switch to TTY3, where a root shell is available for shell based ;; install. The other root TTY's would have been ok too. (system* "chvt" "3") (run-welcome-page logo))) - (,(G_ "Graphical install using a terminal based interface") - . - ,(const #t)) (,(G_ "Reboot") . ,(lambda () -- cgit v1.2.3