]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
util/grub-install-common: Print usable grub-mkimage command
authorGlenn Washburn <development@efficientek.com>
Fri, 22 Sep 2023 19:34:18 +0000 (14:34 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 3 Oct 2023 13:37:13 +0000 (15:37 +0200)
When grub-install is run with the verbose option, it will print a log
message indicating the grub-mkimage command and arguments used.
GRUB no longer calls the grub-mkimage binary internally, however the
command logged is a command that if run should effectively be what
grub-install used. However, as this has changed some of the newer
options have been incorrectly added so that the printed command fails
when run separately. This change makes the displayed command run as
intended.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
util/grub-install-common.c

index f9b9201c894e18da7d51b0064fb4197c54f0c55b..ce854d86f86f1eecf8a9b644d20d78cab78363bf 100644 (file)
@@ -620,6 +620,10 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
     slen += sizeof (" --memdisk ''") + grub_strlen (memdisk_path);
   if (config_path)
     slen += sizeof (" --config ''") + grub_strlen (config_path);
+  if (dtb)
+    slen += sizeof (" --dtb ''") + grub_strlen (dtb);
+  if (sbat)
+    slen += sizeof (" --sbat ''") + grub_strlen (sbat);
 
   for (pk = pubkeys; pk < pubkeys + npubkeys; pk++)
     slen += sizeof (" --pubkey ''") + grub_strlen (*pk);
@@ -642,6 +646,20 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
       p = grub_stpcpy (p, config_path);
       *p++ = '\'';
     }
+  if (dtb)
+    {
+      *p++ = ' ';
+      p = grub_stpcpy (p, "--dtb '");
+      p = grub_stpcpy (p, dtb);
+      *p++ = '\'';
+    }
+  if (sbat)
+    {
+      *p++ = ' ';
+      p = grub_stpcpy (p, "--sbat '");
+      p = grub_stpcpy (p, sbat);
+      *p++ = '\'';
+    }
   for (pk = pubkeys; pk < pubkeys + npubkeys; pk++)
     {
       *p++ = ' ';
@@ -661,11 +679,8 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
   *p = '\0';
 
   grub_util_info ("grub-mkimage --directory '%s' --prefix '%s' --output '%s'"
-                 " --dtb '%s' "
-                 "--sbat '%s' "
-                 "--format '%s' --compression '%s'%s%s%s\n",
+                 " --format '%s' --compression '%s'%s%s%s\n",
                  dir, prefix, outname,
-                 dtb ? : "", sbat ? : "",
                  mkimage_target, compnames[compression],
                  note ? " --note" : "",
                  disable_shim_lock ? " --disable-shim-lock" : "", s);