[Libguestfs] [PATCH 2/2] v2v: ilnux: detect name of grub2-mkconfig
Richard W.M. Jones
rjones at redhat.com
Mon Sep 12 14:02:36 UTC 2016
On Mon, Sep 12, 2016 at 01:31:05PM +0200, Pino Toscano wrote:
> > + 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
>
> is_file returns false if a file does not exist, so there is no need to
> catch the error (this currently swallows other errors than "does not
> exist")
Once you've made the change that Pino suggests, the code can be
refactored a bit more using currying:
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)")
Rich.
--
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