[Pkg-libvirt-commits] [libguestfs] 157/165: v2v: Create apps_map when doing inspection step.
Hilko Bengen
bengen at moszumanska.debian.org
Sat Aug 30 08:25:25 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch experimental
in repository libguestfs.
commit 5b29d9a1a8b22006e8ecfc18a0c1fa545ccb5132
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Mon Jun 23 15:08:11 2014 +0100
v2v: Create apps_map when doing inspection step.
---
v2v/convert_linux.ml | 13 +------------
v2v/types.ml | 1 +
v2v/types.mli | 6 +++++-
v2v/v2v.ml | 13 ++++++++++++-
4 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index 50955db..aa2a499 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -35,7 +35,7 @@ open Types
module G = Guestfs
let rec convert ?(keep_serial_console = true) verbose (g : G.guestfs)
- ({ i_root = root; i_apps = apps }
+ ({ i_root = root; i_apps = apps; i_apps_map = apps_map }
as inspect) source =
let typ = g#inspect_get_type root
and distro = g#inspect_get_distro root
@@ -54,17 +54,6 @@ let rec convert ?(keep_serial_console = true) verbose (g : G.guestfs)
and is_suse_family =
(distro = "sles" || distro = "suse-based" || distro = "opensuse") in
- (* A map of app2_name -> application2, for easier lookups. Note
- * that app names are not unique! (eg. 'kernel' can appear multiple
- * times)
- *)
- let apps_map = List.fold_left (
- fun map app ->
- let name = app.G.app2_name in
- let vs = try StringMap.find name map with Not_found -> [] in
- StringMap.add name (app :: vs) map
- ) StringMap.empty apps in
-
let rec clean_rpmdb () =
(* Clean RPM database. *)
assert (package_format = "rpm");
diff --git a/v2v/types.ml b/v2v/types.ml
index 9a41f18..a2ec59f 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -100,6 +100,7 @@ ov_source_format = %s
type inspect = {
i_root : string;
i_apps : Guestfs.application2 list;
+ i_apps_map : Guestfs.application2 list StringMap.t;
}
type guestcaps = {
diff --git a/v2v/types.mli b/v2v/types.mli
index 87ba291..1e35d82 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -67,7 +67,11 @@ val string_of_overlay : overlay -> string
type inspect = {
i_root : string; (** Root device. *)
- i_apps : Guestfs.application2 list; (** Packages installed. *)
+ i_apps : Guestfs.application2 list; (** List of packages installed. *)
+ i_apps_map : Guestfs.application2 list StringMap.t;
+ (** This is a map from the app name to the application object.
+ Since RPM allows multiple packages with the same name to be
+ installed, the value is a list. *)
}
(** Inspection information. Only the applications list is stored here
as that is the only one which is slow/inconvenient to fetch. *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 6ad3432..2676217 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -327,7 +327,18 @@ and inspect_source g root_choice =
let apps = g#inspect_list_applications2 root in
let apps = Array.to_list apps in
- { i_root = root; i_apps = apps; }
+ (* A map of app2_name -> application2, for easier lookups. Note
+ * that app names are not unique! (eg. 'kernel' can appear multiple
+ * times)
+ *)
+ let apps_map = List.fold_left (
+ fun map app ->
+ let name = app.G.app2_name in
+ let vs = try StringMap.find name map with Not_found -> [] in
+ StringMap.add name (app :: vs) map
+ ) StringMap.empty apps in
+
+ { i_root = root; i_apps = apps; i_apps_map = apps_map; }
let () =
try main ()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list