From patchwork Thu Oct 31 21:15:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Herman Rimm X-Patchwork-Id: 69715 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 1980F27BBE9; Thu, 31 Oct 2024 21:17:30 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B073627BBE2 for ; Thu, 31 Oct 2024 21:17:27 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6cXU-0005Hd-9g; Thu, 31 Oct 2024 17:17:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6cXP-0005HA-LS for guix-patches@gnu.org; Thu, 31 Oct 2024 17:17:03 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t6cXP-0006OZ-D1 for guix-patches@gnu.org; Thu, 31 Oct 2024 17:17:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=zCCRAJucOJvNVxoBexJZtBKSVI+lZAKCgggQbZi3iDI=; b=Hti5NLwjKrjJURefH3Y8y/zYLVMpzAmO+oVRGYLRCeeDEG6CjM3Y3geaMGPsRkMXYgIGA5T3Vg6aw6od8J4YJNxHwzUMiHGUX8/2XPQ7+F8VSE4CgCvOMagw7y5hRRXsglqGolsEiBAn9upPR+lUFfPaPuHyOXUXNdHKaPefA5CVa1NTkjJ5Pj4awyLSLQ/dOSFoKtFLKaKu7OSiqScA1XurMCZAKc2WYW/IShEGV281A2RebadEyfxbxOnQKbofuq6tz/PxuE/qREDegft9uP15clvxsUGs3/IM42MHo8z8gBiz5MMqA+AvTnz28FdOpln/IX1x1wINr2CmRnod4Q==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6cXO-0000xR-TA for guix-patches@gnu.org; Thu, 31 Oct 2024 17:17:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#74109] [PATCH v2 1/2] gnu: bootloader: grub: Add procedure to share EFI installer code. Resent-From: Herman Rimm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 31 Oct 2024 21:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74109 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74109@debbugs.gnu.org Received: via spool by 74109-submit@debbugs.gnu.org id=B74109.17304094083645 (code B ref 74109); Thu, 31 Oct 2024 21:17:02 +0000 Received: (at 74109) by debbugs.gnu.org; 31 Oct 2024 21:16:48 +0000 Received: from localhost ([127.0.0.1]:44366 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6cX9-0000wi-Mg for submit@debbugs.gnu.org; Thu, 31 Oct 2024 17:16:48 -0400 Received: from 81-205-150-117.fixed.kpn.net ([81.205.150.117]:43653 helo=email.rimm.ee) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6cX4-0000w4-1u for 74109@debbugs.gnu.org; Thu, 31 Oct 2024 17:16:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rimm.ee; s=herman; t=1730409393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F07iECtxj+QLyYfw7XbWDwKwgq+iJdg/iJpNuF1IXp4=; b=fCOGNcReMH2ooE4MqkSjTQA7hq2qwxxb83MvO0rIfaZE5/oUH9U4akvUZc/61wMhM4fq9A 9QgxibOG/Q5JtCcImr/McKI2qWWxn1vz/8CHERoS4bE+H4jEw4f7q2T0Hpt9//ZDDs63Xp w1FWq/rmPy9R44ZxI31M24hmg0jcqOHYUWM/6bCUIfqMwY/WAFVU5l3S5dkoj5AepcJBWc XgCorlGzzswPpLhIOI9uKyXvwcotk/y+Di7yf1yeQPwsk7hGyQouBr+XGQkfBIWdNEe5Jz ezqvY0mBo27asetSv6nYhuXqIBSDDl32C2qYkOh2hvxQCD2KoDTwQCJmHkBUpA== Received: by 81-205-150-117.fixed.kpn.net (OpenSMTPD) with ESMTPSA id c3772a9a (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO) for <74109@debbugs.gnu.org>; Thu, 31 Oct 2024 21:16:33 +0000 (UTC) Date: Thu, 31 Oct 2024 22:15:49 +0100 Message-ID: <7eaba6235cafeccce847e9e0e3ed523bafb23930.1730408855.git.herman@rimm.ee> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Herman Rimm X-ACL-Warn: , Herman Rimm via Guix-patches X-Patchwork-Original-From: Herman Rimm via Guix-patches via From: Herman Rimm Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/bootloader/grub.scm (make-grub-efi-bootloader): Add procedure. (install-grub-efi, install-grub-efi32): Remove variables. (install-grub-efi-removable): Deprecate variable. Change-Id: Ie10b506bb1088179d459ddafe3229fd730ac45aa --- gnu/bootloader/grub.scm | 83 ++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 55 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 2723eda5f4..f4a197567e 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -10,6 +10,7 @@ ;;; Copyright © 2022 Karl Hallsby ;;; Copyright © 2022 Denis 'GNUtoo' Carikli ;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz> +;;; Copyright © 2024 Herman Rimm ;;; ;;; This file is part of GNU Guix. ;;; @@ -28,6 +29,7 @@ (define-module (gnu bootloader grub) #:use-module (guix build union) + #:use-module (guix deprecation) #:use-module (guix records) #:use-module (guix store) #:use-module (guix utils) @@ -54,6 +56,7 @@ (define-module (gnu bootloader grub) grub-theme-gfxmode install-grub-efi-removable + make-grub-efi-installer make-grub-efi-netboot-installer grub-bootloader @@ -621,7 +624,16 @@ (define install-grub-disk-image "-d" "." image)))) -(define install-grub-efi +(define* (make-grub-efi-installer #:key efi32? removable?) + "Return a G-expression of a procedure for installing GRUB on a UEFI +system. If EFI32? is #t, then a 32-bit target will be used. If +REMOVABLE? is #t, GRUB will be installed for Removable Media Boot." + (define extra-args + (list (and efi32? + #~(cond ((target-x86?) "--target=i386-efi") + ((target-arm?) "--target=arm-efi"))) + ;; This does not update UEFI boot entries, like --no-nvram. + (and removable? "--removable"))) #~(lambda (bootloader efi-dir mount-point) ;; There is nothing useful to do when called in the context of a disk ;; image generation. @@ -638,57 +650,10 @@ (define install-grub-efi ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or ;; root partition. (setenv "GRUB_ENABLE_CRYPTODISK" "y") - (invoke/quiet grub-install "--boot-directory" install-dir - "--bootloader-id=Guix" - "--efi-directory" target-esp))))) - -(define install-grub-efi-removable - #~(lambda (bootloader efi-dir mount-point) - ;; NOTE: mount-point is /mnt in guix system init /etc/config.scm /mnt/point - ;; NOTE: efi-dir comes from target list of booloader configuration - ;; There is nothing useful to do when called in the context of a disk - ;; image generation. - (when efi-dir - ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the - ;; system whose root is mounted at MOUNT-POINT. - (let ((grub-install (string-append bootloader "/sbin/grub-install")) - (install-dir (string-append mount-point "/boot")) - ;; When installing Guix, it's common to mount EFI-DIR below - ;; MOUNT-POINT rather than /boot/efi on the live image. - (target-esp (if (file-exists? (string-append mount-point efi-dir)) - (string-append mount-point efi-dir) - efi-dir))) - ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or - ;; root partition. - (setenv "GRUB_ENABLE_CRYPTODISK" "y") - (invoke/quiet grub-install "--boot-directory" install-dir - "--removable" - ;; "--no-nvram" - "--bootloader-id=Guix" - "--efi-directory" target-esp))))) - -(define install-grub-efi32 - #~(lambda (bootloader efi-dir mount-point) - ;; There is nothing useful to do when called in the context of a disk - ;; image generation. - (when efi-dir - ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the - ;; system whose root is mounted at MOUNT-POINT. - (let ((grub-install (string-append bootloader "/sbin/grub-install")) - (install-dir (string-append mount-point "/boot")) - ;; When installing Guix, it's common to mount EFI-DIR below - ;; MOUNT-POINT rather than /boot/efi on the live image. - (target-esp (if (file-exists? (string-append mount-point efi-dir)) - (string-append mount-point efi-dir) - efi-dir))) - ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or - ;; root partition. - (setenv "GRUB_ENABLE_CRYPTODISK" "y") - (invoke/quiet grub-install "--boot-directory" install-dir - "--bootloader-id=Guix" - (cond ((target-x86?) "--target=i386-efi") - ((target-arm?) "--target=arm-efi")) - "--efi-directory" target-esp))))) + (invoke/quiet grub-install "--bootloader-id=Guix" + "--boot-directory" install-dir + "--efi-directory" target-esp + #$@(filter identity extra-args)))))) (define* (make-grub-efi-netboot-installer grub-efi grub-cfg subdir) "Make a bootloader-installer for a grub-efi-netboot bootloader, which expects @@ -849,7 +814,7 @@ (define grub-efi-bootloader (bootloader (name 'grub-efi) (package grub-efi) - (installer install-grub-efi) + (installer (make-grub-efi-installer)) (disk-image-installer #f) (configuration-file grub-cfg) (configuration-file-generator grub-configuration-file))) @@ -858,12 +823,12 @@ (define grub-efi-removable-bootloader (bootloader (inherit grub-efi-bootloader) (name 'grub-efi-removable-bootloader) - (installer install-grub-efi-removable))) + (installer (make-grub-efi-installer #:removable? #t)))) (define grub-efi32-bootloader (bootloader (inherit grub-efi-bootloader) - (installer install-grub-efi32) + (installer (make-grub-efi-installer #:efi32? #t)) (name 'grub-efi32) (package grub-efi32))) @@ -909,4 +874,12 @@ (define-syntax grub-configuration (bootloader grub-bootloader) fields ...)))) + +;;; +;;; Deprecated bootloader and installer variables. +;;; + +(define-deprecated/alias install-grub-efi-removable + (make-grub-efi-installer #:removable? #t)) + ;;; grub.scm ends here