On Debian family of OSes Grub2 tools are prefixed with 'grub-', not with 'grub2-'. We have to detect the correct name of the tool to use it.
Signed-off-by: Tomáš Golembiovský <[email protected]> --- v2v/linux_bootloaders.ml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/v2v/linux_bootloaders.ml b/v2v/linux_bootloaders.ml index a5e4c8d..0729f17 100644 --- a/v2v/linux_bootloaders.ml +++ b/v2v/linux_bootloaders.ml @@ -189,6 +189,22 @@ class bootloader_grub2 (g : G.guestfs) grub_config = object (self) inherit bootloader + method private grub2_mkconfig_cmd = + let elems = [ + "/sbin/grub2-mkconfig"; + "/usr/sbin/grub2-mkconfig"; + "/sbin/grub-mkconfig" + "/usr/sbin/grub-mkconfig" + ] in + try + List.find ( + let e -> + try g#is_file ~followsymlinks:true e + with G.Error _ -> false + ) elems + with Not_found -> + error (f_"failed to find grub2-mkconfig binary (but Grub2 was detected on guest)") + method private grub2_update_console ~remove () = let rex = Str.regexp "\\(.*\\)\\bconsole=[xh]vc0\\b\\(.*\\)" in @@ -218,7 +234,7 @@ object (self) g#aug_save (); try - ignore (g#command [| "grub2-mkconfig"; "-o"; grub_config |]) + ignore (g#command [| grub2_mkconfig_cmd; "-o"; grub_config |]) with G.Error msg -> warning (f_"could not rebuild grub2 configuration file (%s). This may mean that grub output will not be sent to the serial port, but otherwise should be harmless. Original error message: %s") @@ -290,7 +306,7 @@ object (self) method remove_console = self#grub2_update_console ~remove:true method update () = - ignore (g#command [| "grub2-mkconfig"; "-o"; grub_config |]) + ignore (g#command [| grub2_mkconfig_cmd; "-o"; grub_config |]) end let detect_bootloader (g : G.guestfs) inspect = -- 2.9.3 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
