GNU bug report logs - #67109
‘efi32-esp’ image support pulls in host-side code

Previous Next

Package: guix;

Reported by: Ludovic Courtès <ludovic.courtes <at> inria.fr>

Date: Sat, 11 Nov 2023 15:47:02 UTC

Severity: normal

To reply to this bug, email your comments to 67109 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to othacehe <at> gnu.org, GNUtoo <at> cyberdimension.org, bug-guix <at> gnu.org:
bug#67109; Package guix. (Sat, 11 Nov 2023 15:47:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludovic.courtes <at> inria.fr>:
New bug report received and forwarded. Copy sent to othacehe <at> gnu.org, GNUtoo <at> cyberdimension.org, bug-guix <at> gnu.org. (Sat, 11 Nov 2023 15:47:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludovic.courtes <at> inria.fr>
To: bug-guix <at> gnu.org
Subject: ‘efi32-esp’ image support pulls in host-side code
Date: Sat, 11 Nov 2023 16:45:09 +0100
[Message part 1 (text/plain, inline)]
Hello,

I noticed that 62c86c8391ceb8953ca972498fd75ea9298b85ff pulls in
host-side code on the “build side”, via (guix utils), meaning that the
closure of the (gnu build image) module would now include 80 modules.

This change also introduces uses of ‘target-x86?’ and ‘target-arm?’ on
the build side that are unlikely to have the intended effect because the
check is then done based on the native system type when running the
build process.  Last, the ‘cond’ form in that commit lacks an ‘else’
clause.

Thus I’m proposing the fix below.  How can I test it though?  I get:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix system image -t efi32-raw gnu/system/examples/bare-bones.tmpl
guix system: error: EFI bootloader required with GPT partitioning
--8<---------------cut here---------------end--------------->8---

Thanks in advance!

Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/gnu/build/image.scm b/gnu/build/image.scm
index 49dc01c0d1..63262a4ffe 100644
--- a/gnu/build/image.scm
+++ b/gnu/build/image.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2013-2020, 2023 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2016 Christine Lemmer-Webber <cwebber <at> dustycloud.org>
 ;;; Copyright © 2016, 2017 Leo Famulari <leo <at> famulari.name>
 ;;; Copyright © 2017 Marius Bakke <mbakke <at> fastmail.com>
@@ -29,7 +29,6 @@ (define-module (gnu build image)
   #:use-module (guix build syscalls)
   #:use-module (guix build utils)
   #:use-module (guix store database)
-  #:use-module (guix utils)
   #:use-module (gnu build bootloader)
   #:use-module (gnu build install)
   #:use-module (gnu build linux-boot)
@@ -191,13 +190,11 @@ (define* (initialize-efi-partition root
 (define* (initialize-efi32-partition root
                                      #:key
                                      grub-efi32
+                                     grub-targets
                                      #:allow-other-keys)
   "Install in ROOT directory, an EFI 32bit loader using GRUB-EFI32."
   (install-efi-loader grub-efi32 root
-                      #:targets (cond ((target-x86?)
-                                       '("i386-efi" . "BOOTIA32.EFI"))
-                                      ((target-arm?)
-                                       '("arm-efi" . "BOOTARM.EFI")))))
+                      #:targets grub-targets))
 
 (define* (initialize-root-partition root
                                     #:key
diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index a990c4f861..49d4287a74 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -136,7 +136,17 @@ (define esp-partition
 (define esp32-partition
   (partition
    (inherit esp-partition)
-   (initializer (gexp initialize-efi32-partition))))
+   (initializer
+    (let-system (system target)
+      (let ((targets (cond ((target-x86? (or target system))
+                            #~'("i386-efi" . "BOOTIA32.EFI"))
+                           ((target-arm? (or target system))
+                            #~'("arm-efi" . "BOOTARM.EFI"))
+                           (else #f))))
+        #~(lambda (root . args)
+            (apply initialize-efi32-partition root
+                   #:grub-targets #$targets
+                   args)))))))
 
 (define root-partition
   (partition

Information forwarded to bug-guix <at> gnu.org:
bug#67109; Package guix. (Tue, 14 Nov 2023 20:54:01 GMT) Full text and rfc822 format available.

Message #8 received at 67109 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: Ludovic Courtès <ludovic.courtes <at> inria.fr>
Cc: 67109 <at> debbugs.gnu.org, Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
Subject: Re: bug#67109: ‘efi32-esp’ image support pulls
 in host-side code
Date: Tue, 14 Nov 2023 21:52:35 +0100
Hey,

Thanks for investigating this!

> Thus I’m proposing the fix below.  How can I test it though?  I get:
>
> $ ./pre-inst-env guix system image -t efi32-raw gnu/system/examples/bare-bones.tmpl
> guix system: error: EFI bootloader required with GPT partitioning

I added this check recently because we do not currently support
installing the `grub-bootloader` on a non-MBR disk.

The way to test your change is to switch the bare-bones system
bootloader to `grub-efi-bootloader`, this way:

--8<---------------cut here---------------start------------->8---
diff --git a/gnu/system/examples/bare-bones.tmpl b/gnu/system/examples/bare-bones.tmpl
index dc6aff5273..e11d4bd5ee 100644
--- a/gnu/system/examples/bare-bones.tmpl
+++ b/gnu/system/examples/bare-bones.tmpl
@@ -18,8 +18,9 @@
   ;; target hard disk, and "my-root" is the label of the target
   ;; root file system.
   (bootloader (bootloader-configuration
-                (bootloader grub-bootloader)
-                (targets '("/dev/sdX"))))
+                (bootloader grub-efi-bootloader)
+                (targets '("/boot/efi"))))
--8<---------------cut here---------------end--------------->8---

We then have the following error:

--8<---------------cut here---------------start------------->8---
guix system: error: #<gexp (lambda (root . args) (apply initialize-efi32-partition root #:grub-targets #<gexp-input #<gexp (quote ("i386-efi" . "BOOTIA32.EFI")) gnu/system/image.scm:142:28 7fef96f85390>:out> args)) gnu/system/image.scm:146:8 7fef96f85360>: invalid G-expression input
--8<---------------cut here---------------end--------------->8---

Mathieu




Information forwarded to bug-guix <at> gnu.org:
bug#67109; Package guix. (Sat, 25 Nov 2023 14:34:02 GMT) Full text and rfc822 format available.

Message #11 received at 67109 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: Ludovic Courtès <ludovic.courtes <at> inria.fr>
Cc: 67109 <at> debbugs.gnu.org, Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
Subject: Re: bug#67109: ‘efi32-esp’ image support pulls
 in host-side code
Date: Sat, 25 Nov 2023 15:33:33 +0100
Hello,

> guix system: error: #<gexp (lambda (root . args) (apply
> initialize-efi32-partition root #:grub-targets #<gexp-input #<gexp
> (quote ("i386-efi" . "BOOTIA32.EFI")) gnu/system/image.scm:142:28
> 7fef96f85390>:out> args)) gnu/system/image.scm:146:8 7fef96f85360>:
> invalid G-expression input

Expressed that way, I no longer have this error and `target` seems to
take the expected value, WDYT?

--8<---------------cut here---------------start------------->8---
(define esp32-partition
  (partition
   (inherit esp-partition)
   (initializer
    #~(lambda (root . args)
        (let ((targets '#$(let-system (system target)
                           (cond ((target-x86? (or target system))
                                  '("i386-efi". "BOOTIA32.EFI"))
                                 ((target-arm? (or target system))
                                  '("arm-efi" . "BOOTARM.EFI"))
                                 (else #f)))))
          (apply initialize-efi32-partition root
                 #:grub-targets targets
                 args))))))
--8<---------------cut here---------------end--------------->8---

Thanks,

Mathieu




Information forwarded to bug-guix <at> gnu.org:
bug#67109; Package guix. (Mon, 27 Nov 2023 09:09:02 GMT) Full text and rfc822 format available.

Message #14 received at 67109 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Mathieu Othacehe <othacehe <at> gnu.org>
Cc: 67109 <at> debbugs.gnu.org, Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
Subject: Re: bug#67109: ‘efi32-esp’ image support pulls
 in host-side code
Date: Mon, 27 Nov 2023 10:07:40 +0100
Hi,

Mathieu Othacehe <othacehe <at> gnu.org> skribis:

>> guix system: error: #<gexp (lambda (root . args) (apply
>> initialize-efi32-partition root #:grub-targets #<gexp-input #<gexp
>> (quote ("i386-efi" . "BOOTIA32.EFI")) gnu/system/image.scm:142:28
>> 7fef96f85390>:out> args)) gnu/system/image.scm:146:8 7fef96f85360>:
>> invalid G-expression input
>
> Expressed that way, I no longer have this error and `target` seems to
> take the expected value, WDYT?
>
> (define esp32-partition
>   (partition
>    (inherit esp-partition)
>    (initializer
>     #~(lambda (root . args)
>         (let ((targets '#$(let-system (system target)
>                            (cond ((target-x86? (or target system))
>                                   '("i386-efi". "BOOTIA32.EFI"))
>                                  ((target-arm? (or target system))
>                                   '("arm-efi" . "BOOTARM.EFI"))
>                                  (else #f)))))
>           (apply initialize-efi32-partition root
>                  #:grub-targets targets
>                  args))))))

Am I right that it breaks if we do:

  (let ((targets #$(let-system …
                     #~'("i386-efi". "BOOTIA32.EFI"))))
    …)

?

That would be the “correct” way to do it, but the problem is that the
body of ‘let-system’ is supposed to evaluate to a file-like object,
which is not what we’re trying to do here.

Hmm, annoying.

Thanks,
Ludo’.




This bug report was last modified 1 year and 242 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.