From 2e3ba998e0b8b54564200a5fbb158e67cf2ef3f2 Mon Sep 17 00:00:00 2001 From: William Manley Date: Thu, 16 Jul 2020 16:00:11 +0100 Subject: [PATCH] syslinux: Improve compatibility with u-boot extlinux.conf The NVidia Jetson NX comes with u-boot installed in syslinux compatible mode. It reads from `/boot/extlinux/extlinux.conf` to know what to boot. It's quite picky about what format it will accept. It crashes if `MENU LABEL` is missing or `KERNEL` is present rather than `LINUX`. This commit improves compatibility by conforming to what u-boot accepts. In theory it shouldn't affect real syslinux systems because the documentation says: > ### LINUX > > You can use this, instead of using KERNEL file to boot a linux kernel > image. although I don't have a real syslinux system to test it on. --- src/libostree/ostree-bootloader-syslinux.c | 10 ++++++++-- tests/bootloader-entries-crosscheck.py | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libostree/ostree-bootloader-syslinux.c b/src/libostree/ostree-bootloader-syslinux.c index 54ed8203c0..d7d9c7fc3b 100644 --- a/src/libostree/ostree-bootloader-syslinux.c +++ b/src/libostree/ostree-bootloader-syslinux.c @@ -92,12 +92,13 @@ append_config_from_loader_entries (OstreeBootloaderSyslinux *self, if (regenerate_default && i == 0) g_ptr_array_add (new_lines, g_strdup_printf ("DEFAULT %s", val)); - g_ptr_array_add (new_lines, g_strdup_printf ("LABEL %s", val)); + g_ptr_array_add (new_lines, g_strdup_printf ("\nLABEL %s", val)); + g_ptr_array_add (new_lines, g_strdup_printf ("\tMENU LABEL %s", val)); val = ostree_bootconfig_parser_get (config, "linux"); if (!val) return glnx_throw (error, "No \"linux\" key in bootloader config"); - g_ptr_array_add (new_lines, g_strdup_printf ("\tKERNEL /boot%s", val)); + g_ptr_array_add (new_lines, g_strdup_printf ("\tLINUX /boot%s", val)); val = ostree_bootconfig_parser_get (config, "initrd"); if (val) @@ -207,6 +208,11 @@ _ostree_bootloader_syslinux_write_config (OstreeBootloader *bootloader, g_free (kernel_arg); kernel_arg = g_strdup (line + strlen ("\tKERNEL ")); } + else if (parsing_label && g_str_has_prefix (line, "\tLINUX ")) + { + g_free (kernel_arg); + kernel_arg = g_strdup (line + strlen ("\tLINUX ")); + } else if (!parsing_label && (g_str_has_prefix (line, "DEFAULT "))) { diff --git a/tests/bootloader-entries-crosscheck.py b/tests/bootloader-entries-crosscheck.py index b5a0206644..52effd476a 100755 --- a/tests/bootloader-entries-crosscheck.py +++ b/tests/bootloader-entries-crosscheck.py @@ -88,6 +88,8 @@ def validate_syslinux(sysroot): syslinux_entry['title'] = v elif k == 'KERNEL': syslinux_entry['linux'] = v + elif k == 'LINUX': + syslinux_entry['linux'] = v elif k == 'INITRD': syslinux_entry['initrd'] = v elif k == 'APPEND':