GNU bug report logs - #45225
[PATCH] gnu: grub: Fix unicode font loading when booting over TFTP.

Previous Next

Package: guix-patches;

Reported by: Stefan <stefan-guix <at> vodafonemail.de>

Date: Sun, 13 Dec 2020 17:26:01 UTC

Severity: normal

Tags: patch

Done: Danny Milosavljevic <dannym <at> scratchpost.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45225 in the body.
You can then email your comments to 45225 AT debbugs.gnu.org in the normal way.

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

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


Report forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Sun, 13 Dec 2020 17:26:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan <stefan-guix <at> vodafonemail.de>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 13 Dec 2020 17:26:01 GMT) Full text and rfc822 format available.

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

From: Stefan <stefan-guix <at> vodafonemail.de>
To: guix-patches <at> gnu.org,
 Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH] gnu: grub: Fix unicode font loading when booting over TFTP.
Date: Sun, 13 Dec 2020 18:25:24 +0100
* gnu/bootloader/grub.scm (font-file): Using (canonicalize-path), as symlinks
 from a bootloader profile do not work on a tftp server when network booting.
---
gnu/bootloader/grub.scm | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index af7b7561ff..3177452dfb 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -191,9 +191,18 @@ fi~%"
  (define font-file
    (let* ((bootloader (bootloader-configuration-bootloader config))
           (grub (bootloader-package bootloader)))
-      (normalize-file (file-append grub "/share/grub/unicode.pf2")
-                      store-mount-point
-                      store-directory-prefix)))
+      ;; The bootloader-package may be a profile with only symlinks.
+      ;; If network booting, then a symlink to the font may not work on the
+      ;; server side.  Therefore we canonicalize the file name of the font.
+      ;; TODO:  The font gets installed by (install-grub-efi-netboot) and
+      ;; (install-grub-efi).  The installed font could be referred to as
+      ;; "unicode".  But it is currently unclear if (install-grub-disk-image)
+      ;; and (install-grub) both install the font as well.
+      ;; Actually this should be preferred.
+      #~(canonicalize-path
+         #+(normalize-file (file-append grub "/share/grub/unicode.pf2")
+                           store-mount-point
+                           store-directory-prefix))))

  (define image
    (normalize-file (grub-background-image config)
-- 
2.29.2



Reply sent to Danny Milosavljevic <dannym <at> scratchpost.org>:
You have taken responsibility. (Mon, 14 Dec 2020 22:36:02 GMT) Full text and rfc822 format available.

Notification sent to Stefan <stefan-guix <at> vodafonemail.de>:
bug acknowledged by developer. (Mon, 14 Dec 2020 22:36:02 GMT) Full text and rfc822 format available.

Message #10 received at 45225-done <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Stefan <stefan-guix <at> vodafonemail.de>
Cc: 45225-done <at> debbugs.gnu.org
Subject: Re: [PATCH] gnu: grub: Fix unicode font loading when booting over
 TFTP.
Date: Mon, 14 Dec 2020 23:35:10 +0100
[Message part 1 (text/plain, inline)]
Hi Stefan,

your patch file arrived mangled in my mailbox.

On Sun, 13 Dec 2020 18:25:24 +0100
Stefan <stefan-guix <at> vodafonemail.de> wrote:

>diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
>index af7b7561ff..3177452dfb 100644
>--- a/gnu/bootloader/grub.scm
>+++ b/gnu/bootloader/grub.scm
>@@ -191,9 +191,18 @@ fi~%"
>  (define font-file

For example, the original source file had here two spaces before the "define".
But the Patch format needs one control character in front.

In this case (for the Context mark), the control character should also be a
space.
That means there should be three spaces there.  But there are two spaces there.

It goes on similarly in the entire patch file.

I've fixed it up manually and pushed to guix master--but you might want
to look into why this happens in general before something important gets
mangled.
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Sat, 19 Dec 2020 20:31:01 GMT) Full text and rfc822 format available.

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

From: Stefan <stefan-guix <at> vodafonemail.de>
To: 45225 <at> debbugs.gnu.org, Danny Milosavljevic <dannym <at> scratchpost.org>,
 Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH] gnu: grub: Fix unicode font loading when booting over TFTP.
Date: Sat, 19 Dec 2020 21:29:58 +0100
Hi Danny and Ludo!

This patch got pushed and later reverted, as it is causing issues, because /gnu/store…-grub…/share/grub/unicode.pf2 is sometimes not visible when building the grub.cfg file.

To understand what is happening here, I modified the creation of the grub.cfg file to write the directory entries of /gnu/store visible at build time into a file.

While the /gnu/store/ on disk shows thousands of entries, when building grub.cfg there are only about 400 entries visible in my case doing a guix system reconfigure. Although the grub-efi package is referred to with a file-append gexp to build the path to the unicode.pf2 in gnu/bootloader/grub.scm, it happens that the grub package is not available in all cases in /gnu/store. The grub-efi package is gotten via (bootloader-package bootloader) and the bootloader possibly from a /run/*-system/parameters file.

I also noticed that even all the Linux kernels and initrds – except for the recent pair –, which end up being referred to from the grub.cfg, are not visible in /gnu/store while building the grub.cfg.

What makes the list of visible entries in /gnu/store when building the grub.cfg? And why might the gexp-referred grub-efi package not always be visible? This feels like a bug to me.


Bye

Stefan



Information forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Mon, 21 Dec 2020 14:51:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Stefan <stefan-guix <at> vodafonemail.de>
Cc: 45225 <at> debbugs.gnu.org, Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: Re: [PATCH] gnu: grub: Fix unicode font loading when booting over
 TFTP.
Date: Mon, 21 Dec 2020 15:50:45 +0100
Hi Stefan,

Stefan <stefan-guix <at> vodafonemail.de> skribis:

> This patch got pushed and later reverted, as it is causing issues, because /gnu/store…-grub…/share/grub/unicode.pf2 is sometimes not visible when building the grub.cfg file.

Yeah, I wanted to send you a heads-up and then I forgot, apologies!

In general, my suggestion when fiddling with these things is to at least
run:

  make check-system TESTS=basic

This one builds and runs quickly and catches the most obvious issues, as
in this case.

Then, when fiddling with the bootloader, file systems, and that kind of
stuff, it’s a good idea to run an installation test, as in:

  make check-system TESTS=installed-os

This is more expensive to build (it first has to build ‘guix’, then an
ISO image, and then run the installation), but it’s a good idea when
low-level things are modified.  See:

  https://guix.gnu.org/manual/en/html_node/Running-the-Test-Suite.html

I’m not sure I understand what this change meant to fix though.  What
was the initial problem that led to the addition of this
‘canonicalize-path’ call?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Mon, 21 Dec 2020 17:04:02 GMT) Full text and rfc822 format available.

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

From: Stefan <stefan-guix <at> vodafonemail.de>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 45225 <at> debbugs.gnu.org, Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: Re: [PATCH] gnu: grub: Fix unicode font loading when booting over
 TFTP.
Date: Mon, 21 Dec 2020 18:03:22 +0100
Hi Ludo’!

> I’m not sure I understand what this change meant to fix though.  What
> was the initial problem that led to the addition of this
> ‘canonicalize-path’ call?

When I am booting over TFTP, the Guix related files are located somewhere on that server and therefore symlinks do not work. Let's make an example:

There is some path like /volume/systems/guix-system/. There you can find gnu/store/ and boot/.

That server serves /volume/systems/guix-system/ via NFS as the root file system for a raspberry. That server also serves /volume/systems/guix-system/boot/ as the TFTP root for booting.

Now due to the fact that I need some firmware, configuration files, U-Boot and GRUB, there is now the possibility to create a bootloader-profile, which is basically a collection of symlinks to all this.

Due to this, there is somewhere a /volume/systems/guix-system/gnu/store/…-bootloader-profile/share/grub/unicode.pf2, which is an *absolute* symlink to /gnu/store/…-grub-efi-2.04/share/grub/unicode.pf2. 

The generated grub.cfg now normally refers to /gnu/store/…-bootloader-profile/share/grub/unicode.pf2.

When GRUB tries to load gnu/store/…-bootloader-profile/share/grub/unicode.pf2 via TFTP, due to a profile prepared *relative* symlink at /volume/systems/guix-system/boot/gnu/store to the real store location at ../..gnu/store/guix-system/gnu/store/ the TFTP server is able to access gnu/store/…-bootloader-profile/share/grub/unicode.pf2.

And there is the problem: That /gnu/store/…-bootloader-profile/share/grub/unicode.pf2 is an *absolute* symlink with no meaning to the TFTP server, so loading the font fails.

Simply speaking: Files for booting via TFTP must not be *absolute* symlinks.

Meanwhile I know that the font can be referred to as simply "unicode" without any path and extension, as it is installed with install-grub-efi, install-grub-efi-netboot and install-grub. I’m just still unsure about install-grub-disk-image. So hopefully the font reference can be simplified.

> Yeah, I wanted to send you a heads-up and then I forgot, apologies!

Nevermind. I’m sorry to have caused this trouble.

> In general, my suggestion when fiddling with these things is to at least
> run …

My trouble is that I only have that raspberry with only 1 GB RAM yet, and running tests on it is kind of impossible.

I tried to install Guix in a virtual machine on a NAS system during the weekend. The installation image is working, but the installed system hangs during boot. At least this was enough to find out that a simple "unicode" in grub.cfg is also sufficient for install-grub. :-)

I’m sorry that I broke Guix. I didn’t imagine that a canonicalize-path would not work, when the store path is known during build.

But this brings me back to my original question: Could you please explain why the grub package, which is referred to with a file-append gexp, is finally not visible when the grub.cfg is created?


Bye

Stefan 





Information forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Tue, 22 Dec 2020 13:39:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Stefan <stefan-guix <at> vodafonemail.de>
Cc: 45225 <at> debbugs.gnu.org, Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: Re: [PATCH] gnu: grub: Fix unicode font loading when booting over
 TFTP.
Date: Tue, 22 Dec 2020 14:38:18 +0100
Hi Stefan,

Stefan <stefan-guix <at> vodafonemail.de> skribis:

> Due to this, there is somewhere a /volume/systems/guix-system/gnu/store/…-bootloader-profile/share/grub/unicode.pf2, which is an *absolute* symlink to /gnu/store/…-grub-efi-2.04/share/grub/unicode.pf2. 
>
> The generated grub.cfg now normally refers to /gnu/store/…-bootloader-profile/share/grub/unicode.pf2.
>
> When GRUB tries to load gnu/store/…-bootloader-profile/share/grub/unicode.pf2 via TFTP, due to a profile prepared *relative* symlink at /volume/systems/guix-system/boot/gnu/store to the real store location at ../..gnu/store/guix-system/gnu/store/ the TFTP server is able to access gnu/store/…-bootloader-profile/share/grub/unicode.pf2.
>
> And there is the problem: That /gnu/store/…-bootloader-profile/share/grub/unicode.pf2 is an *absolute* symlink with no meaning to the TFTP server, so loading the font fails.
>
> Simply speaking: Files for booting via TFTP must not be *absolute* symlinks.

It’s possible to create profiles that use relative symlinks:

  (profile-derivation … #:relative-symlinks? #t)

or, for the declarative counterpart:

  (profile (content …)
           (relative-symlinks? #t))

Would that solve your problem?

BTW, I don’t see “bootloader-profile” in ‘master’; is it on a branch?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Tue, 22 Dec 2020 15:22:02 GMT) Full text and rfc822 format available.

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

From: Stefan <stefan-guix <at> vodafonemail.de>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 45225 <at> debbugs.gnu.org, Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: Re: [PATCH] gnu: grub: Fix unicode font loading when booting over
 TFTP.
Date: Tue, 22 Dec 2020 16:21:40 +0100
Hi Ludo’!

> It’s possible to create profiles that use relative symlinks:

> Would that solve your problem?

Oh, that can be helpful. Thanks!

However, the unicode font is the only file referring from grub.cfg to the bootloader-profile inside the store and I’m meanwhile confident that this is not necessary at all, as the font is installed with all the other grub files in /boot/.

> BTW, I don’t see “bootloader-profile” in ‘master’; is it on a branch?

It’s in master in gnu/bootloader.scm, the function to use is efi-bootloader-profile. However, there’s still a patch pending.

https://issues.guix.gnu.org/41066#33

I’m sorry for my nagging, but I’d really like to understand, why the grub package is not always visible in /gnu/store/ when building the grub.cfg file, although it is referred to by a file-append gexp.


Bye

Stefan



Information forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Mon, 28 Dec 2020 11:25:01 GMT) Full text and rfc822 format available.

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

From: Stefan <stefan-guix <at> vodafonemail.de>
To: Ludovic Courtès <ludo <at> gnu.org>,
 Danny Milosavljevic <dannym <at> scratchpost.org>, 45225 <at> debbugs.gnu.org
Subject: [PATCH] gnu: grub: Use installed unicode font,
 fix loading when booting over TFTP.
Date: Mon, 28 Dec 2020 12:24:16 +0100
* gnu/bootloader/grub.scm (setup-gfxterm): Removed parameter font-file.
Refer to the installed font, not into the store.
(font-file): Removed obsolete function.
(install-grub): When populating a disk-image, install the unicode font, too.
---
 gnu/bootloader/grub.scm | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 29c81ae641..13ee695909 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -168,15 +168,14 @@ STORE-DEVICE designates the device holding the store, and STORE-MOUNT-POINT is
  its mount point; these are used to determine where the background image and
  fonts must be searched for.  STORE-DIRECTORY-PREFIX is a directory prefix to
  prepend to any store file name."
-  (define (setup-gfxterm config font-file)
+  (define (setup-gfxterm config)
      (if (memq 'gfxterm (bootloader-configuration-terminal-outputs config))
          #~(format #f "
-if loadfont ~a; then
+if loadfont unicode; then
    set gfxmode=~a
    insmod all_video
    insmod gfxterm
  fi~%"
-                  #+font-file
                    #$(string-join
                       (grub-theme-gfxmode (bootloader-theme config))
                       ";"))
@@ -188,13 +187,6 @@ fi~%"
        (string-append (symbol->string (assoc-ref colors 'fg)) "/"
                       (symbol->string (assoc-ref colors 'bg)))))
  
-  (define font-file
-    (let* ((bootloader (bootloader-configuration-bootloader config))
-           (grub (bootloader-package bootloader)))
-      (normalize-file (file-append grub "/share/grub/unicode.pf2")
-                      store-mount-point
-                      store-directory-prefix)))
-
    (define image
      (normalize-file (grub-background-image config)
                      store-mount-point
@@ -216,8 +208,8 @@ else
    set menu_color_normal=cyan/blue
    set menu_color_highlight=white/blue
  fi~%"
-                 #$(grub-root-search store-device font-file)
-                 #$(setup-gfxterm config font-file)
+                 #$(grub-root-search store-device image)
+                 #$(setup-gfxterm config)
                   #$(grub-setup-io config)
  
                   #$image
@@ -545,9 +537,13 @@ fi~%"))))
                (invoke/quiet grub "--no-floppy" "--target=i386-pc"
                              "--boot-directory" install-dir
                              device))
-            ;; When creating a disk-image, only install GRUB modules.
-            (copy-recursively (string-append bootloader "/lib/")
-                              install-dir)))))
+            ;; When creating a disk-image, only install a font and GRUB modules.
+            (let* ((fonts (string-append install-dir "/grub/fonts")))
+              (mkdir-p fonts)
+              (copy-file (string-append bootloader "/share/grub/unicode.pf2")
+                         (string-append fonts "/unicode.pf2"))
+              (copy-recursively (string-append bootloader "/lib/")
+                                install-dir))))))
  
  (define install-grub-disk-image
    #~(lambda (bootloader root-index image)
-- 
2.29.2





Information forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Thu, 07 Jan 2021 16:38:02 GMT) Full text and rfc822 format available.

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

From: Stefan <stefan-guix <at> vodafonemail.de>
To: Ludovic Courtès <ludo <at> gnu.org>,
 Danny Milosavljevic <dannym <at> scratchpost.org>, 45225 <at> debbugs.gnu.org
Subject: Re: [PATCH] gnu: grub: Use installed unicode font,
 fix loading when booting over TFTP.
Date: Thu, 7 Jan 2021 17:37:32 +0100
Hi!

A friendly ping. :-)

<https://issues.guix.gnu.org/issue/45225#7>


Bye

Stefan




Information forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Sun, 17 Jan 2021 14:14:01 GMT) Full text and rfc822 format available.

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

From: Stefan <stefan-guix <at> vodafonemail.de>
To: Ludovic Courtès <ludo <at> gnu.org>,
 Danny Milosavljevic <dannym <at> scratchpost.org>, 45225 <at> debbugs.gnu.org
Subject: Re: [PATCH] gnu: grub: Use installed unicode font,
 fix loading when booting over TFTP.
Date: Sun, 17 Jan 2021 15:13:42 +0100
Hi!

Another friendly ping. :-)

<https://issues.guix.gnu.org/issue/45225#7>


Bye

Stefan





Information forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Sun, 17 Jan 2021 15:52:02 GMT) Full text and rfc822 format available.

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

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Stefan <stefan-guix <at> vodafonemail.de>
Cc: 45225 <at> debbugs.gnu.org, Ludovic Courtès <ludo <at> gnu.org>
Subject: Re: [PATCH] gnu: grub: Fix unicode font loading when booting over
 TFTP.
Date: Sun, 17 Jan 2021 16:51:34 +0100
[Message part 1 (text/plain, inline)]
Hi Stefan,

On Tue, 22 Dec 2020 16:21:40 +0100
Stefan <stefan-guix <at> vodafonemail.de> wrote:

> I’m sorry for my nagging, but I’d really like to understand, why the grub package is not always visible in /gnu/store/ when building the grub.cfg file, although it is referred to by a file-append gexp.

I just want to say that I'm not ignoring the question--I honesty don't know.

In any case, until we do know, I've applied your patch
https://issues.guix.gnu.org/issue/45225#7  to guix master as commit
b57056a9fd83c61efb5343853948a798da6e975e--after all, the font was in /boot
for regular Guix Systems anyway, so I don't see a downside loading it from
/boot--especially since it's part of the bootloader anyway, which does not
have different generations for itself.  Also, the code is simpler now.

I also want to note that all 4 hunks in that patch had failed to apply with
git am.  I implore you to please download the patch files from
https://issues.guix.gnu.org/issue/45225#7 using the little blue download arrow
are the top right corner and try to "git am" them yourself.  It won't work
because the spaces in your patch files are mangled.

If it's that way because git send-email doesn't work, I have a block like the
following in ~/.gitconfig--and my patches arrive unmangled that way:

[sendemail]
        from = Example User <user <at> example.com>
        smtpEncryption = tls
        smtpServer = xxx
        smtpUser = xxx
        smtpPass = xxx
        smtpServerPort = 587

Then you can use

  git format-patch -1 -o ../outgoing-topic1
  git send-email ../outgoing-topic1/0001*

and it will work.
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#45225; Package guix-patches. (Sun, 17 Jan 2021 15:59:02 GMT) Full text and rfc822 format available.

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

From: Stefan <stefan-guix <at> vodafonemail.de>
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 45225 <at> debbugs.gnu.org, Ludovic Courtès <ludo <at> gnu.org>
Subject: Re: [PATCH] gnu: grub: Fix unicode font loading when booting over
 TFTP.
Date: Sun, 17 Jan 2021 16:57:59 +0100
Hi Danny!

> I just want to say that I'm not ignoring the question--I honesty don't know.

OK.

> In any case, until we do know, I've applied your patch

Many thanks! :-)

> I also want to note that all 4 hunks in that patch had failed to apply with
> git am.

I’m sorry about this. I think that patch was older than your hint to me about troubles with spaces.

I’ll change my setup. Thanks for the hints.


Bye

Stefan



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 15 Feb 2021 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 69 days ago.

Previous Next


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