Correction de qi-bootmenu 2.0

Suite à la sortie de la version 2.0 de qi-bootmenu, je me suis empressé de l’installer. Malheureusement, cette version est boguée : elle affiche toutes les alternatives de boot possible, mais quelque soit l’entrée choisie, seule la dernière entrée est bootée.

En investiguant, il s’avère que le problème fût assez simple corriger. Néanmoins, Marc André Tanner n’est pas prompt à publier une nouvelle version. Du coup, je publie ma propre version.

Mon patch :

From: Guilhem Bonnefille <guilhem>
Subject: [PATCH] Fix activation of selected entry

When selecting an entry, the booted partition is always the latest  

It seems the bug is around the creation of MenuEntry. Currently  
all entries are constructed with an automatic variable. Doing this,  
data are corrupted when user selects an entry on the GUI.

This patch solves the problem by cloning the MenuEntry data  
(dynamically allocateed variable) just before creating the graphical  
entry. The matter is just sort of memory leak as no code free the  
cloned memory. But is it really an important issue?

Signed-off-by: Guilhem Bonnefille <guilhem>

 gui-list.c |    4 +++-  
 kexec.c    |    3 +++  
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gui-list.c b/gui-list.c  
index 03c1949..80aa2b6 100644  
--- a/gui-list.c  
+++ b/gui-list.c

@@ -72,6 +72,8 @@ static void gui_list_show_error(const char *errstr, va_list ap) {
 static void gui_list_add_item(MenuItem *item) {  
        static unsigned int y;  
-       gui_list_draw_item(item->text, item->logo, gui_item_clicked, item, 0, y);  
+       MenuItem *clone = malloc(sizeof(MenuItem));  
+       memcpy(clone, item, sizeof(MenuItem));  
+       gui_list_draw_item(item->text, item->logo, gui_item_clicked, clone, 0, y);  
        y += LIST_LOGO_HEIGHT;  
diff --git a/kexec.c b/kexec.c  
index 977c67b..a3d6931 100644  
--- a/kexec.c  
+++ b/kexec.c  
@@ -375,6 +375,9 @@ static bool boot_kernel(BootItem *i) {  
        const char *kexec_load[] = { KEXEC, get_kernel_cmdline(i), "-l", i->kernel, NULL };  
+       /* debug */  
+       puts("Setting following kernel options via kexec:");  
+       puts(kexec_load[1]);  
        if (fexecw(kexec_load[0], (char *const *)kexec_load, NULL)) {  
                gui_show_error("Couldn't load kernel from '%s'", i->kernel);  
                return false;  
tg: (94fc251..) t/fix/duplicate-menuentry (depends on: master)