Richard W.M. Jones
2014-Jun-24 15:56 UTC
[Libguestfs] [PATCH 0/2] Miscellaneous fixes to OCaml virt-* tools.
Two fixes to the OCaml virt-* tools.
Richard W.M. Jones
2014-Jun-24 15:56 UTC
[Libguestfs] [PATCH 1/2] mllib: Rewrite text wrapping function so it can handle newlines within the text.
--- mllib/common_utils.ml | 48 ++++++++++++++++++++++++++++++++---------------- mllib/common_utils.mli | 2 +- resize/resize.ml | 4 ++-- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml index 1ce2abe..e500ea4 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -57,25 +57,41 @@ let le32_of_int i String.unsafe_set s 3 (Char.unsafe_chr (Int64.to_int c3)); s -let output_spaces chan n = for i = 0 to n-1 do output_char chan ' ' done +type wrap_break_t = WrapEOS | WrapSpace | WrapNL -let wrap ?(chan = stdout) ?(hanging = 0) str - let rec _wrap col str - let n = String.length str in - let i = try String.index str ' ' with Not_found -> n in - let col - if col+i >= 72 then ( +let rec wrap ?(chan = stdout) ?(indent = 0) str + let len = String.length str in + _wrap chan indent 0 0 len str + +and _wrap chan indent column i len str + if i < len then ( + let (j, break) = _wrap_find_next_break i len str in + let next_column + if column + (j-i) >= 72 then ( output_char chan '\n'; - output_spaces chan hanging; - i+hanging+1 - ) else col+i+1 in - output_string chan (String.sub str 0 i); - if i < n then ( + output_spaces chan indent; + indent + (j-i) + 1 + ) + else column + (j-i) + 1 in + output chan str i (j-i); + match break with + | WrapEOS -> () + | WrapSpace -> output_char chan ' '; - _wrap col (String.sub str (i+1) (n-(i+1))) - ) - in - _wrap 0 str + _wrap chan indent next_column (j+1) len str + | WrapNL -> + output_char chan '\n'; + output_spaces chan indent; + _wrap chan indent indent (j+1) len str + ) + +and _wrap_find_next_break i len str + if i >= len then (len, WrapEOS) + else if String.unsafe_get str i = ' ' then (i, WrapSpace) + else if String.unsafe_get str i = '\n' then (i, WrapNL) + else _wrap_find_next_break (i+1) len str + +and output_spaces chan n = for i = 0 to n-1 do output_char chan ' ' done let string_prefix str prefix let n = String.length prefix in diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli index 16b9dee..792c7b5 100644 --- a/mllib/common_utils.mli +++ b/mllib/common_utils.mli @@ -31,7 +31,7 @@ val roundup64 : int64 -> int64 -> int64 val int_of_le32 : string -> int64 val le32_of_int : int64 -> string -val wrap : ?chan:out_channel -> ?hanging:int -> string -> unit +val wrap : ?chan:out_channel -> ?indent:int -> string -> unit (** Wrap text. *) val string_prefix : string -> string -> bool diff --git a/resize/resize.ml b/resize/resize.ml index dec23b1..7ae8c37 100644 --- a/resize/resize.ml +++ b/resize/resize.ml @@ -833,7 +833,7 @@ read the man page virt-resize(1). (expand_content_method p.p_type)) ) else "" in - wrap ~hanging:4 (text ^ "\n\n") + wrap ~indent:4 (text ^ "\n\n") ) partitions; List.iter ( @@ -852,7 +852,7 @@ read the man page virt-resize(1). (expand_content_method lv.lv_type)) ) else "" in - wrap ~hanging:4 (text ^ "\n\n") + wrap ~indent:4 (text ^ "\n\n") ) lvs; if surplus > 0L then ( -- 1.9.0
Richard W.M. Jones
2014-Jun-24 15:56 UTC
[Libguestfs] [PATCH 2/2] Use -v and -x flags consistently across OCaml virt-* tools.
virt-customize: virt-sparsify: virt-sysprep: virt-v2v: - These tools consistently used -v to mean verbose/debugging and -x to mean enable libguestfs tracing. virt-builder: virt-resize: - These two tools did not recognize -x at all, and used -v to enable libguestfs tracing and general debugging. - This commit changes these two tools to consume -v/-x consistently with the other tools. Unfortunately this has a cascade of effects through the code. --- builder/builder.ml | 45 +++++++++---------- builder/cache.ml | 6 +-- builder/cache.mli | 2 +- builder/cmdline.ml | 16 ++++--- builder/downloader.ml | 16 +++---- builder/downloader.mli | 4 +- builder/get_kernel.ml | 5 ++- builder/get_kernel.mli | 2 +- builder/index_parser.ml | 4 +- builder/index_parser.mli | 2 +- builder/sigchecker.ml | 30 ++++++------- builder/sigchecker.mli | 2 +- builder/sources.ml | 18 ++++---- builder/sources.mli | 2 +- builder/virt-builder.pod | 4 ++ customize/customize_main.ml | 2 +- customize/customize_run.ml | 10 ++--- customize/customize_run.mli | 2 +- customize/perl_edit.ml | 8 ++-- customize/perl_edit.mli | 2 +- mllib/common_utils.ml | 2 +- resize/resize.ml | 51 ++++++++++++---------- resize/virt-resize.pod | 4 ++ sysprep/main.ml | 4 +- sysprep/sysprep_operation.ml | 10 ++--- sysprep/sysprep_operation.mli | 8 ++-- sysprep/sysprep_operation_abrt_data.ml | 2 +- sysprep/sysprep_operation_bash_history.ml | 2 +- sysprep/sysprep_operation_blkid_tab.ml | 2 +- sysprep/sysprep_operation_ca_certificates.ml | 2 +- sysprep/sysprep_operation_crash_data.ml | 2 +- sysprep/sysprep_operation_cron_spool.ml | 2 +- sysprep/sysprep_operation_customize.ml | 4 +- sysprep/sysprep_operation_dhcp_client_state.ml | 2 +- sysprep/sysprep_operation_dhcp_server_state.ml | 2 +- sysprep/sysprep_operation_dovecot_data.ml | 2 +- sysprep/sysprep_operation_firewall_rules.ml | 2 +- sysprep/sysprep_operation_flag_reconfiguration.ml | 2 +- sysprep/sysprep_operation_fs_uuids.ml | 2 +- sysprep/sysprep_operation_kerberos_data.ml | 2 +- sysprep/sysprep_operation_logfiles.ml | 2 +- sysprep/sysprep_operation_lvm_uuids.ml | 2 +- sysprep/sysprep_operation_machine_id.ml | 2 +- sysprep/sysprep_operation_mail_spool.ml | 2 +- sysprep/sysprep_operation_net_hostname.ml | 2 +- sysprep/sysprep_operation_net_hwaddr.ml | 2 +- sysprep/sysprep_operation_pacct_log.ml | 2 +- sysprep/sysprep_operation_package_manager_cache.ml | 2 +- sysprep/sysprep_operation_pam_data.ml | 2 +- sysprep/sysprep_operation_puppet_data_log.ml | 2 +- .../sysprep_operation_rh_subscription_manager.ml | 2 +- sysprep/sysprep_operation_rhn_systemid.ml | 2 +- sysprep/sysprep_operation_rpm_db.ml | 2 +- sysprep/sysprep_operation_samba_db_log.ml | 2 +- sysprep/sysprep_operation_script.ml | 2 +- sysprep/sysprep_operation_smolt_uuid.ml | 2 +- sysprep/sysprep_operation_ssh_hostkeys.ml | 2 +- sysprep/sysprep_operation_ssh_userdir.ml | 2 +- sysprep/sysprep_operation_sssd_db_log.ml | 2 +- sysprep/sysprep_operation_tmp_files.ml | 2 +- sysprep/sysprep_operation_udev_persistent_net.ml | 2 +- sysprep/sysprep_operation_user_account.ml | 2 +- sysprep/sysprep_operation_utmp.ml | 2 +- sysprep/sysprep_operation_yum_uuid.ml | 2 +- 64 files changed, 179 insertions(+), 160 deletions(-) diff --git a/builder/builder.ml b/builder/builder.ml index 70c9430..213e93e 100644 --- a/builder/builder.ml +++ b/builder/builder.ml @@ -74,16 +74,17 @@ let remove_duplicates index let main () (* Command line argument parsing - see cmdline.ml. *) let mode, arg, - arch, attach, cache, check_signature, curl, debug, + arch, attach, cache, check_signature, curl, delete_on_failure, format, gpg, list_format, memsize, - network, ops, output, quiet, size, smp, sources, sync + network, ops, output, quiet, size, smp, sources, sync, + trace, verbose parse_cmdline () in (* Timestamped messages in ordinary, non-debug non-quiet mode. *) let msg fs = make_message_function ~quiet fs in (* If debugging, echo the command line arguments and the sources. *) - if debug then ( + if verbose then ( eprintf "command line:"; List.iter (eprintf " %s") (Array.to_list Sys.argv); prerr_newline (); @@ -97,7 +98,7 @@ let main () let mode match mode with | `Get_kernel -> (* --get-kernel is really a different program ... *) - Get_kernel.get_kernel ~debug ?format ?output arg; + Get_kernel.get_kernel ~trace ~verbose ?format ?output arg; exit 0 | `Delete_cache -> (* --delete-cache *) @@ -125,7 +126,7 @@ let main () eprintf (f_"%s: gpg is not installed (or does not work)\nYou should install gpg, or use --gpg option, or use --no-check-signature.\n") prog; exit 1 ) - else if debug then + else if verbose then warning ~prog (f_"gpg program is not available") ); @@ -148,7 +149,7 @@ let main () match cache with | None -> None | Some dir -> - try Some (Cache.create ~debug ~directory:dir) + try Some (Cache.create ~verbose ~directory:dir) with exn -> warning ~prog (f_"cache %s: %s") dir (Printexc.to_string exn); warning ~prog (f_"disabling the cache"); @@ -156,8 +157,8 @@ let main () in (* Download the sources. *) - let downloader = Downloader.create ~debug ~curl ~cache in - let repos = Sources.read_sources ~prog ~debug in + let downloader = Downloader.create ~verbose ~curl ~cache in + let repos = Sources.read_sources ~prog ~verbose in let repos = List.map ( fun { Sources.uri = uri; Sources.gpgkey = gpgkey; Sources.proxy = proxy } -> let gpgkey @@ -176,8 +177,8 @@ let main () List.map ( fun (source, key, proxy) -> let sigchecker - Sigchecker.create ~debug ~gpg ~check_signature ~gpgkey:key in - Index_parser.get_index ~prog ~debug ~downloader ~sigchecker ~proxy source + Sigchecker.create ~verbose ~gpg ~check_signature ~gpgkey:key in + Index_parser.get_index ~prog ~verbose ~downloader ~sigchecker ~proxy source ) sources ) in let index = remove_duplicates index in @@ -487,7 +488,7 @@ let main () in (* Print out the plan. *) - if debug then ( + if verbose then ( let print_tags tags (try let v = List.assoc `Filename tags in eprintf " +filename=%s" v @@ -543,14 +544,14 @@ let main () let ofile = List.assoc `Filename otags in msg (f_"Copying"); let cmd = sprintf "cp %s %s" (quote ifile) (quote ofile) in - if debug then eprintf "%s\n%!" cmd; + if verbose then eprintf "%s\n%!" cmd; if Sys.command cmd <> 0 then exit 1 | itags, `Rename, otags -> let ifile = List.assoc `Filename itags in let ofile = List.assoc `Filename otags in let cmd = sprintf "mv %s %s" (quote ifile) (quote ofile) in - if debug then eprintf "%s\n%!" cmd; + if verbose then eprintf "%s\n%!" cmd; if Sys.command cmd <> 0 then exit 1 | itags, `Pxzcat, otags -> @@ -573,11 +574,11 @@ let main () let preallocation = if oformat = "qcow2" then Some "metadata" else None in let () let g = new G.guestfs () in - if debug then ( g#set_trace true; g#set_verbose true ); + if verbose then ( g#set_trace true; g#set_verbose true ); g#disk_create ?preallocation ofile oformat osize in let cmd sprintf "virt-resize%s%s%s --output-format %s%s%s %s %s" - (if debug then " --verbose" else " --quiet") + (if verbose then " --verbose" else " --quiet") (if is_block_device ofile then " --no-sparse" else "") (match iformat with | None -> "" @@ -590,7 +591,7 @@ let main () | None -> "" | Some lvexpand -> sprintf " --lv-expand %s" (quote lvexpand)) (quote ifile) (quote ofile) in - if debug then eprintf "%s\n%!" cmd; + if verbose then eprintf "%s\n%!" cmd; if Sys.command cmd <> 0 then exit 1 | itags, `Disk_resize, otags -> @@ -600,8 +601,8 @@ let main () msg (f_"Resizing container (but not filesystems) to expand the disk to %s") (human_size osize); let cmd = sprintf "qemu-img resize %s %Ld%s" - (quote ofile) osize (if debug then "" else " >/dev/null") in - if debug then eprintf "%s\n%!" cmd; + (quote ofile) osize (if verbose then "" else " >/dev/null") in + if verbose then eprintf "%s\n%!" cmd; if Sys.command cmd <> 0 then exit 1 | itags, `Convert, otags -> @@ -617,8 +618,8 @@ let main () | None -> "" | Some iformat -> sprintf " -f %s" (quote iformat)) (quote ifile) (quote oformat) (quote ofile) - (if debug then "" else " >/dev/null 2>&1") in - if debug then eprintf "%s\n%!" cmd; + (if verbose then "" else " >/dev/null 2>&1") in + if verbose then eprintf "%s\n%!" cmd; if Sys.command cmd <> 0 then exit 1 ) plan; @@ -626,7 +627,7 @@ let main () msg (f_"Opening the new disk"); let g let g = new G.guestfs () in - if debug then g#set_trace true; + if verbose then g#set_trace true; (match memsize with None -> () | Some memsize -> g#set_memsize memsize); (match smp with None -> () | Some smp -> g#set_smp smp); @@ -665,7 +666,7 @@ let main () eprintf (f_"%s: no guest operating systems or multiboot OS found in this disk image\nThis is a failure of the source repository. Use -v for more information.\n") prog; exit 1 in - Customize_run.run ~prog ~debug ~quiet g root ops; + Customize_run.run ~prog ~verbose ~quiet g root ops; (* Collect some stats about the final output file. * Notes: diff --git a/builder/cache.ml b/builder/cache.ml index 683cd35..5471d49 100644 --- a/builder/cache.ml +++ b/builder/cache.ml @@ -29,15 +29,15 @@ let clean_cachedir dir ignore (Sys.command cmd); type t = { - debug : bool; + verbose : bool; directory : string; } -let create ~debug ~directory +let create ~verbose ~directory if not (is_directory directory) then mkdir directory 0o755; { - debug = debug; + verbose = verbose; directory = directory; } diff --git a/builder/cache.mli b/builder/cache.mli index 220ebcb..465e58b 100644 --- a/builder/cache.mli +++ b/builder/cache.mli @@ -24,7 +24,7 @@ val clean_cachedir : string -> unit type t (** The abstract data type. *) -val create : debug:bool -> directory:string -> t +val create : verbose:bool -> directory:string -> t (** Create the abstract type. *) val cache_of_name : t -> string -> string -> int -> string diff --git a/builder/cmdline.ml b/builder/cmdline.ml index 45c87fc..122c62b 100644 --- a/builder/cmdline.ml +++ b/builder/cmdline.ml @@ -60,7 +60,6 @@ let parse_cmdline () let check_signature = ref true in let curl = ref "curl" in - let debug = ref false in let delete_on_failure = ref true in @@ -101,6 +100,8 @@ let parse_cmdline () let add_source arg = sources := arg :: !sources in let sync = ref true in + let trace = ref false in + let verbose = ref false in let argspec = [ "--arch", Arg.Set_string arch, "arch" ^ " " ^ s_"Set the output architecture"; @@ -151,10 +152,11 @@ let parse_cmdline () "--smp", Arg.Int set_smp, "vcpus" ^ " " ^ s_"Set number of vCPUs"; "--source", Arg.String add_source, "URL" ^ " " ^ s_"Set source URL"; "--no-sync", Arg.Clear sync, " " ^ s_"Do not fsync output file on exit"; - "-v", Arg.Set debug, " " ^ s_"Enable debugging messages"; - "--verbose", Arg.Set debug, " " ^ s_"Enable debugging messages"; + "-v", Arg.Set verbose, " " ^ s_"Enable debugging messages"; + "--verbose", Arg.Set verbose, " " ^ s_"Enable debugging messages"; "-V", Arg.Unit display_version, " " ^ s_"Display version and exit"; "--version", Arg.Unit display_version, " " ^ s_"Display version and exit"; + "-x", Arg.Set trace, " " ^ s_"Enable tracing of libguestfs calls"; ] in let customize_argspec, get_customize_ops Customize_cmdline.argspec ~prog () in @@ -198,7 +200,6 @@ read the man page virt-builder(1). let cache = !cache in let check_signature = !check_signature in let curl = !curl in - let debug = !debug in let delete_on_failure = !delete_on_failure in let fingerprints = List.rev !fingerprints in let format = match !format with "" -> None | s -> Some s in @@ -214,6 +215,8 @@ read the man page virt-builder(1). let smp = !smp in let sources = List.rev !sources in let sync = !sync in + let trace = !trace in + let verbose = !verbose in (* No arguments and machine-readable mode? Print some facts. *) if args = [] && machine_readable then ( @@ -339,6 +342,7 @@ read the man page virt-builder(1). ) in mode, arg, - arch, attach, cache, check_signature, curl, debug, + arch, attach, cache, check_signature, curl, delete_on_failure, format, gpg, list_format, memsize, - network, ops, output, quiet, size, smp, sources, sync + network, ops, output, quiet, size, smp, sources, sync, + trace, verbose diff --git a/builder/downloader.ml b/builder/downloader.ml index 9fed774..011ed1c 100644 --- a/builder/downloader.ml +++ b/builder/downloader.ml @@ -28,7 +28,7 @@ type uri = string type filename = string type t = { - debug : bool; + verbose : bool; curl : string; cache : Cache.t option; (* cache for templates *) } @@ -38,8 +38,8 @@ type proxy_mode | SystemProxy | ForcedProxy of string -let create ~debug ~curl ~cache = { - debug = debug; +let create ~verbose ~curl ~cache = { + verbose = verbose; curl = curl; cache = cache; } @@ -88,7 +88,7 @@ and download_to ~prog t ?(progress_bar = false) ~proxy uri filename | "file" -> let path = parseduri.URI.path in let cmd = sprintf "cp%s %s %s" - (if t.debug then " -v" else "") + (if t.verbose then " -v" else "") (quote path) (quote filename_new) in let r = Sys.command cmd in if r <> 0 then ( @@ -102,9 +102,9 @@ and download_to ~prog t ?(progress_bar = false) ~proxy uri filename let cmd = sprintf "%s%s%s -g -o /dev/null -I -w '%%{http_code}' %s" outenv t.curl - (if t.debug then "" else " -s -S") + (if t.verbose then "" else " -s -S") (quote uri) in - if t.debug then eprintf "%s\n%!" cmd; + if t.verbose then eprintf "%s\n%!" cmd; let lines = external_command ~prog cmd in if List.length lines < 1 then ( eprintf (f_"%s: unexpected output from curl command, enable debug and look at previous messages\n") @@ -128,9 +128,9 @@ and download_to ~prog t ?(progress_bar = false) ~proxy uri filename let cmd = sprintf "%s%s%s -g -o %s %s" outenv t.curl - (if t.debug then "" else if progress_bar then " -#" else " -s -S") + (if t.verbose then "" else if progress_bar then " -#" else " -s -S") (quote filename_new) (quote uri) in - if t.debug then eprintf "%s\n%!" cmd; + if t.verbose then eprintf "%s\n%!" cmd; let r = Sys.command cmd in if r <> 0 then ( eprintf (f_"%s: curl (download) command failed downloading '%s'\n") diff --git a/builder/downloader.mli b/builder/downloader.mli index a10cdca..2721f79 100644 --- a/builder/downloader.mli +++ b/builder/downloader.mli @@ -32,7 +32,7 @@ type proxy_mode *) | ForcedProxy of string (* The proxy is forced to the specified URL. *) -val create : debug:bool -> curl:string -> cache:Cache.t option -> t +val create : verbose:bool -> curl:string -> cache:Cache.t option -> t (** Create the abstract type. *) val download : prog:string -> t -> ?template:(string*string*int) -> ?progress_bar:bool -> ?proxy:proxy_mode -> uri -> (filename * bool) @@ -46,7 +46,7 @@ val download : prog:string -> t -> ?template:(string*string*int) -> ?progress_ba and revision are used for cache control (see the man page for details). If [~progress_bar:true] then display a progress bar if the file - doesn't come from the cache. In debug mode, progress messages + doesn't come from the cache. In verbose mode, progress messages are always displayed. [proxy] specifies the type of proxy to be used in the transfer, diff --git a/builder/get_kernel.ml b/builder/get_kernel.ml index 7f93728..47518d4 100644 --- a/builder/get_kernel.ml +++ b/builder/get_kernel.ml @@ -26,9 +26,10 @@ open Printf (* Originally: * http://rwmj.wordpress.com/2013/09/13/get-kernel-and-initramfs-from-a-disk-image/ *) -let rec get_kernel ~debug ?format ?output disk +let rec get_kernel ~trace ~verbose ?format ?output disk let g = new G.guestfs () in - if debug then g#set_trace true; + if trace then g#set_trace true; + if verbose then g#set_verbose true; g#add_drive_opts ?format ~readonly:true disk; g#launch (); diff --git a/builder/get_kernel.mli b/builder/get_kernel.mli index 7c48f25..20f9ddd 100644 --- a/builder/get_kernel.mli +++ b/builder/get_kernel.mli @@ -16,4 +16,4 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) -val get_kernel : debug:bool -> ?format:string -> ?output:string -> string -> unit +val get_kernel : trace:bool -> verbose:bool -> ?format:string -> ?output:string -> string -> unit diff --git a/builder/index_parser.ml b/builder/index_parser.ml index 7ccbece..0c8bf1a 100644 --- a/builder/index_parser.ml +++ b/builder/index_parser.ml @@ -109,7 +109,7 @@ let print_entry chan (name, { printable_name = printable_name; ); if hidden then fp "hidden=true\n" -let get_index ~prog ~debug ~downloader ~sigchecker ~proxy source +let get_index ~prog ~verbose ~downloader ~sigchecker ~proxy source let corrupt_file () eprintf (f_"\nThe index file downloaded from '%s' is corrupt.\nYou need to ask the supplier of this file to fix it and upload a fixed version.\n") source; @@ -279,7 +279,7 @@ let get_index ~prog ~debug ~downloader ~sigchecker ~proxy source n, entry ) sections in - if debug then ( + if verbose then ( eprintf "index file (%s) after parsing (C parser):\n" source; List.iter (print_entry Pervasives.stderr) entries ); diff --git a/builder/index_parser.mli b/builder/index_parser.mli index ccf38e8..e25fcc7 100644 --- a/builder/index_parser.mli +++ b/builder/index_parser.mli @@ -38,4 +38,4 @@ and entry = { proxy : Downloader.proxy_mode; } -val get_index : prog:string -> debug:bool -> downloader:Downloader.t -> sigchecker:Sigchecker.t -> proxy:Downloader.proxy_mode -> string -> index +val get_index : prog:string -> verbose:bool -> downloader:Downloader.t -> sigchecker:Sigchecker.t -> proxy:Downloader.proxy_mode -> string -> index diff --git a/builder/sigchecker.ml b/builder/sigchecker.ml index ae8e413..c35d2da 100644 --- a/builder/sigchecker.ml +++ b/builder/sigchecker.ml @@ -30,7 +30,7 @@ type gpgkey_type | KeyFile of string type t = { - debug : bool; + verbose : bool; gpg : string; fingerprint : string; check_signature : bool; @@ -38,13 +38,13 @@ type t = { } (* Import the specified key file. *) -let import_keyfile ~gpg ~gpghome ~debug keyfile +let import_keyfile ~gpg ~gpghome ~verbose keyfile let status_file = Filename.temp_file "vbstat" ".txt" in unlink_on_exit status_file; let cmd = sprintf "%s --homedir %s --status-file %s --import %s%s" gpg gpghome (quote status_file) (quote keyfile) - (if debug then "" else " >/dev/null 2>&1") in - if debug then eprintf "%s\n%!" cmd; + (if verbose then "" else " >/dev/null 2>&1") in + if verbose then eprintf "%s\n%!" cmd; let r = Sys.command cmd in if r <> 0 then ( eprintf (f_"virt-builder: error: could not import public key\nUse the '-v' option and look for earlier error messages.\n"); @@ -52,7 +52,7 @@ let import_keyfile ~gpg ~gpghome ~debug keyfile ); status_file -let rec create ~debug ~gpg ~gpgkey ~check_signature +let rec create ~verbose ~gpg ~gpgkey ~check_signature (* Create a temporary directory for gnupg. *) let tmpdir = Mkdtemp.mkdtemp (Filename.temp_dir_name // "vb.gpghome.XXXXXX") in rmdir_on_exit tmpdir; @@ -67,8 +67,8 @@ let rec create ~debug ~gpg ~gpgkey ~check_signature * cannot. *) let cmd = sprintf "%s --homedir %s --list-keys%s" - gpg tmpdir (if debug then "" else " >/dev/null 2>&1") in - if debug then eprintf "%s\n%!" cmd; + gpg tmpdir (if verbose then "" else " >/dev/null 2>&1") in + if verbose then eprintf "%s\n%!" cmd; let r = Sys.command cmd in if r <> 0 then ( eprintf (f_"virt-builder: error: GPG failure: could not run GPG the first time\nUse the '-v' option and look for earlier error messages.\n"); @@ -78,7 +78,7 @@ let rec create ~debug ~gpg ~gpgkey ~check_signature | No_Key -> assert false | KeyFile kf -> - let status_file = import_keyfile gpg tmpdir debug kf in + let status_file = import_keyfile gpg tmpdir verbose kf in let status = read_whole_file status_file in let status = string_nsplit "\n" status in let fingerprint = ref "" in @@ -95,19 +95,19 @@ let rec create ~debug ~gpg ~gpgkey ~check_signature unlink_on_exit filename; let cmd = sprintf "%s --yes --armor --output %s --export %s%s" gpg (quote filename) (quote fp) - (if debug then "" else " >/dev/null 2>&1") in - if debug then eprintf "%s\n%!" cmd; + (if verbose then "" else " >/dev/null 2>&1") in + if verbose then eprintf "%s\n%!" cmd; let r = Sys.command cmd in if r <> 0 then ( eprintf (f_"virt-builder: error: could not export public key\nUse the '-v' option and look for earlier error messages.\n"); exit 1 ); - ignore (import_keyfile gpg tmpdir debug filename); + ignore (import_keyfile gpg tmpdir verbose filename); fp ) else "" in { - debug = debug; + verbose = verbose; gpg = gpg; fingerprint = fingerprint; check_signature = check_signature; @@ -161,9 +161,9 @@ and do_verify t args let cmd sprintf "%s --homedir %s --verify%s --status-file %s %s" t.gpg t.gpghome - (if t.debug then "" else " -q --logger-file /dev/null") + (if t.verbose then "" else " -q --logger-file /dev/null") (quote status_file) args in - if t.debug then eprintf "%s\n%!" cmd; + if t.verbose then eprintf "%s\n%!" cmd; let r = Sys.command cmd in if r <> 0 then ( eprintf (f_"virt-builder: error: GPG failure: could not verify digital signature of file\nTry:\n - Use the '-v' option and look for earlier error messages.\n - Delete the cache: virt-builder --delete-cache\n - Check no one has tampered with the website or your network!\n"); @@ -196,7 +196,7 @@ let verify_checksum t (SHA512 csum) filename unlink_on_exit csum_file; let cmd = sprintf "sha512sum %s | awk '{print $1}' > %s" (quote filename) (quote csum_file) in - if t.debug then eprintf "%s\n%!" cmd; + if t.verbose then eprintf "%s\n%!" cmd; let r = Sys.command cmd in if r <> 0 then ( eprintf (f_"virt-builder: error: could not run sha512sum command to verify checksum\n"); diff --git a/builder/sigchecker.mli b/builder/sigchecker.mli index 8c6ba7f..5b1885b 100644 --- a/builder/sigchecker.mli +++ b/builder/sigchecker.mli @@ -23,7 +23,7 @@ type gpgkey_type | Fingerprint of string | KeyFile of string -val create : debug:bool -> gpg:string -> gpgkey:gpgkey_type -> check_signature:bool -> t +val create : verbose:bool -> gpg:string -> gpgkey:gpgkey_type -> check_signature:bool -> t val verify : t -> string -> unit (** Verify the file is signed (if check_signature is true). *) diff --git a/builder/sources.ml b/builder/sources.ml index be1c27d..a752edc 100644 --- a/builder/sources.ml +++ b/builder/sources.ml @@ -31,8 +31,8 @@ type source = { module StringSet = Set.Make (String) -let parse_conf ~prog ~debug file - if debug then ( +let parse_conf ~prog ~verbose file + if verbose then ( eprintf (f_"%s: trying to read %s\n") prog file; ); let sections = Ini_reader.read_ini ~prog ~error_suffix:"[ignored]" file in @@ -51,7 +51,7 @@ let parse_conf ~prog ~debug file try Some (URI.parse_uri (List.assoc ("gpgkey", None) fields)) with | Not_found -> None | Invalid_argument "URI.parse_uri" as ex -> - if debug then ( + if verbose then ( eprintf (f_"%s: '%s' has invalid gpgkey URI\n") prog n; ); raise ex in @@ -61,7 +61,7 @@ let parse_conf ~prog ~debug file (match uri.URI.protocol with | "file" -> Some uri.URI.path | _ -> - if debug then ( + if verbose then ( eprintf (f_"%s: '%s' has non-local gpgkey URI\n") prog n; ); None @@ -83,7 +83,7 @@ let parse_conf ~prog ~debug file with Not_found | Invalid_argument _ -> acc ) sections [] in - if debug then ( + if verbose then ( eprintf (f_"%s: ... read %d sources\n") prog (List.length sources); ); @@ -101,7 +101,7 @@ let merge_sources current_sources new_sources let filter_filenames filename Filename.check_suffix filename ".conf" -let read_sources ~prog ~debug +let read_sources ~prog ~verbose let dirs = Paths.xdg_config_dirs ~prog in let dirs match Paths.xdg_config_home ~prog with @@ -118,7 +118,7 @@ let read_sources ~prog ~debug List.fold_left ( fun acc file -> try ( - let s = merge_sources acc (parse_conf ~prog ~debug (dir // file)) in + let s = merge_sources acc (parse_conf ~prog ~verbose (dir // file)) in (* Add the current file name to the set only if its parsing * was successful. *) @@ -126,12 +126,12 @@ let read_sources ~prog ~debug s ) with | Unix_error (code, fname, _) -> - if debug then ( + if verbose then ( eprintf (f_"%s: file error: %s: %s\n") prog fname (error_message code) ); acc | Invalid_argument msg -> - if debug then ( + if verbose then ( eprintf (f_"%s: internal error: invalid argument: %s\n") prog msg ); acc diff --git a/builder/sources.mli b/builder/sources.mli index 0ade536..3e31d35 100644 --- a/builder/sources.mli +++ b/builder/sources.mli @@ -23,4 +23,4 @@ type source = { proxy : Downloader.proxy_mode; } -val read_sources : prog:string -> debug:bool -> source list +val read_sources : prog:string -> verbose:bool -> source list diff --git a/builder/virt-builder.pod b/builder/virt-builder.pod index a70767f..323016c 100644 --- a/builder/virt-builder.pod +++ b/builder/virt-builder.pod @@ -500,6 +500,10 @@ your bug report. Display version number and exit. +=item B<-x> + +Enable tracing of libguestfs API calls. + =back =head2 Customization options diff --git a/customize/customize_main.ml b/customize/customize_main.ml index 00d5bae..7229943 100644 --- a/customize/customize_main.ml +++ b/customize/customize_main.ml @@ -228,7 +228,7 @@ read the man page virt-customize(1). ) mps; (* Do the customization. *) - Customize_run.run ~prog ~debug:verbose ~quiet g root ops; + Customize_run.run ~prog ~verbose ~quiet g root ops; g#umount_all (); ) roots; diff --git a/customize/customize_run.ml b/customize/customize_run.ml index 57b888f..af1bf86 100644 --- a/customize/customize_run.ml +++ b/customize/customize_run.ml @@ -27,7 +27,7 @@ open Password let quote = Filename.quote -let run ~prog ~debug ~quiet (g : Guestfs.guestfs) root (ops : ops) +let run ~prog ~verbose ~quiet (g : Guestfs.guestfs) root (ops : ops) (* Timestamped messages in ordinary, non-debug non-quiet mode. *) let msg fs = make_message_function ~quiet fs in @@ -75,7 +75,7 @@ exec >>%s 2>&1 %s " (quote logfile) env_vars cmd in - if debug then eprintf "running command:\n%s\n%!" cmd; + if verbose then eprintf "running command:\n%s\n%!" cmd; try ignore (g#sh cmd) with Guestfs.Error msg -> @@ -193,7 +193,7 @@ exec >>%s 2>&1 exit 1 ); - Perl_edit.edit_file ~debug g path expr + Perl_edit.edit_file ~verbose g path expr | `FirstbootCommand cmd -> incr i; @@ -313,7 +313,7 @@ exec >>%s 2>&1 * If debugging, dump out the log file. * Then if asked, scrub the log file. *) - if debug then debug_logfile (); + if verbose then debug_logfile (); if ops.flags.scrub_logfile && g#exists logfile then ( msg (f_"Scrubbing the log file"); @@ -330,7 +330,7 @@ exec >>%s 2>&1 *) (try ignore (g#debug "sh" [| "fuser"; "-k"; "/sysroot" |]) with exn -> - if debug then + if verbose then eprintf (f_"%s: %s (ignored)\n") prog (Printexc.to_string exn) ); g#ping_daemon () (* tiny delay after kill *) diff --git a/customize/customize_run.mli b/customize/customize_run.mli index 0fa7683..0b375eb 100644 --- a/customize/customize_run.mli +++ b/customize/customize_run.mli @@ -23,4 +23,4 @@ * filesystems must be mounted up. *) -val run : prog:string -> debug:bool -> quiet:bool -> Guestfs.guestfs -> string -> Customize_cmdline.ops -> unit +val run : prog:string -> verbose:bool -> quiet:bool -> Guestfs.guestfs -> string -> Customize_cmdline.ops -> unit diff --git a/customize/perl_edit.ml b/customize/perl_edit.ml index 28e5dea..e44ff69 100644 --- a/customize/perl_edit.ml +++ b/customize/perl_edit.ml @@ -25,7 +25,7 @@ open Printf * * Code copied from virt-edit. *) -let rec edit_file ~debug (g : Guestfs.guestfs) file expr +let rec edit_file ~verbose (g : Guestfs.guestfs) file expr let file_old = file ^ "~" in g#rename file file_old; @@ -34,7 +34,7 @@ let rec edit_file ~debug (g : Guestfs.guestfs) file expr unlink_on_exit tmpfile; g#download file_old tmpfile; - do_perl_edit ~debug g tmpfile expr; + do_perl_edit ~verbose g tmpfile expr; (* Upload the file. Unlike virt-edit we can afford to fail here * so we don't need the temporary upload file. @@ -45,7 +45,7 @@ let rec edit_file ~debug (g : Guestfs.guestfs) file expr g#copy_attributes ~all:true file_old file; g#rm file_old -and do_perl_edit ~debug g file expr +and do_perl_edit ~verbose g file expr (* Pass the expression to Perl via the environment. This sidesteps * any quoting problems with the already complex Perl command line. *) @@ -65,7 +65,7 @@ and do_perl_edit ~debug g file expr close STDOUT or die \"close: $!\"; ' < %s > %s.out" file file in - if debug then + if verbose then eprintf "%s\n%!" cmd; let r = Sys.command cmd in diff --git a/customize/perl_edit.mli b/customize/perl_edit.mli index fd30dcc..e84ac08 100644 --- a/customize/perl_edit.mli +++ b/customize/perl_edit.mli @@ -16,4 +16,4 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) -val edit_file : debug:bool -> Guestfs.guestfs -> string -> string -> unit +val edit_file : verbose:bool -> Guestfs.guestfs -> string -> string -> unit diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml index e500ea4..6c7ac34 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -217,7 +217,7 @@ let error ~prog ?(exit_code = 1) fs prerr_newline (); prerr_newline (); wrap ~chan:stderr - (sprintf (f_"%s: If reporting bugs, run %s with debugging enabled (-v) and include the complete output.") + (sprintf (f_"%s: If reporting bugs, run %s with debugging enabled (-v -x) and include the complete output.") prog prog); prerr_newline (); exit exit_code diff --git a/resize/resize.ml b/resize/resize.ml index 7ae8c37..9614ec7 100644 --- a/resize/resize.ml +++ b/resize/resize.ml @@ -132,10 +132,10 @@ let string_of_expand_content_method = function (* Main program. *) let main () let infile, outfile, align_first, alignment, copy_boot_loader, - debug, debug_gc, deletes, + debug_gc, deletes, dryrun, expand, expand_content, extra_partition, format, ignores, lv_expands, machine_readable, ntfsresize_force, output_format, - quiet, resizes, resizes_force, shrink, sparse + quiet, resizes, resizes_force, shrink, sparse, trace, verbose let display_version () printf "virt-resize %s\n" Config.package_version; exit 0 @@ -146,7 +146,6 @@ let main () let align_first = ref "auto" in let alignment = ref 128 in let copy_boot_loader = ref true in - let debug = ref false in let debug_gc = ref false in let deletes = ref [] in let dryrun = ref false in @@ -174,14 +173,16 @@ let main () else shrink := s in let sparse = ref true in + let trace = ref false in + let verbose = ref false in let ditto = " -\"-" in let argspec = Arg.align [ "--align-first", Arg.Set_string align_first, s_"never|always|auto" ^ " " ^ s_"Align first partition (default: auto)"; "--alignment", Arg.Set_int alignment, s_"sectors" ^ " " ^ s_"Set partition alignment (default: 128 sectors)"; "--no-copy-boot-loader", Arg.Clear copy_boot_loader, " " ^ s_"Don't copy boot loader"; - "-d", Arg.Set debug, " " ^ s_"Enable debugging messages"; - "--debug", Arg.Set debug, ditto; + "-d", Arg.Set verbose, " " ^ s_"Enable debugging messages"; + "--debug", Arg.Set verbose, ditto; "--debug-gc",Arg.Set debug_gc, " " ^ s_"Debug GC and memory allocations"; "--delete", Arg.String (add deletes), s_"part" ^ " " ^ s_"Delete partition"; "--expand", Arg.String set_expand, s_"part" ^ " " ^ s_"Expand partition"; @@ -206,10 +207,11 @@ let main () "--resize-force", Arg.String (add resizes_force), s_"part=size" ^ " " ^ s_"Forcefully resize partition"; "--shrink", Arg.String set_shrink, s_"part" ^ " " ^ s_"Shrink partition"; "--no-sparse", Arg.Clear sparse, " " ^ s_"Turn off sparse copying"; - "-v", Arg.Set debug, " " ^ s_"Enable debugging messages"; - "--verbose", Arg.Set debug, ditto; + "-v", Arg.Set verbose, " " ^ s_"Enable debugging messages"; + "--verbose", Arg.Set verbose, ditto; "-V", Arg.Unit display_version, " " ^ s_"Display version and exit"; "--version", Arg.Unit display_version, ditto; + "-x", Arg.Set trace, " " ^ s_"Enable tracing of libguestfs calls"; ] in long_options := argspec; let disks = ref [] in @@ -224,8 +226,8 @@ read the man page virt-resize(1). prog in Arg.parse argspec anon_fun usage_msg; - let debug = !debug in - if debug then ( + let verbose = !verbose in + if verbose then ( eprintf "command line:"; List.iter (eprintf " %s") (Array.to_list Sys.argv); prerr_newline () @@ -251,6 +253,7 @@ read the man page virt-resize(1). let resizes_force = List.rev !resizes_force in let shrink = match !shrink with "" -> None | str -> Some str in let sparse = !sparse in + let trace = !trace in if alignment < 1 then error (f_"alignment cannot be < 1"); @@ -308,10 +311,10 @@ read the man page virt-resize(1). infile in infile, outfile, align_first, alignment, copy_boot_loader, - debug, debug_gc, deletes, + debug_gc, deletes, dryrun, expand, expand_content, extra_partition, format, ignores, lv_expands, machine_readable, ntfsresize_force, output_format, - quiet, resizes, resizes_force, shrink, sparse in + quiet, resizes, resizes_force, shrink, sparse, trace, verbose in (* Default to true, since NTFS and btrfs support are usually available. *) let ntfs_available = ref true in @@ -320,7 +323,8 @@ read the man page virt-resize(1). (* Add in and out disks to the handle and launch. *) let connect_both_disks () let g = new G.guestfs () in - if debug then g#set_trace true; + if trace then g#set_trace true; + if verbose then g#set_verbose true; let _, { URI.path = path; protocol = protocol; server = server; username = username; password = password } = infile in @@ -361,7 +365,7 @@ read the man page virt-resize(1). let sectsize = g#blockdev_getss "/dev/sdb" in let insize = g#blockdev_getsize64 "/dev/sda" in let outsize = g#blockdev_getsize64 "/dev/sdb" in - if debug then ( + if verbose then ( eprintf "%s size %Ld bytes\n" (fst infile) insize; eprintf "%s size %Ld bytes\n" outfile outsize ); @@ -391,7 +395,7 @@ read the man page virt-resize(1). (* Get the source partition type. *) let parttype, parttype_string let pt = g#part_get_parttype "/dev/sda" in - if debug then eprintf "partition table type: %s\n%!" pt; + if verbose then eprintf "partition table type: %s\n%!" pt; match pt with | "msdos" -> MBR, "msdos" @@ -477,7 +481,7 @@ read the man page virt-resize(1). p_target_start = 0L; p_target_end = 0L } ) parts in - if debug then ( + if verbose then ( eprintf "%d partitions found\n" (List.length partitions); List.iter debug_partition partitions ); @@ -529,7 +533,7 @@ read the man page virt-resize(1). { lv_name = name; lv_type = typ; lv_operation = LVOpNone } ) lvs in - if debug then ( + if verbose then ( eprintf "%d logical volumes found\n" (List.length lvs); List.iter debug_logvol lvs ); @@ -735,7 +739,7 @@ read the man page virt-resize(1). let surplus = outsize -^ (required +^ overhead) in - if debug then + if verbose then eprintf "calculate surplus: outsize=%Ld required=%Ld overhead=%Ld surplus=%Ld\n%!" outsize required overhead surplus; @@ -749,7 +753,7 @@ read the man page virt-resize(1). if expand <> None || shrink <> None then ( let surplus = calculate_surplus () in - if debug then + if verbose then eprintf "surplus before --expand or --shrink: %Ld\n" surplus; (match expand with @@ -991,7 +995,7 @@ read the man page virt-resize(1). | `Always, _ | `Auto, true -> true in - if debug then + if verbose then eprintf "align_first_partition_and_fix_bootloader = %b\n%!" align_first_partition_and_fix_bootloader; @@ -1017,7 +1021,7 @@ read the man page virt-resize(1). let end_ = start +^ size in let next = roundup64 end_ alignment in - if debug then + if verbose then eprintf "target partition %d: ignore or copy: start=%Ld end=%Ld\n%!" partnum start (end_ -^ 1L); @@ -1031,7 +1035,7 @@ read the man page virt-resize(1). let next = start +^ size in let next = roundup64 next alignment in - if debug then + if verbose then eprintf "target partition %d: resize: newsize=%Ld start=%Ld end=%Ld\n%!" partnum newsize start (next -^ 1L); @@ -1165,7 +1169,7 @@ read the man page virt-resize(1). if not quiet then printf (f_"Fixing first NTFS partition boot record ...\n%!"); - if debug then ( + if verbose then ( let old_hidden = int_of_le32 (g#pread_device target 4 0x1c_L) in eprintf "old hidden sectors value: 0x%Lx\n%!" old_hidden ); @@ -1207,7 +1211,8 @@ read the man page virt-resize(1). g#close (); let g = new G.guestfs () in - if debug then g#set_trace true; + if trace then g#set_trace true; + if verbose then g#set_verbose true; (* The output disk is being created, so use cache=unsafe here. *) g#add_drive ?format:output_format ~readonly:false ~cachemode:"unsafe" outfile; diff --git a/resize/virt-resize.pod b/resize/virt-resize.pod index 0fd7e9e..2c1f901 100644 --- a/resize/virt-resize.pod +++ b/resize/virt-resize.pod @@ -586,6 +586,10 @@ Enable debugging messages. Display version number and exit. +=item B<-x> + +Enable tracing of libguestfs API calls. + =back =head1 MACHINE READABLE OUTPUT diff --git a/sysprep/main.ml b/sysprep/main.ml index 37e4dc8..ef5d8c9 100644 --- a/sysprep/main.ml +++ b/sysprep/main.ml @@ -270,7 +270,7 @@ let do_sysprep () (* Perform the filesystem operations. *) Sysprep_operation.perform_operations_on_filesystems - ?operations ~debug:verbose ~quiet g root side_effects; + ?operations ~verbose ~quiet g root side_effects; (* Unmount everything in this guest. *) g#umount_all (); @@ -279,7 +279,7 @@ let do_sysprep () (* Perform the block device operations. *) Sysprep_operation.perform_operations_on_devices - ?operations ~debug:verbose ~quiet g root side_effects; + ?operations ~verbose ~quiet g root side_effects; ) roots (* Finished. *) diff --git a/sysprep/sysprep_operation.ml b/sysprep/sysprep_operation.ml index 4914a97..19ccfe0 100644 --- a/sysprep/sysprep_operation.ml +++ b/sysprep/sysprep_operation.ml @@ -33,7 +33,7 @@ end class device_side_effects = object end -type 'a callback = debug:bool -> quiet:bool -> Guestfs.guestfs -> string -> 'a -> unit +type 'a callback = verbose:bool -> quiet:bool -> Guestfs.guestfs -> string -> 'a -> unit type operation = { order : int; @@ -276,7 +276,7 @@ let compare_operations { order = o1; name = n1 } { order = o2; name = n2 } let i = compare o1 o2 in if i <> 0 then i else compare n1 n2 -let perform_operations_on_filesystems ?operations ~debug ~quiet g root +let perform_operations_on_filesystems ?operations ~verbose ~quiet g root side_effects assert !baked; @@ -295,11 +295,11 @@ let perform_operations_on_filesystems ?operations ~debug ~quiet g root function | { name = name; perform_on_filesystems = Some fn } -> msg "Performing %S ..." name; - fn ~debug ~quiet g root side_effects + fn ~verbose ~quiet g root side_effects | { perform_on_filesystems = None } -> () ) ops -let perform_operations_on_devices ?operations ~debug ~quiet g root +let perform_operations_on_devices ?operations ~verbose ~quiet g root side_effects assert !baked; @@ -318,6 +318,6 @@ let perform_operations_on_devices ?operations ~debug ~quiet g root function | { name = name; perform_on_devices = Some fn } -> msg "Performing %S ..." name; - fn ~debug ~quiet g root side_effects + fn ~verbose ~quiet g root side_effects | { perform_on_devices = None } -> () ) ops diff --git a/sysprep/sysprep_operation.mli b/sysprep/sysprep_operation.mli index 03859ae..c2057ed 100644 --- a/sysprep/sysprep_operation.mli +++ b/sysprep/sysprep_operation.mli @@ -30,8 +30,8 @@ end class device_side_effects : object end (** There are currently no device side-effects. For future use. *) -type 'side_effects callback = debug:bool -> quiet:bool -> Guestfs.guestfs -> string -> 'side_effects -> unit -(** [callback ~debug ~quiet g root side_effects] is called to do work. +type 'side_effects callback = verbose:bool -> quiet:bool -> Guestfs.guestfs -> string -> 'side_effects -> unit +(** [callback ~verbose ~quiet g root side_effects] is called to do work. If the operation has side effects such as creating files, it should indicate that by calling the [side_effects] object. *) @@ -169,8 +169,8 @@ val remove_all_from_set : set -> set (** [remove_all_from_set set] removes from [set] all the available operations. *) -val perform_operations_on_filesystems : ?operations:set -> debug:bool -> quiet:bool -> Guestfs.guestfs -> string -> filesystem_side_effects -> unit +val perform_operations_on_filesystems : ?operations:set -> verbose:bool -> quiet:bool -> Guestfs.guestfs -> string -> filesystem_side_effects -> unit (** Perform all operations, or the subset listed in the [operations] set. *) -val perform_operations_on_devices : ?operations:set -> debug:bool -> quiet:bool -> Guestfs.guestfs -> string -> device_side_effects -> unit +val perform_operations_on_devices : ?operations:set -> verbose:bool -> quiet:bool -> Guestfs.guestfs -> string -> device_side_effects -> unit (** Perform all operations, or the subset listed in the [operations] set. *) diff --git a/sysprep/sysprep_operation_abrt_data.ml b/sysprep/sysprep_operation_abrt_data.ml index 94d8dd7..fb16ea2 100644 --- a/sysprep/sysprep_operation_abrt_data.ml +++ b/sysprep/sysprep_operation_abrt_data.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let abrt_data_perform ~debug ~quiet g root side_effects +let abrt_data_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let paths = g#glob_expand "/var/spool/abrt/*" in diff --git a/sysprep/sysprep_operation_bash_history.ml b/sysprep/sysprep_operation_bash_history.ml index fdc0786..01f9962 100644 --- a/sysprep/sysprep_operation_bash_history.ml +++ b/sysprep/sysprep_operation_bash_history.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let bash_history_perform ~debug ~quiet g root side_effects +let bash_history_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let files = g#glob_expand "/home/*/.bash_history" in diff --git a/sysprep/sysprep_operation_blkid_tab.ml b/sysprep/sysprep_operation_blkid_tab.ml index f85e987..54d066f 100644 --- a/sysprep/sysprep_operation_blkid_tab.ml +++ b/sysprep/sysprep_operation_blkid_tab.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let blkid_tab_perform ~debug ~quiet g root side_effects +let blkid_tab_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let files = [ "/var/run/blkid.tab"; diff --git a/sysprep/sysprep_operation_ca_certificates.ml b/sysprep/sysprep_operation_ca_certificates.ml index c846b25..aa2e115 100644 --- a/sysprep/sysprep_operation_ca_certificates.ml +++ b/sysprep/sysprep_operation_ca_certificates.ml @@ -22,7 +22,7 @@ open Common_gettext.Gettext module StringSet = Set.Make (String) module G = Guestfs -let ca_certificates_perform ~debug ~quiet g root side_effects +let ca_certificates_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let paths = [ "/etc/pki/CA/certs/*.crt"; diff --git a/sysprep/sysprep_operation_crash_data.ml b/sysprep/sysprep_operation_crash_data.ml index 3fb865e..370f695 100644 --- a/sysprep/sysprep_operation_crash_data.ml +++ b/sysprep/sysprep_operation_crash_data.ml @@ -26,7 +26,7 @@ let globs = [ "/var/log/dump/*"; ] -let crash_data_perform ~debug ~quiet g root side_effects +let crash_data_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ = "linux" then ( List.iter (fun glob -> Array.iter g#rm_rf (g#glob_expand glob)) globs diff --git a/sysprep/sysprep_operation_cron_spool.ml b/sysprep/sysprep_operation_cron_spool.ml index 0f11f91..9a78e85 100644 --- a/sysprep/sysprep_operation_cron_spool.ml +++ b/sysprep/sysprep_operation_cron_spool.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let cron_spool_perform ~debug ~quiet (g : Guestfs.guestfs) root side_effects +let cron_spool_perform ~verbose ~quiet (g : Guestfs.guestfs) root side_effects Array.iter g#rm_rf (g#glob_expand "/var/spool/cron/*"); Array.iter g#rm (g#glob_expand "/var/spool/atjobs/*"); Array.iter g#rm (g#glob_expand "/var/spool/atjobs/.SEQ"); diff --git a/sysprep/sysprep_operation_customize.ml b/sysprep/sysprep_operation_customize.ml index 145c29f..668c25a 100644 --- a/sysprep/sysprep_operation_customize.ml +++ b/sysprep/sysprep_operation_customize.ml @@ -30,9 +30,9 @@ let customize_args, get_ops ) args in args, get_ops -let customize_perform ~debug ~quiet g root side_effects +let customize_perform ~verbose ~quiet g root side_effects let ops = get_ops () in - Customize_run.run ~prog ~debug ~quiet g root ops; + Customize_run.run ~prog ~verbose ~quiet g root ops; side_effects#created_file () (* XXX Did we? *) let op = { diff --git a/sysprep/sysprep_operation_dhcp_client_state.ml b/sysprep/sysprep_operation_dhcp_client_state.ml index 803c3ce..9bc320c 100644 --- a/sysprep/sysprep_operation_dhcp_client_state.ml +++ b/sysprep/sysprep_operation_dhcp_client_state.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let dhcp_client_state_perform ~debug ~quiet g root side_effects +let dhcp_client_state_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ = "linux" then ( List.iter ( diff --git a/sysprep/sysprep_operation_dhcp_server_state.ml b/sysprep/sysprep_operation_dhcp_server_state.ml index 3bf13d3..ea42b38 100644 --- a/sysprep/sysprep_operation_dhcp_server_state.ml +++ b/sysprep/sysprep_operation_dhcp_server_state.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let dhcp_server_state_perform ~debug ~quiet g root side_effects +let dhcp_server_state_perform ~verbose ~quiet g root side_effects Array.iter g#rm_rf (g#glob_expand "/var/lib/dhcpd/*") let op = { diff --git a/sysprep/sysprep_operation_dovecot_data.ml b/sysprep/sysprep_operation_dovecot_data.ml index e9d6dc5..e000ab0 100644 --- a/sysprep/sysprep_operation_dovecot_data.ml +++ b/sysprep/sysprep_operation_dovecot_data.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let dovecot_data_perform ~debug ~quiet g root side_effects +let dovecot_data_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let files = g#glob_expand "/var/lib/dovecot/*" in diff --git a/sysprep/sysprep_operation_firewall_rules.ml b/sysprep/sysprep_operation_firewall_rules.ml index 558aca3..22dd5e8 100644 --- a/sysprep/sysprep_operation_firewall_rules.ml +++ b/sysprep/sysprep_operation_firewall_rules.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let firewall_rules_perform ~debug ~quiet g root side_effects +let firewall_rules_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let paths = [ "/etc/sysconfig/iptables"; diff --git a/sysprep/sysprep_operation_flag_reconfiguration.ml b/sysprep/sysprep_operation_flag_reconfiguration.ml index 69ea377..b556deb 100644 --- a/sysprep/sysprep_operation_flag_reconfiguration.ml +++ b/sysprep/sysprep_operation_flag_reconfiguration.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let flag_reconfiguration ~debug ~quiet g root side_effects +let flag_reconfiguration ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( g#touch "/.unconfigured"; diff --git a/sysprep/sysprep_operation_fs_uuids.ml b/sysprep/sysprep_operation_fs_uuids.ml index 57ccd68..af168c2 100644 --- a/sysprep/sysprep_operation_fs_uuids.ml +++ b/sysprep/sysprep_operation_fs_uuids.ml @@ -27,7 +27,7 @@ module G = Guestfs let prog = "virt-sysprep" -let rec fs_uuids_perform ~debug ~quiet g root side_effects +let rec fs_uuids_perform ~verbose ~quiet g root side_effects let fses = g#list_filesystems () in List.iter (function | _, "unknown" -> () diff --git a/sysprep/sysprep_operation_kerberos_data.ml b/sysprep/sysprep_operation_kerberos_data.ml index 1e7d436..063f967 100644 --- a/sysprep/sysprep_operation_kerberos_data.ml +++ b/sysprep/sysprep_operation_kerberos_data.ml @@ -22,7 +22,7 @@ open Common_gettext.Gettext module StringSet = Set.Make (String) module G = Guestfs -let kerberos_data_perform ~debug ~quiet g root side_effects +let kerberos_data_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let excepts = [ "/var/kerberos/krb5kdc/kadm5.acl"; diff --git a/sysprep/sysprep_operation_logfiles.ml b/sysprep/sysprep_operation_logfiles.ml index 2c5dd68..1b90d9f 100644 --- a/sysprep/sysprep_operation_logfiles.ml +++ b/sysprep/sysprep_operation_logfiles.ml @@ -128,7 +128,7 @@ let globs = List.sort compare [ ] let globs_as_pod = String.concat "\n" (List.map ((^) " ") globs) -let logfiles_perform ~debug ~quiet g root side_effects +let logfiles_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ = "linux" then ( List.iter (fun glob -> Array.iter g#rm_rf (g#glob_expand glob)) globs diff --git a/sysprep/sysprep_operation_lvm_uuids.ml b/sysprep/sysprep_operation_lvm_uuids.ml index 85cd9ee..6771a22 100644 --- a/sysprep/sysprep_operation_lvm_uuids.ml +++ b/sysprep/sysprep_operation_lvm_uuids.ml @@ -23,7 +23,7 @@ open Common_gettext.Gettext module G = Guestfs -let rec lvm_uuids_perform ~debug ~quiet g root side_effects +let rec lvm_uuids_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ = "linux" then ( let has_lvm2_feature diff --git a/sysprep/sysprep_operation_machine_id.ml b/sysprep/sysprep_operation_machine_id.ml index 68770f8..acf8757 100644 --- a/sysprep/sysprep_operation_machine_id.ml +++ b/sysprep/sysprep_operation_machine_id.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let machine_id_perform ~debug ~quiet g root side_effects +let machine_id_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let path = "/etc/machine-id" in diff --git a/sysprep/sysprep_operation_mail_spool.ml b/sysprep/sysprep_operation_mail_spool.ml index 8e59f33..3b56184 100644 --- a/sysprep/sysprep_operation_mail_spool.ml +++ b/sysprep/sysprep_operation_mail_spool.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let mail_spool_perform ~debug ~quiet g root side_effects +let mail_spool_perform ~verbose ~quiet g root side_effects List.iter ( fun glob -> Array.iter g#rm_rf (g#glob_expand glob) ) [ diff --git a/sysprep/sysprep_operation_net_hostname.ml b/sysprep/sysprep_operation_net_hostname.ml index c0491ab..5bf4b07 100644 --- a/sysprep/sysprep_operation_net_hostname.ml +++ b/sysprep/sysprep_operation_net_hostname.ml @@ -22,7 +22,7 @@ open Common_gettext.Gettext module G = Guestfs -let net_hostname_perform ~debug ~quiet g root side_effects +let net_hostname_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in let distro = g#inspect_get_distro root in match typ, distro with diff --git a/sysprep/sysprep_operation_net_hwaddr.ml b/sysprep/sysprep_operation_net_hwaddr.ml index da3c2b3..ea24997 100644 --- a/sysprep/sysprep_operation_net_hwaddr.ml +++ b/sysprep/sysprep_operation_net_hwaddr.ml @@ -22,7 +22,7 @@ open Common_gettext.Gettext module G = Guestfs -let net_hwaddr_perform ~debug ~quiet g root side_effects +let net_hwaddr_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in let distro = g#inspect_get_distro root in match typ, distro with diff --git a/sysprep/sysprep_operation_pacct_log.ml b/sysprep/sysprep_operation_pacct_log.ml index 41a6cad..0abd349 100644 --- a/sysprep/sysprep_operation_pacct_log.ml +++ b/sysprep/sysprep_operation_pacct_log.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let pacct_log_perform ~debug ~quiet g root side_effects +let pacct_log_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in let distro = g#inspect_get_distro root in match typ, distro with diff --git a/sysprep/sysprep_operation_package_manager_cache.ml b/sysprep/sysprep_operation_package_manager_cache.ml index 0c86eca..835153b 100644 --- a/sysprep/sysprep_operation_package_manager_cache.ml +++ b/sysprep/sysprep_operation_package_manager_cache.ml @@ -22,7 +22,7 @@ open Common_utils module G = Guestfs -let package_manager_cache_perform ~debug ~quiet g root side_effects +let package_manager_cache_perform ~verbose ~quiet g root side_effects let packager = g#inspect_get_package_management root in let cache_dirs match packager with diff --git a/sysprep/sysprep_operation_pam_data.ml b/sysprep/sysprep_operation_pam_data.ml index a8e93e3..16b073a 100644 --- a/sysprep/sysprep_operation_pam_data.ml +++ b/sysprep/sysprep_operation_pam_data.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let pam_data_perform ~debug ~quiet g root side_effects +let pam_data_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let paths = [ "/var/run/console/*"; diff --git a/sysprep/sysprep_operation_puppet_data_log.ml b/sysprep/sysprep_operation_puppet_data_log.ml index af1d8ba..6bc14f5 100644 --- a/sysprep/sysprep_operation_puppet_data_log.ml +++ b/sysprep/sysprep_operation_puppet_data_log.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let puppet_data_log_perform ~debug ~quiet g root side_effects +let puppet_data_log_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let paths = [ "/var/log/puppet/*"; diff --git a/sysprep/sysprep_operation_rh_subscription_manager.ml b/sysprep/sysprep_operation_rh_subscription_manager.ml index 1cf8a9b..3c1ca09 100644 --- a/sysprep/sysprep_operation_rh_subscription_manager.ml +++ b/sysprep/sysprep_operation_rh_subscription_manager.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let rh_subscription_manager_perform ~debug ~quiet g root side_effects +let rh_subscription_manager_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in let distro = g#inspect_get_distro root in diff --git a/sysprep/sysprep_operation_rhn_systemid.ml b/sysprep/sysprep_operation_rhn_systemid.ml index 59a80b1..5f32537 100644 --- a/sysprep/sysprep_operation_rhn_systemid.ml +++ b/sysprep/sysprep_operation_rhn_systemid.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let rhn_systemid_perform ~debug ~quiet g root side_effects +let rhn_systemid_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in let distro = g#inspect_get_distro root in diff --git a/sysprep/sysprep_operation_rpm_db.ml b/sysprep/sysprep_operation_rpm_db.ml index 8f5e63b..e15bf97 100644 --- a/sysprep/sysprep_operation_rpm_db.ml +++ b/sysprep/sysprep_operation_rpm_db.ml @@ -22,7 +22,7 @@ open Common_gettext.Gettext module StringSet = Set.Make (String) module G = Guestfs -let rpm_db_perform ~debug ~quiet g root side_effects +let rpm_db_perform ~verbose ~quiet g root side_effects let pf = g#inspect_get_package_format root in if pf = "rpm" then ( let paths = g#glob_expand "/var/lib/rpm/__db.*" in diff --git a/sysprep/sysprep_operation_samba_db_log.ml b/sysprep/sysprep_operation_samba_db_log.ml index a8dd0d3..6ad9068 100644 --- a/sysprep/sysprep_operation_samba_db_log.ml +++ b/sysprep/sysprep_operation_samba_db_log.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let samba_db_log_perform ~debug ~quiet g root side_effects +let samba_db_log_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let paths = [ "/var/log/samba/old/*"; diff --git a/sysprep/sysprep_operation_script.ml b/sysprep/sysprep_operation_script.ml index b9641e7..d486a88 100644 --- a/sysprep/sysprep_operation_script.ml +++ b/sysprep/sysprep_operation_script.ml @@ -36,7 +36,7 @@ let set_scriptdir dir let scripts = ref [] let add_script script = scripts := script :: !scripts -let rec script_perform ~debug ~quiet (g : Guestfs.guestfs) root side_effects +let rec script_perform ~verbose ~quiet (g : Guestfs.guestfs) root side_effects let scripts = List.rev !scripts in if scripts <> [] then ( (* Create a temporary directory? *) diff --git a/sysprep/sysprep_operation_smolt_uuid.ml b/sysprep/sysprep_operation_smolt_uuid.ml index 55b9447..8096c4f 100644 --- a/sysprep/sysprep_operation_smolt_uuid.ml +++ b/sysprep/sysprep_operation_smolt_uuid.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let smolt_uuid_perform ~debug ~quiet g root side_effects +let smolt_uuid_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ = "linux" then ( let files = [ "/etc/sysconfig/hw-uuid"; diff --git a/sysprep/sysprep_operation_ssh_hostkeys.ml b/sysprep/sysprep_operation_ssh_hostkeys.ml index 1f31051..15a4fd6 100644 --- a/sysprep/sysprep_operation_ssh_hostkeys.ml +++ b/sysprep/sysprep_operation_ssh_hostkeys.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let ssh_hostkeys_perform ~debug ~quiet g root side_effects +let ssh_hostkeys_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let files = g#glob_expand "/etc/ssh/*_host_*" in diff --git a/sysprep/sysprep_operation_ssh_userdir.ml b/sysprep/sysprep_operation_ssh_userdir.ml index 3b6d553..60cf778 100644 --- a/sysprep/sysprep_operation_ssh_userdir.ml +++ b/sysprep/sysprep_operation_ssh_userdir.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let ssh_userdir_perform ~debug ~quiet g root side_effects +let ssh_userdir_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let dirs = g#glob_expand "/home/*/.ssh" in diff --git a/sysprep/sysprep_operation_sssd_db_log.ml b/sysprep/sysprep_operation_sssd_db_log.ml index 644c105..654e733 100644 --- a/sysprep/sysprep_operation_sssd_db_log.ml +++ b/sysprep/sysprep_operation_sssd_db_log.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let sssd_db_log_perform ~debug ~quiet g root side_effects +let sssd_db_log_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let paths = [ "/var/log/sssd/*"; diff --git a/sysprep/sysprep_operation_tmp_files.ml b/sysprep/sysprep_operation_tmp_files.ml index d5a52f3..593acbf 100644 --- a/sysprep/sysprep_operation_tmp_files.ml +++ b/sysprep/sysprep_operation_tmp_files.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let tmp_files_perform ~debug ~quiet g root side_effects +let tmp_files_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let paths = [ "/tmp"; diff --git a/sysprep/sysprep_operation_udev_persistent_net.ml b/sysprep/sysprep_operation_udev_persistent_net.ml index 764f8a3..9cf74c8 100644 --- a/sysprep/sysprep_operation_udev_persistent_net.ml +++ b/sysprep/sysprep_operation_udev_persistent_net.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let udev_persistent_net_perform ~debug ~quiet g root side_effects +let udev_persistent_net_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ = "linux" then ( try g#rm "/etc/udev/rules.d/70-persistent-net.rules" diff --git a/sysprep/sysprep_operation_user_account.ml b/sysprep/sysprep_operation_user_account.ml index 14b3b44..fa93769 100644 --- a/sysprep/sysprep_operation_user_account.ml +++ b/sysprep/sysprep_operation_user_account.ml @@ -25,7 +25,7 @@ open Common_gettext.Gettext module G = Guestfs -let user_account_perform ~debug ~quiet g root side_effects +let user_account_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( g#aug_init "/" 0; diff --git a/sysprep/sysprep_operation_utmp.ml b/sysprep/sysprep_operation_utmp.ml index c559a03..b306b99 100644 --- a/sysprep/sysprep_operation_utmp.ml +++ b/sysprep/sysprep_operation_utmp.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let utmp_perform ~debug ~quiet g root side_effects +let utmp_perform ~verbose ~quiet g root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( try g#rm "/var/run/utmp" diff --git a/sysprep/sysprep_operation_yum_uuid.ml b/sysprep/sysprep_operation_yum_uuid.ml index c775d85..77f30fb 100644 --- a/sysprep/sysprep_operation_yum_uuid.ml +++ b/sysprep/sysprep_operation_yum_uuid.ml @@ -21,7 +21,7 @@ open Common_gettext.Gettext module G = Guestfs -let yum_uuid_perform ~debug ~quiet g root side_effects +let yum_uuid_perform ~verbose ~quiet g root side_effects let packager = g#inspect_get_package_management root in if packager = "yum" then ( try g#rm "/var/lib/yum/uuid" with G.Error _ -> () -- 1.9.0