Install packages from local files without touching network.
Signed-off-by: Tomáš Golembiovský <tgolembi(a)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 =
+ 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