Current package removal implementation uses `rpm -e`, which will fail if anything depends on the package we are trying to remove. Like when `spausedd` is dependent on `open-vm-tools`.
Reuse the package uninstall logic from virt-customize, which will handle this no problem. Fixes: https://issues.redhat.com/browse/RHEL-71522 Signed-off-by: Cole Robinson <crobi...@redhat.com> --- First time touching ocaml, be gentle :) This fixes my minimal test case, but there's test suite regressions. + How to run a single test against in tree virt-v2v? + and/or get `make check` to spit out more info? more questions: + uninstall failure is still fatal. example how to make this non-fatal? + `virt-v2v -v` logs don't show command stdout. expected? do I need an extra debug option? + better way to share code with customize_run.ml ? guest_pkgs_command() is lifted from there + should I instead change Linux.remove impl, or should I aim to remove that code entirely? convert/convert_linux.ml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml index 3d0e2b88..2e0cf61b 100644 --- a/convert/convert_linux.ml +++ b/convert/convert_linux.ml @@ -131,6 +131,18 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ = (*----------------------------------------------------------------------*) (* Conversion step. *) + let guest_pkgs_command f = + try f (g#inspect_get_package_management inspect.i_root) with + | Guest_packages.Unknown_package_manager msg + | Guest_packages.Unimplemented_package_manager msg -> + error "%s" msg + in + + let uninstall_packages pkgs = + let cmd = guest_pkgs_command(Guest_packages.uninstall_command pkgs) in + ignore (g#sh cmd); + in + let rec do_convert () = augeas_grub_configuration (); @@ -237,7 +249,7 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ = else None ) inspect.i_apps in - Linux.remove g inspect.i_root xenmods; + uninstall_packages xenmods; (* Undo related nastiness if kmod-xenpv was installed. *) if xenmods <> [] then ( @@ -310,7 +322,7 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ = fun { G.app2_name = name } -> name = package_name ) inspect.i_apps in if has_guest_additions then - Linux.remove g inspect.i_root [package_name]; + uninstall_packages [package_name]; (* Guest Additions might have been installed from a tarball. The * above code won't detect this case. Look for the uninstall tool @@ -455,8 +467,7 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ = ) ); - let remove = !remove in - Linux.remove g inspect.i_root remove; + uninstall_packages !remove; (* VMware Tools may have been installed from a tarball, so the * above code won't remove it. Look for the uninstall tool and run @@ -503,7 +514,7 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ = let pkgs = List.map (fun { G.app2_name = name } -> name) pkgs in if pkgs <> [] then ( - Linux.remove g inspect.i_root pkgs; + uninstall_packages pkgs; (* Installing these guest utilities automatically unconfigures * ttys in /etc/inittab if the system uses it. We need to put -- 2.48.1 _______________________________________________ Libguestfs mailing list -- guestfs@lists.libguestfs.org To unsubscribe send an email to guestfs-le...@lists.libguestfs.org