On Tue, 6 Nov 2018 11:32:38 +0000 "Richard W.M. Jones" <rjo...@redhat.com> wrote:
> On Tue, Nov 06, 2018 at 11:44:14AM +0100, Tomáš Golembiovský wrote: > > Install packages from local files without touching network. > > In fact, not limited to local files, but is limited to guests which > use ‘yum’. So I think the function needs a better name unless you're > planning to combine it with > customize/customize_run.ml:guest_install_command (which would be overkill). Uh, somehow I totally screwed this up. The plan was to use "rpm". > > > Signed-off-by: Tomáš Golembiovský <tgole...@redhat.com> > > --- > > v2v/linux.ml | 19 +++++++++++++++++++ > > v2v/linux.mli | 3 +++ > > 2 files changed, 22 insertions(+) > > > > diff --git a/v2v/linux.ml b/v2v/linux.ml > > index 177724e39..6a5cae512 100644 > > --- a/v2v/linux.ml > > +++ b/v2v/linux.ml > > @@ -31,6 +31,25 @@ let augeas_reload g = > > g#aug_load (); > > debug_augeas_errors g > > > > +let rec install g inspect packages = > > + if packages <> [] then ( > > + do_install g inspect packages; > > + (* Reload Augeas in case anything changed. *) > > + augeas_reload g > > + ) > > + > > +and do_install g { i_package_format = package_format } packages = > > It's purely a matter of style, but it's also possible to nest > functions, so: > > let install g inspect packages = > let do_install () = > ... > in > if packages <> [] then ( > do_install (); > ... > > Of course you could also inline do_install. I used the same style as remove(). I will inline the code as I prefer that. Tomas > > Rich. > > > + assert (List.length packages > 0); > > + match package_format with > > + | "rpm" -> > > + let cmd = [ "yum"; "--assumeyes"; "install" ] @ packages in > > + let cmd = Array.of_list cmd in > > + ignore (g#command cmd) > > + > > + | format -> > > + error (f_"don’t know how to install packages using %s: packages: %s") > > + format (String.concat " " packages) > > + > > let rec remove g inspect packages = > > if packages <> [] then ( > > do_remove g inspect packages; > > diff --git a/v2v/linux.mli b/v2v/linux.mli > > index 1c604665e..0036f4769 100644 > > --- a/v2v/linux.mli > > +++ b/v2v/linux.mli > > @@ -23,6 +23,9 @@ val augeas_reload : Guestfs.guestfs -> unit > > additional debugging information about parsing problems > > that augeas found. *) > > > > +val install: Guestfs.guestfs -> Types.inspect -> string list -> unit > > +(** Install pacakge(s). *) > > + > > val remove : Guestfs.guestfs -> Types.inspect -> string list -> unit > > (** Uninstall package(s). *) > > > > -- > > 2.19.0 > > > > _______________________________________________ > > Libguestfs mailing list > > Libguestfs@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-top is 'top' for virtual machines. Tiny program with many > powerful monitoring features, net stats, disk stats, logging, etc. > http://people.redhat.com/~rjones/virt-top -- Tomáš Golembiovský <tgole...@redhat.com> _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs