From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KKWyOXyHrF6DbgAA0tVLHw (envelope-from ) for ; Fri, 01 May 2020 20:33:00 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id iBqCOoaHrF4gWQAAbx9fmQ (envelope-from ) for ; Fri, 01 May 2020 20:33:10 +0000 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EDB39942388 for ; Fri, 1 May 2020 20:33:08 +0000 (UTC) Received: from localhost ([::1]:50256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUcLN-0006oj-1l for larch@yhetil.org; Fri, 01 May 2020 16:33:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUcLH-0006oM-Sr for guix-patches@gnu.org; Fri, 01 May 2020 16:33:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUcLH-00038i-8I for guix-patches@gnu.org; Fri, 01 May 2020 16:33:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39212) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jUcLG-00037p-Rc for guix-patches@gnu.org; Fri, 01 May 2020 16:33:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jUcLG-0006Bj-MQ for guix-patches@gnu.org; Fri, 01 May 2020 16:33:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41011] [PATCH] gnu: grub: Support for network boot via tftp/nfs. Resent-From: Stefan Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 01 May 2020 20:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41011 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41011@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.158836517823775 (code B ref -1); Fri, 01 May 2020 20:33:02 +0000 Received: (at submit) by debbugs.gnu.org; 1 May 2020 20:32:58 +0000 Received: from localhost ([127.0.0.1]:50758 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUcLC-0006BO-Aa for submit@debbugs.gnu.org; Fri, 01 May 2020 16:32:58 -0400 Received: from lists.gnu.org ([209.51.188.17]:55530) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUcLA-0006BG-WD for submit@debbugs.gnu.org; Fri, 01 May 2020 16:32:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUcLA-0006mW-1U for guix-patches@gnu.org; Fri, 01 May 2020 16:32:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUcL8-0002oR-5E for guix-patches@gnu.org; Fri, 01 May 2020 16:32:55 -0400 Received: from vsmx012.vodafonemail.xion.oxcs.net ([153.92.174.90]:14985) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUcL7-0002bE-EL for guix-patches@gnu.org; Fri, 01 May 2020 16:32:53 -0400 Received: from vsmx004.vodafonemail.xion.oxcs.net (unknown [192.168.75.198]) by mta-8-out.mta.xion.oxcs.net (Postfix) with ESMTP id 288B9F35070 for ; Fri, 1 May 2020 20:32:47 +0000 (UTC) Received: from macbook-pro.kuh-wiese.my-router.de (unknown [90.186.146.133]) by mta-8-out.mta.xion.oxcs.net (Postfix) with ESMTPA id F072D19AE34 for ; Fri, 1 May 2020 20:32:44 +0000 (UTC) From: Stefan Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: <9AAFEFF4-8ACE-4C95-975F-67C3F4FDAF81@vodafonemail.de> Date: Fri, 1 May 2020 22:32:44 +0200 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) X-VADE-STATUS: LEGIT X-VADE-SCORE: 0 X-VADE-REASON: gggruggvucftvghtrhhoucdtuddrgeduhedrieejgddugeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuvegfuffvqffogfftpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhtgfguffkfffvggfosehtqhhmtdhhtddvnecuhfhrohhmpefuthgvfhgrnhcuoehsthgvfhgrnhdqghhuihigsehvohgurghfohhnvghmrghilhdruggvqeenucggtffrrghtthgvrhhnpeeutdeliefgfedvheejhfekvedtgfegiefhgeehheffgfffhfdvjeejhfelgfevffenucfkphepledtrddukeeirddugeeirddufeefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopehmrggtsghoohhkqdhprhhordhkuhhhqdifihgvshgvrdhmhidqrhhouhhtvghrrdguvgdpihhnvghtpeeltddrudekiedrudegiedrudeffedpmhgrihhlfhhrohhmpehsthgvfhgrnhdqghhuihigsehvohgurghfohhnvghmrghilhdruggvpdhrtghpthhtohepghhuihigqdhprghttghhvghssehgnhhurdhorhhg Received-SPF: pass client-ip=153.92.174.90; envelope-from=stefan-guix@vodafonemail.de; helo=vsmx012.vodafonemail.xion.oxcs.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/01 16:32:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 X-Spam-Score: -0.51 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Scan-Result: default: False [-0.51 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.49530464255682]; DWL_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; MV_CASE(0.50)[]; RCVD_COUNT_TWELVE(0.00)[13]; TO_DN_NONE(0.00)[]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.16), country: US(-0.00), ip: 2001:470:142::17(-0.50)]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[90.186.146.133:received]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:22989, ipnet:2001:470:142::/48, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[stefan-guix@vodafonemail.de,guix-patches-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[vodafonemail.de]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; DNSWL_BLOCKED(0.00)[2001:470:142::17:from]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: jVk2d7L1nV9T * gnu/bootloader/grub.scm (grub-efi-net-bootloader): New efi bootloader = for network booting via tftp/nfs and possibly images, prepared for chain = loading. (install-grub-efi-net): New bootloader installer for tftp and possibly = images, does not need root rights. (grub-root-search): Adding support for tftp root. (eye-candy): Enable gfxterm support for all systems. * gnu/system.scm (read-boot-parameters): Prevent devices with ":/" from = being treated as a file system label. --- gnu/bootloader/grub.scm | 107 +++++++++++++++++++++++++++++++--------- gnu/system.scm | 3 +- 2 files changed, 86 insertions(+), 24 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 190b717163..9ca4f016f6 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -23,7 +23,7 @@ =20 (define-module (gnu bootloader grub) #:use-module (guix records) - #:use-module ((guix utils) #:select (%current-system)) + #:use-module ((guix utils) #:select (%current-system = %current-target-system)) #:use-module (guix gexp) #:use-module (gnu artwork) #:use-module (gnu bootloader) @@ -53,6 +53,7 @@ =20 grub-bootloader grub-efi-bootloader + grub-efi-net-bootloader grub-mkrescue-bootloader =20 grub-configuration)) @@ -142,34 +143,20 @@ WIDTH/HEIGHT, or #f if none was found." #:width width #:height height)))) =20 (define* (eye-candy config store-device store-mount-point - #:key system port) + #:key port) "Return a gexp that writes to PORT (a port-valued gexp) the 'grub.cfg' part concerned with graphics mode, background images, = colors, and all that. STORE-DEVICE designates the device holding the store, and STORE-MOUNT-POINT is its mount point; these are used to determine where = the -background image and fonts must be searched for. SYSTEM must be the = target -system string---e.g., \"x86_64-linux\"." +background image and fonts must be searched for." (define setup-gfxterm-body - (let ((gfxmode - (or (and-let* ((theme (bootloader-configuration-theme = config)) - (gfxmode (grub-gfxmode theme))) - (string-join gfxmode ";")) - "auto"))) - - ;; Intel and EFI systems need to be switched into graphics mode, = whereas - ;; most other modern architectures have no other mode and = therefore - ;; don't need to be switched. - - ;; XXX: Do we really need to restrict to x86 systems? We could = imitate - ;; what the GRUB default configuration does and decide based on = whether - ;; a user provided 'gfxterm' in the terminal-outputs field of = their - ;; bootloader-configuration record. - (if (string-match "^(x86_64|i[3-6]86)-" system) - (format #f " + (format #f " set gfxmode=3D~a insmod all_video - insmod gfxterm~%" gfxmode) - ""))) + insmod gfxterm~%" + (string-join + (grub-gfxmode (bootloader-theme config)) + ";"))) =20 (define (setup-gfxterm config font-file) (if (memq 'gfxterm (bootloader-configuration-terminal-outputs = config)) @@ -316,6 +303,9 @@ code." ((? file-system-label? label) (format #f "search --label --set ~a" (file-system-label->string label))) + ((? (lambda (device) + (and (string? device) (string-contains device ":/"))) = nfs-uri) + "set root=3D(tftp)") ((or #f (? string?)) #~(format #f "search --file --set ~a" #$file))))) =20 @@ -355,7 +345,6 @@ entries corresponding to old generations of the = system." (eye-candy config (menu-entry-device (first all-entries)) (menu-entry-device-mount-point (first all-entries)) - #:system system #:port #~port)) =20 (define keyboard-layout-config @@ -443,6 +432,68 @@ fi~%")))) "--bootloader-id=3DGuix" "--efi-directory" target-esp)))) =20 +(define (install-grub-efi-net efi-subdir) + "Define a grub-efi bootloader installer for installation in = EFI-SUBDIR, +which is usually \"efi/guix\" or \"efi/boot\"." + (let* ((arch (car (string-split (or (%current-target-system) + (%current-system)) + #\-))) + (efi-bootloader-link (string-append "boot" + (match arch + ("i686" "ia32") + ("x86_64" "x64") + ("armhf" "arm") + ("aarch64" "aa64") + ("riscv" "riscv32") + ("riscv64" "riscv64")) + ".efi")) + (efi-bootloader (string-append (match arch + ("i686" "i386") + ("x86_64" "x86_64") + ("armhf" "arm") + ("aarch64" "arm64") + ("riscv" "riscv32") + ("riscv64" "riscv64")) + "-efi/core.efi"))) + #~(lambda (bootloader target mount-point) + "Install GRUB as e.g. \"bootx64.efi\" or \"bootarm64.efi\" = \"into +EFI-SUBDIR, which is usually \"efi/guix\" or \"efi/boot\" below the = directory +TARGET for the system whose root is mounted at MOUNT-POINT." + (let* ((mount-point-list (delete "" (string-split mount-point = #\/))) + (target-list (delete "" (string-split target #\/))) + (net-dir + (string-append "/" (string-join (append + mount-point-list + target-list) + "/"))) + (subdir #$efi-subdir) + (efi-bootloader-link + (string-append net-dir "/" subdir "/" = #$efi-bootloader-link)) + (store-name (car (delete "" (string-split bootloader = #\/)))) + (store + ;; Use target-list to construct a "../gnu" link with a = correct + ;; number of "../" to the store. + (string-join (append (make-list (length target-list) = "..") + (list store-name)) + "/")) + (store-link (string-append net-dir "/" store-name))) + ;; Tell 'grub-install' that there might be a LUKS-encrypted = /boot or + ;; root partition. + (setenv "GRUB_ENABLE_CRYPTODISK" "y") + (invoke/quiet (string-append bootloader "/bin/grub-mknetdir") + (string-append "--net-directory=3D" net-dir) + (string-append "--subdir=3D" subdir)) + (catch 'system-error + (lambda () (delete-file efi-bootloader-link)) + (lambda _ #f)) + (symlink #$efi-bootloader + efi-bootloader-link) + (catch 'system-error + (lambda () (delete-file store-link)) + (lambda _ #f)) + (symlink store + store-link))))) + ^L =20 ;;; @@ -464,6 +515,16 @@ fi~%")))) (name 'grub-efi) (package grub-efi))) =20 +(define* (grub-efi-net-bootloader #:key (target #f) (efi-subdir #f)) + (let ((target (or target "boot")) + (efi-subdir (or efi-subdir "efi/boot"))) + (bootloader + (inherit grub-bootloader) + (name 'grub-efi-net-bootloader) + (package grub-efi) + (installer (install-grub-efi-net efi-subdir)) + (configuration-file (string-append target "/" efi-subdir = "/grub.cfg"))))) + (define* grub-mkrescue-bootloader (bootloader (inherit grub-efi-bootloader) diff --git a/gnu/system.scm b/gnu/system.scm index 29e622872d..540f0e4a9e 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -297,7 +297,8 @@ file system labels." ((? string? device) ;; It used to be that we would not distinguish between labels = and ;; device names. Try to infer the right thing here. - (if (string-prefix? "/dev/" device) + (if (or (string-prefix? "/dev/" device) + (string-contains device ":/")) ; nfs device (file-system-label device))))) =20 --=20 2.26.0