From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leo Famulari Subject: Re: Non-graphical GRUB configuration Date: Wed, 5 Apr 2017 07:59:19 -0400 Message-ID: <20170405115919.GA28944@jasmine> References: <20170331125956.rhlwjg45vwo3pgwh@abyayala> <20170331234321.GA10435@jasmine> <20170401072740.kgzz3zbtikn5hpg5@abyayala> <20170401202901.GA10480@jasmine> <86vaqmwz3c.fsf@gmail.com> <20170402210620.GA26945@jasmine> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oLBj+sq0vYjzfsbl" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvjaz-0007K5-Iz for guix-devel@gnu.org; Wed, 05 Apr 2017 07:59:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvjau-0000KZ-M3 for guix-devel@gnu.org; Wed, 05 Apr 2017 07:59:29 -0400 Content-Disposition: inline In-Reply-To: <20170402210620.GA26945@jasmine> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: myglc2 Cc: guix-devel@gnu.org --oLBj+sq0vYjzfsbl Content-Type: multipart/mixed; boundary="yrj/dFKFPuw6o+aM" Content-Disposition: inline --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Apr 02, 2017 at 05:06:20PM -0400, Leo Famulari wrote: > Based on the GRUB manual [0], how about this plan? >=20 > We'd add these fields to (grub-configuration):=20 >=20 > terminal-outputs: One or more symbols: console, serial, gfxterm, > ofconsole, vga_text. Default gfxterm. >=20 > terminal-inputs: One or more symbols: console, serial, ofconsole, > at_keyboard,usb_keyboard. Default unset. >=20 > If 'terminal-inputs' or 'serial-*' are unset, we do what we do now: > nothing. If 'terminal-outputs' is unset, we also do the same thing we > now, which is set it to gfxterm. >=20 > If any of them are set, we'd insert the corresponding text into the > generated grub.cfg. >=20 > If terminal-outputs does not include the symbol 'gfxterm', we'd disable > the "setup_gfxterm" function. Here's a WIP patch that I'd like some advice about. It does insert the relevant text into grub.cfg, although I recommend testing it in a virtual machine for now. Questions: 1) In general, is this approach okay? 2) I think that (grub-setup-io) should be used in (grub-configuration-file) instead of (eye-candy). But, when I try calling it there, in the builder, it has no effect on grub.cfg. Any suggestions for debugging this? --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-system-grub-Expose-GRUB-settings-for-interactive-int.patch" Content-Transfer-Encoding: quoted-printable =46rom c1d081d111fb4778b6a0625abbdd8cc540ae630f Mon Sep 17 00:00:00 2001 =46rom: Leo Famulari Date: Sun, 2 Apr 2017 22:18:00 -0400 Subject: [PATCH] system: grub: Expose GRUB settings for interactive interfaces. WIP: Does not validate input and setup-io is used in the wrong place * gnu/system/grub.scm (): Add new fields terminal-outputs, terminal-inputs, serial-unit, and serial-speed. (grub-setup-io, setup-gfxterm): New procedures. * doc/guix.texi (GRUB Configuration): Document the new fields. --- doc/guix.texi | 17 ++++++++++++ gnu/system/grub.scm | 75 +++++++++++++++++++++++++++++++++++++++++--------= ---- 2 files changed, 75 insertions(+), 17 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index aa779e38e..8107872bc 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14920,6 +14920,23 @@ The @code{grub-theme} object describing the theme = to use. =20 @item @code{grub} (default: @code{grub}) The GRUB package to use. + +@item @code{terminal-outputs} (default: @code{'gfxterm}) +The output terminals used for the GRUB boot menu, as a list of symbols. + +@item @code{terminal-inputs} (default: @code{'()}) +The input terminals used for the GRUB boot menu, as a list of symbols. +The default is the native platform terminal as determined by GRUB at +run-time. + +@item @code{serial-unit} (default: @code{#f}) +The serial unit used by GRUB, as an integer from 0 to 3. The default +value is deferred to GRUB; currently GRUB choosese 0, which corresponds +to COM1. + +@item @code{serial-speed} (default: @code{#f}) +The speed of the serial interface, as an integer. The default value is +deferred to GRUB; currently GRUB chooses 9600bps. @end table =20 @end deftp diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm index 4f9bde6a6..8a516f05f 100644 --- a/gnu/system/grub.scm +++ b/gnu/system/grub.scm @@ -107,17 +107,25 @@ denoting a file name." (define-record-type* grub-configuration make-grub-configuration grub-configuration? - (grub grub-configuration-grub ; package - (default (@ (gnu packages bootloaders) grub))) - (device grub-configuration-device) ; string - (menu-entries grub-configuration-menu-entries ; list - (default '())) - (default-entry grub-configuration-default-entry ; integer - (default 0)) - (timeout grub-configuration-timeout ; integer - (default 5)) - (theme grub-configuration-theme ; - (default %default-theme))) + (grub grub-configuration-grub ; package + (default (@ (gnu packages bootloaders) grub))) + (device grub-configuration-device) ; string + (menu-entries grub-configuration-menu-entries ; list + (default '())) + (default-entry grub-configuration-default-entry ; integer + (default 0)) + (timeout grub-configuration-timeout ; integer + (default 5)) + (theme grub-configuration-theme ; + (default %default-theme)) + (terminal-outputs grub-configuration-terminal-outputs ; list of symbols + (default '(gfxterm))) + (terminal-inputs grub-configuration-terminal-inputs ; list of symbols + (default '())) + (serial-unit grub-configuration-serial-unit ; integer | #f + (default #f)) + (serial-speed grub-configuration-serial-speed ; integer | #f + (default #f))) =20 (define-record-type* menu-entry make-menu-entry @@ -198,11 +206,16 @@ system string---e.g., \"x86_64-linux\"." insmod vbe insmod vga fi - - terminal_output gfxterm " "")) =20 + (define (setup-gfxterm config font-file) + (if (memq 'gfxterm (grub-configuration-terminal-outputs config)) + #~(format #f "if loadfont ~a; then + setup_gfxterm +fi~%" #$font-file) + "")) + (define (theme-colors type) (let* ((theme (grub-configuration-theme config)) (colors (type theme))) @@ -221,9 +234,8 @@ function setup_gfxterm {~a} # Set 'root' to the partition that contains /gnu/store. ~a =20 -if loadfont ~a; then - setup_gfxterm -fi +~a +~a =20 insmod png if background_image ~a; then @@ -235,7 +247,8 @@ else fi~%" #$setup-gfxterm-body #$(grub-root-search store-device font-file) - #$font-file + #$(grub-setup-io config) + #$(setup-gfxterm config font-file) =20 #$(strip-mount-point store-mount-point image) #$(theme-colors grub-theme-color-normal) @@ -246,6 +259,34 @@ fi~%" ;;; Configuration file. ;;; =20 +(define (grub-setup-io config) + "Return GRUB commands to configure the input / output interfaces. The r= esult +is a string that can be inserted in grub.cfg. +TODO Check the bounds of unit, and compare outputs and inputs to a list of +valid interfaces taken from the GRUB manual." + (let* ((symbols->string (lambda (list) + (string-join (map symbol->string list) " "))) + (outputs (grub-configuration-terminal-outputs config)) + (inputs (grub-configuration-terminal-inputs config)) + (unit (grub-configuration-serial-unit config)) + (speed (grub-configuration-serial-speed config)) + (io (string-append + "terminal_output " (symbols->string outputs) "\n" + (if (null? inputs) + "" + (string-append "terminal_input " + (symbols->string inputs) "\n")) + (if (or unit speed) + (string-append "serial" + (if unit + (string-append " --unit=3D" + (number->string unit)) "") + (if speed + (string-append " --speed=3D" + (number->string speed)) "= ")) + "")))) + (format #f "~a" io))) + (define (grub-root-search device file) "Return the GRUB 'search' command to look for DEVICE, which contains FIL= E, a gexp. The result is a gexp that can be inserted in the grub.cfg-generat= ion --=20 2.12.2 --yrj/dFKFPuw6o+aM-- --oLBj+sq0vYjzfsbl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEsFFZSPHn08G5gDigJkb6MLrKfwgFAljk3BQACgkQJkb6MLrK fwg/dQ/+NhKQK6lZ7v9gTEeuOwav/Zn+KsN/M1Bbw84CooCmZVccKH7R/7Yv6rIq 7By0hZxSW0rU6ITdYbq5+N+RTWUHx6koEFcgVKMq7ZFP6sQGJir7J0wD9eWb//LT daPtZaF+1N2u6SkzdmfUENRa6cV6PbD7RRAV9pRIIiHE0Nt15HefUE0f9mYV0Kez zD9UzhcFHxBHaD46z5xkB0e50NQbly+IZJ0wu1eX9or8MNmpjSQAuybmxz2fFo2O +ByEuYpKfgCqDpo4kf1mzeJ33pChKQaGVVjnivM3AWo37oQHackbORkVIahzmQZS I1bYcPpEusoXRObk4gIKCeZR4x3ciKbK7ChbHd3+d1Z5wdca4aPKaoaxZLK7rG/S bGHzie158x410NsdAPWy2fW6U43RnmR6DHIhJHjpf3M4CdY/QdDgdC5jjii1HV/V 6RDLSy5YDNl4H1QsgXxgaavoO0K5P4K4iOzY/A8IMktECNR7nNU+XpAk+nEOE2JL sEtCGmxBtkpFdcVyqpRIY0iOBAoCD45wSVU6cVfz4ySiLBbW4B7gxmMnqOzj9eEp O6JyY3gkBgPyiLyhhy2UdcStIuzuizUwmSjAbIfajRZuiJyGPRInGbW1Q+2F9lxp aTDMkX1pK/WPZD8x6ixS1HnQlbXAZoKBTK/KSVLsOPb4XcnPrBk= =VltX -----END PGP SIGNATURE----- --oLBj+sq0vYjzfsbl--