[PATCH] gnu: grub: Fix unicode font loading when booting over TFTP.

  • Done
  • quality assurance status badge
Details
3 participants
  • Danny Milosavljevic
  • Ludovic Courtès
  • Stefan
Owner
unassigned
Submitted by
Stefan
Severity
normal
S
S
Stefan wrote on 13 Dec 2020 18:25
C6806B63-5919-41C9-B80D-6F6827061598@vodafonemail.de
* 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(-)

Toggle diff (28 lines)
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
D
D
Danny Milosavljevic wrote on 14 Dec 2020 23:35
(name . Stefan)(address . stefan-guix@vodafonemail.de)(address . 45225-done@debbugs.gnu.org)
20201214233510.40725a4d@scratchpost.org
Hi Stefan,

your patch file arrived mangled in my mailbox.

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

Toggle quote (7 lines)
>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.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl/X6J4ACgkQ5xo1VCww
uqUPAAgAg7T2WCmi9SX15hUIl98NwoDUHBGKg1DNIGM1VXWxPYjRndTFfgieHpY2
VWipynBu5fdgdbeYR/bsI0Vm4s1ZVkDHHFiopb4CVUkXVh+FaWohSu75XK4BuY9b
5CW/E9FOBJrFq8OUraUz06bh0lVrGEXtOQxjbRSvDJO+pW9bF5YBc0y04TYoIrJT
726ILPBqaNF8C+29eDfX+4j9cqt6e3qUzpU1x61CMLlJVaqex1Q74yiUEg0FMXrQ
jndp4npUJZ1sHLozrPgXozYRJ/pCF7I2Cc+dWLt2vfCID490AzFDBVdJOu5/WuX9
8SDI20nJImoFM/cO3P5Gz/aJMzYYmA==
=nb+E
-----END PGP SIGNATURE-----


Closed
S
S
Stefan wrote on 19 Dec 2020 21:29
[PATCH] gnu: grub: Fix unicode font loading when booting over TFTP.
5BC2CE26-5F2D-4250-A9E5-D04BB85DD942@vodafonemail.de
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
L
L
Ludovic Courtès wrote on 21 Dec 2020 15:50
(name . Stefan)(address . stefan-guix@vodafonemail.de)
87blen6wmy.fsf@gnu.org
Hi Stefan,

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

Toggle quote (2 lines)
> 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:


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’.
S
S
Stefan wrote on 21 Dec 2020 18:03
(name . Ludovic Courtès)(address . ludo@gnu.org)
4043C397-47B2-4DA5-B873-86DABE169ED0@vodafonemail.de
Hi Ludo’!

Toggle quote (4 lines)
> 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.

Toggle quote (2 lines)
> Yeah, I wanted to send you a heads-up and then I forgot, apologies!

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

Toggle quote (3 lines)
> 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
L
L
Ludovic Courtès wrote on 22 Dec 2020 14:38
(name . Stefan)(address . stefan-guix@vodafonemail.de)
877dpa2c6t.fsf@gnu.org
Hi Stefan,

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

Toggle quote (10 lines)
> 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’.
S
S
Stefan wrote on 22 Dec 2020 16:21
(name . Ludovic Courtès)(address . ludo@gnu.org)
7BDB1D37-7B0A-41FD-876A-61B60E4DF159@vodafonemail.de
Hi Ludo’!

Toggle quote (4 lines)
> 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/.

Toggle quote (2 lines)
> 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.


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
S
S
Stefan wrote on 28 Dec 2020 12:24
[PATCH] gnu: grub: Use installed unicode font, fix loading when booting over TFTP.
B4C7682B-58CF-4B67-A086-C0E8190AB779@vodafonemail.de
* 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(-)

Toggle diff (66 lines)
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
S
S
D
D
Danny Milosavljevic wrote on 17 Jan 2021 16:51
Re: [PATCH] gnu: grub: Fix unicode font loading when booting over TFTP.
(name . Stefan)(address . stefan-guix@vodafonemail.de)
20210117165134.59a27e3f@scratchpost.org
Hi Stefan,

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

Toggle quote (2 lines)
> 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
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#7using 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@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.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAmAEXQYACgkQ5xo1VCww
uqXIbQf+P/2O+1Fl+rc9dg/rIdfPIVSDTRhikGXLHyzyHkR13B++56ST6qrMtKYm
3dxsZz/gSwdVHACSLaKYFcEsPGNPWpYfiLmtB67fcpW6hnNz/8nczNH+Z2p1+Bex
FACfMfiKmHeRYv4ggk5MX1mnc6hWManOnZmv/0eL1jJxO7aeW11NBeu6rRDNpt1J
88Szl1N5yfknFFGKHXpv0dLtuw66w29OcBERq8LiRpvPJdmK+8VRYwyuOQyTVO9j
7yDmetCpp/1hD/lO0Fgr6L/MgUFzetdXVl8a3eczP1pcw84pCm7JMPktJfqqzMOU
dpye9nwVSUoWnDdX6Re+buHXO0pccA==
=P5/7
-----END PGP SIGNATURE-----


S
S
Stefan wrote on 17 Jan 2021 16:57
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
07A7C043-B057-4C81-A998-B6351E0E138A@vodafonemail.de
Hi Danny!

Toggle quote (2 lines)
> I just want to say that I'm not ignoring the question--I honesty don't know.

OK.

Toggle quote (2 lines)
> In any case, until we do know, I've applied your patch

Many thanks! :-)

Toggle quote (3 lines)
> 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
?
Your comment

This issue is archived.

To comment on this conversation send an email to 45225@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 45225
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch