[Libguestfs] [PATCH v3 2/2] v2v: ilnux: detect name of grub2-mkconfig
Richard W.M. Jones
rjones at redhat.com
Tue Sep 13 14:30:04 UTC 2016
The subject needs ilnux -> linux, but the patch itself is fine.
Rich.
On Tue, Sep 13, 2016 at 03:51:31PM +0200, Tomáš Golembiovský wrote:
> 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ý <tgolembi at redhat.com>
> ---
> v2v/linux_bootloaders.ml | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/v2v/linux_bootloaders.ml b/v2v/linux_bootloaders.ml
> index a5e4c8d..4f53f87 100644
> --- a/v2v/linux_bootloaders.ml
> +++ b/v2v/linux_bootloaders.ml
> @@ -186,6 +186,19 @@ end
>
> (* Grub2 representation. *)
> class bootloader_grub2 (g : G.guestfs) grub_config =
> +
> + let grub2_mkconfig_cmd =
> + let elems = [
> + "/sbin/grub2-mkconfig";
> + "/usr/sbin/grub2-mkconfig";
> + "/sbin/grub-mkconfig";
> + "/usr/sbin/grub-mkconfig"
> + ] in
> + try List.find (g#is_file ~followsymlinks:true) elems
> + with Not_found ->
> + error (f_"failed to find grub2-mkconfig binary (but Grub2 was detected on guest)")
> + in
> +
> object (self)
> inherit bootloader
>
> @@ -218,7 +231,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 +303,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
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
More information about the Libguestfs
mailing list