From ea881513e9c15b0a816d3ba4afe471ff2f591a03 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 14 Jul 2022 12:44:27 +0100 Subject: [PATCH] common: Adapt to renamed function On_exit.rmdir -> On_exit.rm_rf This function was renamed to make it clearer what it does (and that it's potentially dangerous). The functionality is unchanged. Reviewed-by: Laszlo Ersek (cherry picked from commit 2eb6441264deb0411d36dabaf8fb2da9f07c8439) --- common | 2 +- input/OVA.ml | 2 +- input/parse_domain_from_vmx.ml | 2 +- lib/nbdkit.ml | 2 +- lib/qemuNBD.ml | 2 +- lib/utils.ml | 2 +- output/python_script.ml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) Submodule common af6cb55b..fd964c1b: diff --git a/common/mlcustomize/guest_packages.ml b/common/mlcustomize/guest_packages.ml index 4c3c34ed..7c29a2ab 100644 --- a/common/mlcustomize/guest_packages.ml +++ b/common/mlcustomize/guest_packages.ml @@ -73,9 +73,9 @@ let install_command packages package_management = | "zypper" -> sprintf "zypper -n in -l %s" quoted_args | "unknown" -> - error_unknown_package_manager (s_"--install") + error_unknown_package_manager "--install" | pm -> - error_unimplemented_package_manager (s_"--install") pm + error_unimplemented_package_manager "--install" pm let update_command package_management = match package_management with @@ -103,9 +103,9 @@ let update_command package_management = | "zypper" -> "zypper -n update -l" | "unknown" -> - error_unknown_package_manager (s_"--update") + error_unknown_package_manager "--update" | pm -> - error_unimplemented_package_manager (s_"--update") pm + error_unimplemented_package_manager "--update" pm let uninstall_command packages package_management = let quoted_args = String.concat " " (List.map quote packages) in @@ -127,6 +127,6 @@ let uninstall_command packages package_management = | "zypper" -> sprintf "zypper -n rm %s" quoted_args | "unknown" -> - error_unknown_package_manager (s_"--uninstall") + error_unknown_package_manager "--uninstall" | pm -> - error_unimplemented_package_manager (s_"--uninstall") pm + error_unimplemented_package_manager "--uninstall" pm diff --git a/common/mltools/on_exit.ml b/common/mltools/on_exit.ml index 53ccb68a..cae12e73 100644 --- a/common/mltools/on_exit.ml +++ b/common/mltools/on_exit.ml @@ -52,7 +52,7 @@ let do_actions () = List.iter (do_action (fun file -> Unix.unlink file)) !files; List.iter (do_action ( fun dir -> - let cmd = sprintf "rm -rf %s" (Filename.quote dir) in + let cmd = sprintf "rm -rf -- %s" (Filename.quote dir) in ignore (Tools_utils.shell_command cmd) ) ) !rmdirs; @@ -102,7 +102,7 @@ let unlink filename = register (); List.push_front filename files -let rmdir dir = +let rm_rf dir = register (); List.push_front dir rmdirs diff --git a/common/mltools/on_exit.mli b/common/mltools/on_exit.mli index a02e3db3..9bcf104f 100644 --- a/common/mltools/on_exit.mli +++ b/common/mltools/on_exit.mli @@ -47,7 +47,7 @@ val f : (unit -> unit) -> unit val unlink : string -> unit (** Unlink a single temporary file on exit. *) -val rmdir : string -> unit +val rm_rf : string -> unit (** Recursively remove a temporary directory on exit (using [rm -rf]). *) val kill : ?signal:int -> int -> unit diff --git a/input/OVA.ml b/input/OVA.ml index 9e9c3712..09ceee98 100644 --- a/input/OVA.ml +++ b/input/OVA.ml @@ -78,7 +78,7 @@ let rec parse_ova ova = else ( let tmpdir = let t = Mkdtemp.temp_dir ~base_dir:large_tmpdir "ova." in - On_exit.rmdir t; + On_exit.rm_rf t; t in match detect_file_type ova with diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml index 947ca414..7aca2c24 100644 --- a/input/parse_domain_from_vmx.ml +++ b/input/parse_domain_from_vmx.ml @@ -375,7 +375,7 @@ and find_nics vmx = let parse_domain_from_vmx vmx_source = let tmpdir = let t = Mkdtemp.temp_dir "vmx." in - On_exit.rmdir t; + On_exit.rm_rf t; t in (* If the transport is SSH, fetch the file from remote, else diff --git a/lib/nbdkit.ml b/lib/nbdkit.ml index 07896684..1137b6bb 100644 --- a/lib/nbdkit.ml +++ b/lib/nbdkit.ml @@ -105,7 +105,7 @@ let add_filter_if_available cmd filter = let run_unix socket cmd = (* Create a temporary directory where we place the PID file. *) let piddir = Mkdtemp.temp_dir "v2vnbdkit." in - On_exit.rmdir piddir; + On_exit.rm_rf piddir; let id = unique () in let pidfile = piddir // sprintf "nbdkit%d.pid" id in diff --git a/lib/qemuNBD.ml b/lib/qemuNBD.ml index bbb65f41..c3dd1666 100644 --- a/lib/qemuNBD.ml +++ b/lib/qemuNBD.ml @@ -69,7 +69,7 @@ let run_unix socket { disk; snapshot; format; imgopts } = (* Create a temporary directory where we place the PID file. *) let piddir = Mkdtemp.temp_dir "v2vqemunbd." in - On_exit.rmdir piddir; + On_exit.rm_rf piddir; let id = unique () in let pidfile = piddir // sprintf "qemunbd%d.pid" id in diff --git a/lib/utils.ml b/lib/utils.ml index 7116a4f9..84b9a93f 100644 --- a/lib/utils.ml +++ b/lib/utils.ml @@ -204,7 +204,7 @@ let error_if_no_ssh_agent () = let create_v2v_directory () = let d = Mkdtemp.temp_dir "v2v." in chown_for_libvirt_rhbz_1045069 d; - On_exit.rmdir d; + On_exit.rm_rf d; d (* Wait for a file to appear until a timeout. *) diff --git a/output/python_script.ml b/output/python_script.ml index 54ccd1b5..ecf46c2d 100644 --- a/output/python_script.ml +++ b/output/python_script.ml @@ -33,7 +33,7 @@ type script = { let create ?(name = "script.py") code = let tmpdir = Mkdtemp.temp_dir "v2v." in - On_exit.rmdir tmpdir; + On_exit.rm_rf tmpdir; let path = tmpdir // name in with_open_out path (fun chan -> output_string chan code); { tmpdir; path }