unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#67109: ‘efi32-esp’ image support pulls in host-side code
@ 2023-11-11 15:45 Ludovic Courtès
  2023-11-14 20:52 ` Mathieu Othacehe
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2023-11-11 15:45 UTC (permalink / raw)
  To: 67109; +Cc: Mathieu Othacehe, Denis 'GNUtoo' Carikli

[-- Attachment #1: Type: text/plain, Size: 933 bytes --]

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’.


[-- Attachment #2: Type: text/x-patch, Size: 2589 bytes --]

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@gnu.org>
+;;; Copyright © 2013-2020, 2023 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Christine Lemmer-Webber <cwebber@dustycloud.org>
 ;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
 ;;; Copyright © 2017 Marius Bakke <mbakke@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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#67109: ‘efi32-esp’ image support pulls in host-side code
  2023-11-11 15:45 bug#67109: ‘efi32-esp’ image support pulls in host-side code Ludovic Courtès
@ 2023-11-14 20:52 ` Mathieu Othacehe
  2023-11-25 14:33   ` Mathieu Othacehe
  0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Othacehe @ 2023-11-14 20:52 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 67109, Denis 'GNUtoo' Carikli


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




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#67109: ‘efi32-esp’ image support pulls in host-side code
  2023-11-14 20:52 ` Mathieu Othacehe
@ 2023-11-25 14:33   ` Mathieu Othacehe
  2023-11-27  9:07     ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Othacehe @ 2023-11-25 14:33 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 67109, Denis 'GNUtoo' Carikli


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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#67109: ‘efi32-esp’ image support pulls in host-side code
  2023-11-25 14:33   ` Mathieu Othacehe
@ 2023-11-27  9:07     ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2023-11-27  9:07 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 67109, Denis 'GNUtoo' Carikli

Hi,

Mathieu Othacehe <othacehe@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’.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-27  9:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-11 15:45 bug#67109: ‘efi32-esp’ image support pulls in host-side code Ludovic Courtès
2023-11-14 20:52 ` Mathieu Othacehe
2023-11-25 14:33   ` Mathieu Othacehe
2023-11-27  9:07     ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).