On Wed, Nov 07, 2018 at 12:53:19PM +0100, Tomáš Golembiovský wrote:
Install packages from local files without touching network.
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
v2v/linux.ml | 14 ++++++++++++++
v2v/linux.mli | 3 +++
2 files changed, 17 insertions(+)
diff --git a/v2v/linux.ml b/v2v/linux.ml
index 177724e39..966170cdd 100644
--- a/v2v/linux.ml
+++ b/v2v/linux.ml
@@ -31,6 +31,20 @@ let augeas_reload g =
g#aug_load ();
debug_augeas_errors g
+let rec install_local g { i_package_format = package_format } packages =
+ if packages <> [] then (
+ match package_format with
+ | "rpm" ->
+ let cmd = [ "rpm"; "--upgrade"; "-v" ] @ 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)
+ (* Reload Augeas in case anything changed. *)
+ augeas_reload g
+ )
+
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..80593cebc 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_local: Guestfs.guestfs -> Types.inspect -> string list -> unit
+(** Install pacakge(s). *)
+
val remove : Guestfs.guestfs -> Types.inspect -> string list -> unit
(** Uninstall package(s). *)
This is fine now, assuming we don't want to add dpkg support.
Rich.
--
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