From patchwork Wed Oct 30 15:01:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herman Rimm X-Patchwork-Id: 69651 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 AA7F627BBE9; Wed, 30 Oct 2024 15:03:23 +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 7952A27BBE2 for ; Wed, 30 Oct 2024 15:03:20 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6ADw-0000XF-WD; Wed, 30 Oct 2024 11:03:05 -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 1t6ADu-0000Wq-OU for guix-patches@gnu.org; Wed, 30 Oct 2024 11:03:02 -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 1t6ADu-0007ND-El for guix-patches@gnu.org; Wed, 30 Oct 2024 11:03:02 -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:Date:From:To:Subject; bh=csqvVs+3VmLAxsRkYi5Z9DAg31KF8J89PnJ6bDQWHWw=; b=BFLgGGWSWJHQFgXEtcxENYX0rzu+9Zi8sjWV//Z4z90bD210Iar21/Sm9IvrnY3/BIRcQnlbNnZzFY8OnoI8fJQ9ros0fB5yddtjQ+7GptY01UWj0j3xBZJ5nJhB0P5caXfSrvackOLOF0xwV/r91hI14gkQbLORAM4GWeb054zgdpP2ZGMHlWwmGCy6jHjaroC4smiIlizzsCP/AZ/ad9K25JHuuHeLX/rYnrguy27le45YEKbXOdSA/3r4V7Acbmf9kXi6Uvn5pwOid9vNtgSckBjNFLzqUNQqYQm6TsPZzUogYq4euOqRpLZdIwN94X+sqHq92bwiIzK8PdGJeg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6ADu-00050r-9P for guix-patches@gnu.org; Wed, 30 Oct 2024 11:03:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#74109] [PATCH] 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: Wed, 30 Oct 2024 15:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74109 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74109@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.173030053019227 (code B ref -1); Wed, 30 Oct 2024 15:03:02 +0000 Received: (at submit) by debbugs.gnu.org; 30 Oct 2024 15:02:10 +0000 Received: from localhost ([127.0.0.1]:35528 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6AD3-000503-Ur for submit@debbugs.gnu.org; Wed, 30 Oct 2024 11:02:10 -0400 Received: from lists.gnu.org ([209.51.188.17]:40462) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6AD2-0004zu-QP for submit@debbugs.gnu.org; Wed, 30 Oct 2024 11:02:09 -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 1t6AD1-0000UF-9f for guix-patches@gnu.org; Wed, 30 Oct 2024 11:02:08 -0400 Received: from 81-205-150-117.fixed.kpn.net ([81.205.150.117] helo=email.rimm.ee) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1t6ACz-0007Iv-6v for guix-patches@gnu.org; Wed, 30 Oct 2024 11:02:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rimm.ee; s=herman; t=1730300512; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hjV/Wav+KbPMyyHm3SqJdWbUPxbTJrR3Ml2xTATln2M=; b=bKtFUOP9WKamK8qUe/Ot+cJOElv6VZwZ6TbxZAMvC4B0lg78Xs0ielSRbLJEOEkMkCELtk sdzxUMdHbsKqfFpdcnxSbX7h/G1R6Id2F//Q3i7pwdIVITb3hvcRTYGTsO6iMJBKVueko6 elHtlY+Hy5Al8tXMxG1qj4wukItVXTgrl0L741MNwmgMwxrJQpdzU9d9JDdg6sKNV/jWzw r94X4ydrOhYa3vk0TNSPpAaNUZtn8Ohvxl1aPKj61QzPZxGoRkiHgeKuwOpW34ET7d3g1y eGvQfmjMpeyBBm7rPKEIr6V0iBU9LBgRLeK8l7zAONo8XC982s3an40jIM6blA== Received: by 81-205-150-117.fixed.kpn.net (OpenSMTPD) with ESMTPSA id 74133844 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO) for ; Wed, 30 Oct 2024 15:01:51 +0000 (UTC) Date: Wed, 30 Oct 2024 16:01:11 +0100 Message-ID: <0d64318889bc98bd9b59d72676641a3914ffed3e.1730300346.git.herman@rimm.ee> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Received-SPF: pass client-ip=81.205.150.117; envelope-from=herman@rimm.ee; helo=email.rimm.ee X-Spam_score_int: 16 X-Spam_score: 1.6 X-Spam_bar: + X-Spam_report: (1.6 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_PBL=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_RCVD_IP=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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 | 82 ++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 55 deletions(-) base-commit: d6f775c30c6f47e174f6110d1089edc6315600e4 diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 2723eda5f4..4933bdcff0 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -28,6 +28,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 +55,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 +623,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 +649,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 +813,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 +822,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 +873,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