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 bIJCEtN1U1+NLQAA0tVLHw (envelope-from ) for ; Sat, 05 Sep 2020 11:26:11 +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 EGi2DdN1U19GIAAAbx9fmQ (envelope-from ) for ; Sat, 05 Sep 2020 11:26:11 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.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 C688F9404C7 for ; Sat, 5 Sep 2020 11:26:10 +0000 (UTC) Received: from localhost ([::1]:44710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEWKf-0004ZX-QU for larch@yhetil.org; Sat, 05 Sep 2020 07:26:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEWKY-0004SW-Ji for guix-patches@gnu.org; Sat, 05 Sep 2020 07:26:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kEWKY-0000cq-Ar for guix-patches@gnu.org; Sat, 05 Sep 2020 07:26:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kEWKY-0003eZ-7C for guix-patches@gnu.org; Sat, 05 Sep 2020 07:26:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41011] [PATCH] gnu: grub: Support for network boot via tftp/nfs. References: <9AAFEFF4-8ACE-4C95-975F-67C3F4FDAF81@vodafonemail.de> In-Reply-To: <9AAFEFF4-8ACE-4C95-975F-67C3F4FDAF81@vodafonemail.de> Resent-From: Stefan Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 05 Sep 2020 11:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41011 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41011@debbugs.gnu.org Received: via spool by 41011-submit@debbugs.gnu.org id=B41011.159930513514008 (code B ref 41011); Sat, 05 Sep 2020 11:26:02 +0000 Received: (at 41011) by debbugs.gnu.org; 5 Sep 2020 11:25:35 +0000 Received: from localhost ([127.0.0.1]:41623 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kEWK7-0003dr-Hl for submit@debbugs.gnu.org; Sat, 05 Sep 2020 07:25:35 -0400 Received: from vsmx011.vodafonemail.xion.oxcs.net ([153.92.174.89]:26230) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kEWK6-0003de-67 for 41011@debbugs.gnu.org; Sat, 05 Sep 2020 07:25:35 -0400 Received: from vsmx003.vodafonemail.xion.oxcs.net (unknown [192.168.75.197]) by mta-5-out.mta.xion.oxcs.net (Postfix) with ESMTP id E02B159D61A for <41011@debbugs.gnu.org>; Sat, 5 Sep 2020 11:25:27 +0000 (UTC) Received: from macbook-pro.kuh-wiese.my-router.de (unknown [178.5.77.113]) by mta-7-out.mta.xion.oxcs.net (Postfix) with ESMTPA id 96535539AB9 for <41011@debbugs.gnu.org>; Sat, 5 Sep 2020 11:25:25 +0000 (UTC) From: Stefan Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: Date: Sat, 5 Sep 2020 13:25:24 +0200 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) X-VADE-STATUS: LEGIT X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.7 (-) 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 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -0.51 X-TUID: jmZzai/kXQ1l * gnu/bootloader/grub.scm (grub-net-bootloader): New bootloader for network booting via tftp. (install-grub-net): New bootloader installer for tftp. --- gnu/bootloader/grub.scm | 79 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 4 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index b905ae360c..8f078dc2ac 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -24,7 +24,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) @@ -46,8 +46,11 @@ grub-theme-color-highlight grub-theme-gfxmode =20 + install-grub-net + grub-bootloader grub-efi-bootloader + grub-net-bootloader grub-mkrescue-bootloader grub-minimal-bootloader =20 @@ -501,11 +504,73 @@ fi~%")))) "--bootloader-id=3DGuix" "--efi-directory" target-esp)))) =20 +(define (install-grub-net subdir) + "Define a grub-net bootloader installer for installation in SUBDIR, +which is usually \"efi/boot\" or \"efi/Guix\"." + (let* ((arch (car (string-split (or (%current-target-system) + (%current-system)) + #\-))) + (efi-bootloader-link (string-append "/boot" + (match arch + ("i686" "ia32") + ("x86_64" "x64") + ("arm" "arm") + ("armhf" "arm") + ("aarch64" "aa64") + ("riscv" "riscv32") + ("riscv64" "riscv64")) + ".efi")) + (efi-bootloader (string-append (match arch + ("i686" "i386") + ("x86_64" "x86_64") + ("arm" "arm") + ("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 +SUBDIR, which is usually \"efi/boot\" or \"efi/Guix\" below the = directory TARGET +for the system whose root is mounted at MOUNT-POINT." + (let* (;; Use target-depth and subdir-depth to construct links = to + ;; "../gnu" and "../../../boot/grub/grub.cfg" with the = correct + ;; number of "../". Note: This doesn't consider ".." or = ".", + ;; which may appear inside target or subdir. + (target-depth (length (delete "" (string-split target = #\/)))) + (subdir-depth (length (delete "" (string-split #$subdir = #\/)))) + (up1 (string-join (make-list target-depth "..") "/" = 'suffix)) + (up2 (string-join (make-list subdir-depth "..") "/" = 'suffix)) + (net-dir (string-append mount-point target "/")) + (store-name (car (delete "" (string-split bootloader = #\/)))) + (store (string-append up1 store-name)) + (store-link (string-append net-dir store-name)) + (grub-cfg (string-append up1 up2 "boot/grub/grub.cfg")) + (grub-cfg-link (string-append net-dir #$subdir = "/grub.cfg")) + (efi-bootloader-link + (string-append net-dir #$subdir = #$efi-bootloader-link))) + ;; 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)) + (false-if-exception (delete-file store-link)) + (symlink store store-link) + (false-if-exception (delete-file grub-cfg-link)) + (symlink grub-cfg grub-cfg-link) + (false-if-exception (delete-file efi-bootloader-link)) + (symlink #$efi-bootloader efi-bootloader-link))))) + ^L =20 ;;; ;;; Bootloader definitions. ;;; +;;; For all these grub-bootloader variables the path to = /boot/grub/grub.cfg +;;; is fixed. Inheriting and overwriting the field = 'configuration-file' will +;;; break 'guix system delete-generations', 'guix system = switch-generation', +;;; and 'guix system roll-back'. =20 (define grub-bootloader (bootloader @@ -516,12 +581,12 @@ fi~%")))) (configuration-file "/boot/grub/grub.cfg") (configuration-file-generator grub-configuration-file))) =20 -(define* grub-minimal-bootloader +(define grub-minimal-bootloader (bootloader (inherit grub-bootloader) (package grub-minimal))) =20 -(define* grub-efi-bootloader +(define grub-efi-bootloader (bootloader (inherit grub-bootloader) (installer install-grub-efi) @@ -529,7 +594,13 @@ fi~%")))) (name 'grub-efi) (package grub-efi))) =20 -(define* grub-mkrescue-bootloader +(define grub-net-bootloader + (bootloader + (inherit grub-efi-bootloader) + (name 'grub-net-bootloader) + (installer (install-grub-net "efi/Guix")))) + +(define grub-mkrescue-bootloader (bootloader (inherit grub-efi-bootloader) (package grub-hybrid))) --=20 2.26.0