mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
v2v: linux: try to fix removal of VMware tools
Try to improve the way packages of VMware tools are removed from YUM-based guests: - when filtering the package itself from its providers, do a stricter check so either the provide is the unversioned package, or it is exactly its own name - if the package has no other providers, then going further will cause the invocation of 'yum install' with no packages, and thus the package itself will not be added to the list of packages to be removed; to overcome this issue, just mark the package as "to be removed" in that case Related to: RHBZ#1155150
This commit is contained in:
@@ -252,29 +252,41 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
|
||||
|
||||
(* The packages provide themselves, filter this out. *)
|
||||
let provides =
|
||||
List.filter (fun s -> String.find s library = -1) provides in
|
||||
List.filter (
|
||||
fun s ->
|
||||
not (library = s || String.is_prefix s (library ^ " = "))
|
||||
) provides in
|
||||
|
||||
(* Trim whitespace. *)
|
||||
let rex = Str.regexp "^[ \t]*\\([^ \t]+\\)[ \t]*$" in
|
||||
let provides = List.map (Str.replace_first rex "\\1") provides in
|
||||
|
||||
(* Install the dependencies with yum. Use yum explicitly
|
||||
* because we don't have package names and local install is
|
||||
* impractical.
|
||||
(* If the package provides something other than itself, then
|
||||
* proceed installing the replacements; in the other case,
|
||||
* just mark the package for removal, as it means no other
|
||||
* package can depend on something provided.
|
||||
*)
|
||||
let cmd = ["yum"; "-q"; "resolvedep"] @ provides in
|
||||
let cmd = Array.of_list cmd in
|
||||
let replacements = g#command_lines cmd in
|
||||
let replacements = Array.to_list replacements in
|
||||
if provides <> [] then (
|
||||
(* Trim whitespace. *)
|
||||
let rex = Str.regexp "^[ \t]*\\([^ \t]+\\)[ \t]*$" in
|
||||
let provides = List.map (Str.replace_first rex "\\1") provides in
|
||||
|
||||
let cmd = [ "yum"; "install"; "-y" ] @ replacements in
|
||||
let cmd = Array.of_list cmd in
|
||||
(try
|
||||
ignore (g#command cmd);
|
||||
push_front library remove
|
||||
with G.Error msg ->
|
||||
eprintf "%s: could not install replacement for %s. Error was: %s. %s was not removed.\n"
|
||||
prog library msg library
|
||||
(* Install the dependencies with yum. Use yum explicitly
|
||||
* because we don't have package names and local install is
|
||||
* impractical.
|
||||
*)
|
||||
let cmd = ["yum"; "-q"; "resolvedep"] @ provides in
|
||||
let cmd = Array.of_list cmd in
|
||||
let replacements = g#command_lines cmd in
|
||||
let replacements = Array.to_list replacements in
|
||||
|
||||
let cmd = [ "yum"; "install"; "-y" ] @ replacements in
|
||||
let cmd = Array.of_list cmd in
|
||||
(try
|
||||
ignore (g#command cmd);
|
||||
push_front library remove
|
||||
with G.Error msg ->
|
||||
eprintf "%s: could not install replacement for %s. Error was: %s. %s was not removed.\n"
|
||||
prog library msg library
|
||||
);
|
||||
) else (
|
||||
push_front library remove;
|
||||
);
|
||||
) libraries
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user