From patchwork Wed Mar 20 23:04:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 1512 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2ABF216DB7; Wed, 20 Mar 2019 23:06:14 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 636E616DB4 for ; Wed, 20 Mar 2019 23:06:13 +0000 (GMT) Received: from localhost ([127.0.0.1]:56192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6kHl-0007vR-0A for patchwork@mira.cbaines.net; Wed, 20 Mar 2019 19:06:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6kHg-0007sB-VD for guix-patches@gnu.org; Wed, 20 Mar 2019 19:06:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6kHe-0003RK-Hu for guix-patches@gnu.org; Wed, 20 Mar 2019 19:06:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6kHe-0003Qc-8O for guix-patches@gnu.org; Wed, 20 Mar 2019 19:06:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h6kHe-0005iL-1Y for guix-patches@gnu.org; Wed, 20 Mar 2019 19:06:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#34929] [PATCH 11/12] system: Initialize console keyboard layout in the initrd. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 20 Mar 2019 23:06:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34929 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 34929@debbugs.gnu.org Received: via spool by 34929-submit@debbugs.gnu.org id=B34929.155312311021840 (code B ref 34929); Wed, 20 Mar 2019 23:06:05 +0000 Received: (at 34929) by debbugs.gnu.org; 20 Mar 2019 23:05:10 +0000 Received: from localhost ([127.0.0.1]:52457 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h6kGi-0005g2-MD for submit@debbugs.gnu.org; Wed, 20 Mar 2019 19:05:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56831) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h6kGc-0005dU-Qg for 34929@debbugs.gnu.org; Wed, 20 Mar 2019 19:05:04 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6kGX-0002Ui-IG; Wed, 20 Mar 2019 19:04:57 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=57670 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1h6kGX-0004wC-12; Wed, 20 Mar 2019 19:04:57 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 21 Mar 2019 00:04:34 +0100 Message-Id: <20190320230435.25458-11-ludo@gnu.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320230435.25458-1-ludo@gnu.org> References: <20190320230435.25458-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Partially fixes . * gnu/system.scm ()[keyboard-layout]: New field. (operating-system-initrd-file): Pass #:keyboard-layout to MAKE-INITRD. * gnu/system/linux-initrd.scm (raw-initrd): Add #:keyboard-layout. Pass #:keymap-file to 'boot-system'. (base-initrd): Add #:keyboard-layout. [helper-packages]: Add LOADKEYS-STATIC when KEYBOARD-LAYOUT is true. Pass #:keyboard-layout to 'raw-initrd'. * gnu/build/linux-boot.scm (boot-system): Add #:keymap-file and honor it. * doc/guix.texi (operating-system Reference): Document the 'keyboard-layout' field. (Initial RAM Disk): Update 'raw-initrd' and 'base-initrd' documentation. --- doc/guix.texi | 34 +++++++++++++++++++++++++++++++++- gnu/build/linux-boot.scm | 15 +++++++++++++-- gnu/system.scm | 7 +++++-- gnu/system/linux-initrd.scm | 26 ++++++++++++++++++++++++-- 4 files changed, 75 insertions(+), 7 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5fa68d5e5a..e2bd84493b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -10364,6 +10364,24 @@ the command-line of the kernel---e.g., @code{("console=ttyS0")}. @item @code{bootloader} The system bootloader configuration object. @xref{Bootloader Configuration}. +@item @code{keyboard-layout} (default: @code{#f}) +This field specifies the keyboard layout to use in the console. It can be +either @code{#f}, in which case the default keyboard layout is used (usually +US English), or a @code{} record. + +This keyboard layout is in effect as soon as the kernel has booted. For +instance, it is the keyboard layout in effect when you type a passphrase if +your root file system is on a @code{luks-device-mapping} mapped device +(@pxref{Mapped Devices}). + +@quotation Note +This does @emph{not} specify the keyboard layout used by the bootloader, nor +that used by the graphical display server. @xref{Bootloader Configuration}, +for information on how to specify the bootloader's keyboard layout. @xref{X +Window}, for information on how to specify the keyboard layout used by the X +Window System. +@end quotation + @item @code{initrd-modules} (default: @code{%base-initrd-modules}) @cindex initrd @cindex initial RAM disk @@ -22972,6 +22990,7 @@ here is how to use it and customize it further. @cindex initial RAM disk @deffn {Scheme Procedure} raw-initrd @var{file-systems} @ [#:linux-modules '()] [#:mapped-devices '()] @ + [#:keyboard-layout #f] @ [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f] Return a derivation that builds a raw initrd. @var{file-systems} is a list of file systems to be mounted by the initrd, possibly in addition to @@ -22983,6 +23002,12 @@ the root file system specified on the kernel command line via @code{--root}. include @code{e2fsck/static} or other packages needed by the initrd to check the root file system. +When true, @var{keyboard-layout} is a @code{} record denoting +the desired console keyboard layout. This is done before @var{mapped-devices} +are set up and before @var{file-systems} are mounted such that, should the +user need to enter a passphrase or use the REPL, this happens using the +intended keyboard layout. + When @var{qemu-networking?} is true, set up networking with the standard QEMU parameters. When @var{virtio?} is true, load additional modules so that the initrd can be used as a QEMU guest with para-virtualized I/O drivers. @@ -22992,7 +23017,8 @@ to it are lost. @end deffn @deffn {Scheme Procedure} base-initrd @var{file-systems} @ - [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@ + [#:mapped-devices '()] [#:keyboard-layout #f] @ + [#:qemu-networking? #f] [#:volatile-root? #f] @ [#:linux-modules '()] Return as a file-like object a generic initrd, with kernel modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be @@ -23000,6 +23026,12 @@ mounted by the initrd, possibly in addition to the root file system specified on the kernel command line via @code{--root}. @var{mapped-devices} is a list of device mappings to realize before @var{file-systems} are mounted. +When true, @var{keyboard-layout} is a @code{} record denoting +the desired console keyboard layout. This is done before @var{mapped-devices} +are set up and before @var{file-systems} are mounted such that, should the +user need to enter a passphrase or use the REPL, this happens using the +intended keyboard layout. + @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}. The initrd is automatically populated with all the kernel modules necessary diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm index 44b3506284..a35d18ad7c 100644 --- a/gnu/build/linux-boot.scm +++ b/gnu/build/linux-boot.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès ;;; Copyright © 2017 Mathieu Othacehe ;;; ;;; This file is part of GNU Guix. @@ -437,6 +437,7 @@ bailing out.~%root contents: ~s~%" (scandir "/")) (define* (boot-system #:key (linux-modules '()) linux-module-directory + keymap-file qemu-guest-networking? volatile-root? pre-mount @@ -444,7 +445,8 @@ bailing out.~%root contents: ~s~%" (scandir "/")) (on-error 'debug)) "This procedure is meant to be called from an initrd. Boot a system by first loading LINUX-MODULES (a list of module names) from -LINUX-MODULE-DIRECTORY, then setting up QEMU guest networking if +LINUX-MODULE-DIRECTORY, then installing KEYMAP-FILE with 'loadkeys' (if +KEYMAP-FILE is true), then setting up QEMU guest networking if QEMU-GUEST-NETWORKING? is true, calling PRE-MOUNT, mounting the file systems specified in MOUNTS, and finally booting into the new root if any. The initrd supports kernel command-line options '--load', '--root', and '--repl'. @@ -491,6 +493,15 @@ upon error." #:lookup-module lookup-module) (map lookup-module linux-modules)) + (when keymap-file + (let ((status (system* "loadkeys" keymap-file))) + (unless (zero? status) + ;; Emit a warning rather than abort when we cannot load + ;; KEYMAP-FILE. + (format (current-error-port) + "warning: 'loadkeys' exited with status ~a~%" + status)))) + (when qemu-guest-networking? (unless (configure-qemu-networking) (display "network interface is DOWN\n"))) diff --git a/gnu/system.scm b/gnu/system.scm index e6c86cb9ba..d25eb40325 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès ;;; Copyright © 2015 Mark H Weaver ;;; Copyright © 2015, 2016 Alex Kost ;;; Copyright © 2016 Chris Marusich @@ -157,6 +157,8 @@ (default '())) ; list of gexps/strings (bootloader operating-system-bootloader) ; + (keyboard-layout operating-system-keyboard-layout ;#f | + (default #f)) (initrd operating-system-initrd ; (list fs) -> file-like (default base-initrd)) (initrd-modules operating-system-initrd-modules ; list of strings @@ -878,7 +880,8 @@ hardware-related operations as necessary when booting a Linux container." #:linux (operating-system-kernel os) #:linux-modules (operating-system-initrd-modules os) - #:mapped-devices mapped-devices)) + #:mapped-devices mapped-devices + #:keyboard-layout (operating-system-keyboard-layout os))) (define (locale-name->definition* name) "Variant of 'locale-name->definition' that raises an error upon failure." diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 983c6d81c8..656afd1ddb 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès ;;; Copyright © 2016 Mark H Weaver ;;; Copyright © 2016 Jan Nieuwenhuizen ;;; Copyright © 2017 Mathieu Othacehe @@ -31,10 +31,13 @@ #:use-module (gnu packages disk) #:use-module (gnu packages linux) #:use-module (gnu packages guile) + #:use-module ((gnu packages xorg) + #:select (console-setup xkeyboard-config)) #:use-module ((gnu packages make-bootstrap) #:select (%guile-static-stripped)) #:use-module (gnu system file-systems) #:use-module (gnu system mapped-devices) + #:use-module (gnu system keyboard) #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (ice-9 vlist) @@ -139,6 +142,7 @@ MODULES and taken from LINUX." (linux linux-libre) (linux-modules '()) (mapped-devices '()) + (keyboard-layout #f) (helper-packages '()) qemu-networking? volatile-root? @@ -152,6 +156,11 @@ mappings to realize before FILE-SYSTEMS are mounted. HELPER-PACKAGES is a list of packages to be copied in the initrd. It may include e2fsck/static or other packages needed by the initrd to check root partition. +When true, KEYBOARD-LAYOUT is a record denoting the desired +console keyboard layout. This is done before MAPPED-DEVICES are set up and +before FILE-SYSTEMS are mounted such that, should the user need to enter a +passphrase or use the REPL, this happens using the intended keyboard layout. + When QEMU-NETWORKING? is true, set up networking with the standard QEMU parameters. @@ -206,6 +215,8 @@ upon error." (and #$@device-mapping-commands)) #:linux-modules '#$linux-modules #:linux-module-directory '#$kodir + #:keymap-file #+(and=> keyboard-layout + keyboard-layout->console-keymap) #:qemu-guest-networking? #$qemu-networking? #:volatile-root? '#$volatile-root? #:on-error '#$on-error))) @@ -290,6 +301,7 @@ FILE-SYSTEMS." (linux linux-libre) (linux-modules '()) (mapped-devices '()) + (keyboard-layout #f) qemu-networking? volatile-root? (extra-modules '()) ;deprecated @@ -300,6 +312,11 @@ mounted by the initrd, possibly in addition to the root file system specified on the kernel command line via '--root'. MAPPED-DEVICES is a list of device mappings to realize before FILE-SYSTEMS are mounted. +When true, KEYBOARD-LAYOUT is a record denoting the desired +console keyboard layout. This is done before MAPPED-DEVICES are set up and +before FILE-SYSTEMS are mounted such that, should the user need to enter a +passphrase or use the REPL, this happens using the intended keyboard layout. + QEMU-NETWORKING? and VOLATILE-ROOT? behaves as in raw-initrd. The initrd is automatically populated with all the kernel modules necessary @@ -316,13 +333,18 @@ loaded at boot time in the order in which they appear." ,@extra-modules)) (define helper-packages - (file-system-packages file-systems #:volatile-root? volatile-root?)) + (append (file-system-packages file-systems + #:volatile-root? volatile-root?) + (if keyboard-layout + (list loadkeys-static) + '()))) (raw-initrd file-systems #:linux linux #:linux-modules linux-modules* #:mapped-devices mapped-devices #:helper-packages helper-packages + #:keyboard-layout keyboard-layout #:qemu-networking? qemu-networking? #:volatile-root? volatile-root? #:on-error on-error))