Move the actual job in an helper function, so the common bits (like the
check of the size of 'packages' and the reload of Augeas) can be done
for all the package manager implementations.
This should be code motion with no behaviour change.
---
v2v/linux.ml | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/v2v/linux.ml b/v2v/linux.ml
index 46cb3ba..ed639c1 100644
--- a/v2v/linux.ml
+++ b/v2v/linux.ml
@@ -37,22 +37,25 @@ and augeas_reload g =
g#aug_load ();
debug_augeas_errors g
-let remove g inspect packages =
+let rec remove g inspect packages =
if packages <> [] then (
- let package_format = inspect.i_package_format in
- match package_format with
- | "rpm" ->
- let cmd = [ "rpm"; "-e" ] @ packages in
- let cmd = Array.of_list cmd in
- ignore (g#command cmd);
+ do_remove g inspect packages;
+ (* Reload Augeas in case anything changed. *)
+ augeas_reload g
+ )
- (* Reload Augeas in case anything changed. *)
- augeas_reload g
+and do_remove g inspect packages =
+ assert (List.length packages > 0);
+ let package_format = inspect.i_package_format in
+ match package_format with
+ | "rpm" ->
+ let cmd = [ "rpm"; "-e" ] @ packages in
+ let cmd = Array.of_list cmd in
+ ignore (g#command cmd)
- | format ->
- error (f_"don't know how to remove packages using %s: packages: %s")
- format (String.concat " " packages)
- )
+ | format ->
+ error (f_"don't know how to remove packages using %s: packages: %s")
+ format (String.concat " " packages)
let file_list_of_package (g : Guestfs.guestfs) inspect app =
let package_format = inspect.i_package_format in
--
2.7.4