Pino Toscano
2016-Feb-03 18:28 UTC
[Libguestfs] [PATCH 1/3] sysprep, get-kernel: explicit the Guestfs parameter
Help the OCaml compiler by expliciting Guestfs.guestfs as type for 'g' in some functions. --- get-kernel/get_kernel.ml | 2 +- sysprep/sysprep_operation_abrt_data.ml | 2 +- sysprep/sysprep_operation_bash_history.ml | 2 +- sysprep/sysprep_operation_ca_certificates.ml | 2 +- sysprep/sysprep_operation_crash_data.ml | 2 +- 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_kerberos_data.ml | 2 +- sysprep/sysprep_operation_logfiles.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/sysprep_operation_rh_subscription_manager.ml | 2 +- sysprep/sysprep_operation_rpm_db.ml | 2 +- sysprep/sysprep_operation_samba_db_log.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 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/get-kernel/get_kernel.ml b/get-kernel/get_kernel.ml index 812138f..6f26ca4 100644 --- a/get-kernel/get_kernel.ml +++ b/get-kernel/get_kernel.ml @@ -149,7 +149,7 @@ let rec do_fetch ~transform_fn ~outputdir g root g#umount_all () -and pick_kernel_files_linux g root +and pick_kernel_files_linux (g : Guestfs.guestfs) root (* Get all kernels and initramfses. *) let glob w = Array.to_list (g#glob_expand w) in let kernels = glob "/boot/vmlinuz-*" in diff --git a/sysprep/sysprep_operation_abrt_data.ml b/sysprep/sysprep_operation_abrt_data.ml index d950270..0d94271 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 g root side_effects +let abrt_data_perform (g : Guestfs.guestfs) 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 67eb4e3..5ddd515 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 g root side_effects +let bash_history_perform (g : Guestfs.guestfs) 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_ca_certificates.ml b/sysprep/sysprep_operation_ca_certificates.ml index 213f4ac..1d85fda 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 g root side_effects +let ca_certificates_perform (g : Guestfs.guestfs) 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 79f3d7f..70633fc 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 g root side_effects +let crash_data_perform (g : Guestfs.guestfs) 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_dhcp_client_state.ml b/sysprep/sysprep_operation_dhcp_client_state.ml index 3ee91df..bf5361f 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 g root side_effects +let dhcp_client_state_perform (g : Guestfs.guestfs) 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 dfc71b2..b9fe936 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 g root side_effects +let dhcp_server_state_perform (g : Guestfs.guestfs) 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 976d483..3ca8bf5 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 g root side_effects +let dovecot_data_perform (g : Guestfs.guestfs) 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 f5967fc..0a70169 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 g root side_effects +let firewall_rules_perform (g : Guestfs.guestfs) 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_kerberos_data.ml b/sysprep/sysprep_operation_kerberos_data.ml index 449d604..9dc794f 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 g root side_effects +let kerberos_data_perform (g : Guestfs.guestfs) 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 7b81959..0a9e054 100644 --- a/sysprep/sysprep_operation_logfiles.ml +++ b/sysprep/sysprep_operation_logfiles.ml @@ -132,7 +132,7 @@ let globs = List.sort compare [ ] let globs_as_pod = String.concat "\n" (List.map ((^) " ") globs) -let logfiles_perform g root side_effects +let logfiles_perform (g : Guestfs.guestfs) 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_mail_spool.ml b/sysprep/sysprep_operation_mail_spool.ml index 0db831c..873f753 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 g root side_effects +let mail_spool_perform (g : Guestfs.guestfs) 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 9b13ffd..3824d42 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 g root side_effects +let net_hostname_perform (g : Guestfs.guestfs) 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 9052fcb..439da6d 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 g root side_effects +let net_hwaddr_perform (g : Guestfs.guestfs) 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 355198d..1f9f0be 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 g root side_effects +let pacct_log_perform (g : Guestfs.guestfs) 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 5eb0453..f35764a 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 g root side_effects +let package_manager_cache_perform (g : Guestfs.guestfs) 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 c3b988f..698a052 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 g root side_effects +let pam_data_perform (g : Guestfs.guestfs) 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 f00e4a9..b8cb244 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 g root side_effects +let puppet_data_log_perform (g : Guestfs.guestfs) 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 d6c38b2..443feac 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 g root side_effects +let rh_subscription_manager_perform (g : Guestfs.guestfs) 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 55e50fe..81190e0 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 g root side_effects +let rpm_db_perform (g : Guestfs.guestfs) 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 126a7ac..19fdbf4 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 g root side_effects +let samba_db_log_perform (g : Guestfs.guestfs) 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_ssh_hostkeys.ml b/sysprep/sysprep_operation_ssh_hostkeys.ml index 417e792..fbbf4a6 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 g root side_effects +let ssh_hostkeys_perform (g : Guestfs.guestfs) 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 19f8890..2ff9581 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 g root side_effects +let ssh_userdir_perform (g : Guestfs.guestfs) 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 8f1bc88..9e35679 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 g root side_effects +let sssd_db_log_perform (g : Guestfs.guestfs) 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 af600db..1892d63 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 g root side_effects +let tmp_files_perform (g : Guestfs.guestfs) root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( let paths = [ "/tmp"; -- 2.5.0
Pino Toscano
2016-Feb-03 18:28 UTC
[Libguestfs] [PATCH 2/3] daemon: glob: add option for not returning dirs with trailing slash
Add a new optional bool "nodirectoryslash", to indicate that the caller does not want trailing slashes in names of directories; this helps with interoperability with other tools (such as rm). Related to RHBZ#1293271. --- daemon/glob.c | 8 ++++++-- generator/actions.ml | 17 ++++++++++++----- gobject/Makefile.inc | 2 ++ po/POTFILES | 1 + 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/daemon/glob.c b/daemon/glob.c index 45fb30f..de615ee 100644 --- a/daemon/glob.c +++ b/daemon/glob.c @@ -26,14 +26,18 @@ #include "actions.h" char ** -do_glob_expand (const char *pattern) +do_glob_expand (const char *pattern, int nodirectoryslash) { int r; glob_t buf = { .gl_pathc = 0, .gl_pathv = NULL, .gl_offs = 0 }; + int flags = GLOB_BRACE; + + if (!nodirectoryslash) + flags |= GLOB_MARK; /* glob(3) in glibc never calls chdir, so this seems to be safe: */ CHROOT_IN; - r = glob (pattern, GLOB_MARK|GLOB_BRACE, NULL, &buf); + r = glob (pattern, flags, NULL, &buf); CHROOT_OUT; if (r == GLOB_NOMATCH) { /* Return an empty list instead of an error. */ diff --git a/generator/actions.ml b/generator/actions.ml index 4078082..9efa732 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -5967,27 +5967,34 @@ See also: C<guestfs_command_lines>" }; * start with "/". There is no concept of "cwd" in libguestfs, * hence no "."-relative names. *) - style = RStringList "paths", [Pathname "pattern"], []; + style = RStringList "paths", [Pathname "pattern"], [OBool "nodirectoryslash"]; proc_nr = Some 113; + once_had_no_optargs = true; tests = [ InitScratchFS, Always, TestResult ( [["mkdir_p"; "/glob_expand/b/c"]; ["touch"; "/glob_expand/b/c/d"]; ["touch"; "/glob_expand/b/c/e"]; - ["glob_expand"; "/glob_expand/b/c/*"]], + ["glob_expand"; "/glob_expand/b/c/*"; ""]], "is_string_list (ret, 2, \"/glob_expand/b/c/d\", \"/glob_expand/b/c/e\")"), []; InitScratchFS, Always, TestResult ( [["mkdir_p"; "/glob_expand2/b/c"]; ["touch"; "/glob_expand2/b/c/d"]; ["touch"; "/glob_expand2/b/c/e"]; - ["glob_expand"; "/glob_expand2/*/c/*"]], + ["glob_expand"; "/glob_expand2/*/c/*"; ""]], "is_string_list (ret, 2, \"/glob_expand2/b/c/d\", \"/glob_expand2/b/c/e\")"), []; InitScratchFS, Always, TestResult ( [["mkdir_p"; "/glob_expand3/b/c"]; ["touch"; "/glob_expand3/b/c/d"]; ["touch"; "/glob_expand3/b/c/e"]; - ["glob_expand"; "/glob_expand3/*/x/*"]], - "is_string_list (ret, 0)"), [] + ["glob_expand"; "/glob_expand3/*/x/*"; ""]], + "is_string_list (ret, 0)"), []; + InitScratchFS, Always, TestResult ( + [["mkdir_p"; "/glob_expand4/b/c"]; + ["touch"; "/glob_expand4/b1"]; + ["touch"; "/glob_expand4/c1"]; + ["glob_expand"; "/glob_expand4/b*"; "true"]], + "is_string_list (ret, 2, \"/glob_expand4/b\", \"/glob_expand4/b1\")"), []; ]; shortdesc = "expand a wildcard path"; longdesc = "\ diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc index 3522eb2..5ba0fc9 100644 --- a/gobject/Makefile.inc +++ b/gobject/Makefile.inc @@ -68,6 +68,7 @@ guestfs_gobject_headers= \ include/guestfs-gobject/optargs-disk_create.h \ include/guestfs-gobject/optargs-e2fsck.h \ include/guestfs-gobject/optargs-fstrim.h \ + include/guestfs-gobject/optargs-glob_expand.h \ include/guestfs-gobject/optargs-grep.h \ include/guestfs-gobject/optargs-hivex_open.h \ include/guestfs-gobject/optargs-inspect_get_icon.h \ @@ -154,6 +155,7 @@ guestfs_gobject_sources= \ src/optargs-disk_create.c \ src/optargs-e2fsck.c \ src/optargs-fstrim.c \ + src/optargs-glob_expand.c \ src/optargs-grep.c \ src/optargs-hivex_open.c \ src/optargs-inspect_get_icon.c \ diff --git a/po/POTFILES b/po/POTFILES index aca174d..2a1e313 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -195,6 +195,7 @@ gobject/src/optargs-cpio_out.c gobject/src/optargs-disk_create.c gobject/src/optargs-e2fsck.c gobject/src/optargs-fstrim.c +gobject/src/optargs-glob_expand.c gobject/src/optargs-grep.c gobject/src/optargs-hivex_open.c gobject/src/optargs-inspect_get_icon.c -- 2.5.0
Pino Toscano
2016-Feb-03 18:28 UTC
[Libguestfs] [PATCH 3/3] customize: add globbing for --delete
Support globbing in paths passed to --delete, telling glob to not return directories with leading slash. This re-adds back globbing for --delete in virt-sysprep, which was available before the integration with common code from virt-customize. --- customize/customize_run.ml | 2 +- generator/customize.ml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/customize/customize_run.ml b/customize/customize_run.ml index 84f634b..6476f6a 100644 --- a/customize/customize_run.ml +++ b/customize/customize_run.ml @@ -191,7 +191,7 @@ exec >>%s 2>&1 | `Delete path -> message (f_"Deleting: %s") path; - g#rm_rf path + Array.iter g#rm_rf (g#glob_expand ~nodirectoryslash:true path) | `Edit (path, expr) -> message (f_"Editing: %s") path; diff --git a/generator/customize.ml b/generator/customize.ml index 19aec81..5d9a19b 100644 --- a/generator/customize.ml +++ b/generator/customize.ml @@ -115,6 +115,11 @@ Wildcards cannot be used."; Delete a file from the guest. Or delete a directory (and all its contents, recursively). +You can use shell glob characters in the specified path; note that such +metacharacters might require proper escape. For example: + + virt-customize --delete '/var/log/*.log'. + See also: I<--upload>, I<--scrub>."; }; -- 2.5.0
Richard W.M. Jones
2016-Feb-03 18:35 UTC
Re: [Libguestfs] [PATCH 1/3] sysprep, get-kernel: explicit the Guestfs parameter
On Wed, Feb 03, 2016 at 07:28:16PM +0100, Pino Toscano wrote:> Help the OCaml compiler by expliciting Guestfs.guestfs as type for 'g' > in some functions.Looks mechanical, ACK. Does Hindley-Milner type inference have problems here? I've not seen them in this case. Rich.> get-kernel/get_kernel.ml | 2 +- > sysprep/sysprep_operation_abrt_data.ml | 2 +- > sysprep/sysprep_operation_bash_history.ml | 2 +- > sysprep/sysprep_operation_ca_certificates.ml | 2 +- > sysprep/sysprep_operation_crash_data.ml | 2 +- > 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_kerberos_data.ml | 2 +- > sysprep/sysprep_operation_logfiles.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/sysprep_operation_rh_subscription_manager.ml | 2 +- > sysprep/sysprep_operation_rpm_db.ml | 2 +- > sysprep/sysprep_operation_samba_db_log.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 +- > 25 files changed, 25 insertions(+), 25 deletions(-) > > diff --git a/get-kernel/get_kernel.ml b/get-kernel/get_kernel.ml > index 812138f..6f26ca4 100644 > --- a/get-kernel/get_kernel.ml > +++ b/get-kernel/get_kernel.ml > @@ -149,7 +149,7 @@ let rec do_fetch ~transform_fn ~outputdir g root > > g#umount_all () > > -and pick_kernel_files_linux g root > +and pick_kernel_files_linux (g : Guestfs.guestfs) root > (* Get all kernels and initramfses. *) > let glob w = Array.to_list (g#glob_expand w) in > let kernels = glob "/boot/vmlinuz-*" in > diff --git a/sysprep/sysprep_operation_abrt_data.ml b/sysprep/sysprep_operation_abrt_data.ml > index d950270..0d94271 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 g root side_effects > +let abrt_data_perform (g : Guestfs.guestfs) 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 67eb4e3..5ddd515 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 g root side_effects > +let bash_history_perform (g : Guestfs.guestfs) 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_ca_certificates.ml b/sysprep/sysprep_operation_ca_certificates.ml > index 213f4ac..1d85fda 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 g root side_effects > +let ca_certificates_perform (g : Guestfs.guestfs) 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 79f3d7f..70633fc 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 g root side_effects > +let crash_data_perform (g : Guestfs.guestfs) 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_dhcp_client_state.ml b/sysprep/sysprep_operation_dhcp_client_state.ml > index 3ee91df..bf5361f 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 g root side_effects > +let dhcp_client_state_perform (g : Guestfs.guestfs) 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 dfc71b2..b9fe936 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 g root side_effects > +let dhcp_server_state_perform (g : Guestfs.guestfs) 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 976d483..3ca8bf5 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 g root side_effects > +let dovecot_data_perform (g : Guestfs.guestfs) 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 f5967fc..0a70169 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 g root side_effects > +let firewall_rules_perform (g : Guestfs.guestfs) 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_kerberos_data.ml b/sysprep/sysprep_operation_kerberos_data.ml > index 449d604..9dc794f 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 g root side_effects > +let kerberos_data_perform (g : Guestfs.guestfs) 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 7b81959..0a9e054 100644 > --- a/sysprep/sysprep_operation_logfiles.ml > +++ b/sysprep/sysprep_operation_logfiles.ml > @@ -132,7 +132,7 @@ let globs = List.sort compare [ > ] > let globs_as_pod = String.concat "\n" (List.map ((^) " ") globs) > > -let logfiles_perform g root side_effects > +let logfiles_perform (g : Guestfs.guestfs) 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_mail_spool.ml b/sysprep/sysprep_operation_mail_spool.ml > index 0db831c..873f753 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 g root side_effects > +let mail_spool_perform (g : Guestfs.guestfs) 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 9b13ffd..3824d42 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 g root side_effects > +let net_hostname_perform (g : Guestfs.guestfs) 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 9052fcb..439da6d 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 g root side_effects > +let net_hwaddr_perform (g : Guestfs.guestfs) 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 355198d..1f9f0be 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 g root side_effects > +let pacct_log_perform (g : Guestfs.guestfs) 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 5eb0453..f35764a 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 g root side_effects > +let package_manager_cache_perform (g : Guestfs.guestfs) 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 c3b988f..698a052 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 g root side_effects > +let pam_data_perform (g : Guestfs.guestfs) 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 f00e4a9..b8cb244 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 g root side_effects > +let puppet_data_log_perform (g : Guestfs.guestfs) 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 d6c38b2..443feac 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 g root side_effects > +let rh_subscription_manager_perform (g : Guestfs.guestfs) 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 55e50fe..81190e0 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 g root side_effects > +let rpm_db_perform (g : Guestfs.guestfs) 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 126a7ac..19fdbf4 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 g root side_effects > +let samba_db_log_perform (g : Guestfs.guestfs) 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_ssh_hostkeys.ml b/sysprep/sysprep_operation_ssh_hostkeys.ml > index 417e792..fbbf4a6 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 g root side_effects > +let ssh_hostkeys_perform (g : Guestfs.guestfs) 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 19f8890..2ff9581 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 g root side_effects > +let ssh_userdir_perform (g : Guestfs.guestfs) 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 8f1bc88..9e35679 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 g root side_effects > +let sssd_db_log_perform (g : Guestfs.guestfs) 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 af600db..1892d63 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 g root side_effects > +let tmp_files_perform (g : Guestfs.guestfs) root side_effects > let typ = g#inspect_get_type root in > if typ <> "windows" then ( > let paths = [ "/tmp"; > -- > 2.5.0 > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Richard W.M. Jones
2016-Feb-03 18:38 UTC
Re: [Libguestfs] [PATCH 2/3] daemon: glob: add option for not returning dirs with trailing slash
On Wed, Feb 03, 2016 at 07:28:17PM +0100, Pino Toscano wrote:> Add a new optional bool "nodirectoryslash", to indicate that the caller > does not want trailing slashes in names of directories; this helps with > interoperability with other tools (such as rm).Hmm, double negative :-/ Can it be "directoryslash" (defaulting to true of course)?> char ** > -do_glob_expand (const char *pattern) > +do_glob_expand (const char *pattern, int nodirectoryslash)Since this function is using an optarg, it must consult optargs_bitmask below, ie.> { > int r; > glob_t buf = { .gl_pathc = 0, .gl_pathv = NULL, .gl_offs = 0 }; > + int flags = GLOB_BRACE; > + > + if (!nodirectoryslash) > + flags |= GLOB_MARK;(with the sense reversed as I mentioned above) it would be: if (optargs_bitmask & GUESTFS_GLOB_EXPAND_DIRECTORYSLASH_BITMASK) { if (directoryslash) flags |= GLOB_MARK; } else { flags |= GLOB_MARK; /* defaults to true for backwards compatibility */ } You could simplify that a bit, but that's the general idea. Rest of the change is fine. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Richard W.M. Jones
2016-Feb-03 18:41 UTC
Re: [Libguestfs] [PATCH 3/3] customize: add globbing for --delete
On Wed, Feb 03, 2016 at 07:28:18PM +0100, Pino Toscano wrote:> Support globbing in paths passed to --delete, telling glob to not > return directories with leading slash. > > This re-adds back globbing for --delete in virt-sysprep, which was > available before the integration with common code from virt-customize. > --- > customize/customize_run.ml | 2 +- > generator/customize.ml | 5 +++++ > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/customize/customize_run.ml b/customize/customize_run.ml > index 84f634b..6476f6a 100644 > --- a/customize/customize_run.ml > +++ b/customize/customize_run.ml > @@ -191,7 +191,7 @@ exec >>%s 2>&1 > > | `Delete path -> > message (f_"Deleting: %s") path; > - g#rm_rf path > + Array.iter g#rm_rf (g#glob_expand ~nodirectoryslash:true path) > > | `Edit (path, expr) -> > message (f_"Editing: %s") path; > diff --git a/generator/customize.ml b/generator/customize.ml > index 19aec81..5d9a19b 100644 > --- a/generator/customize.ml > +++ b/generator/customize.ml > @@ -115,6 +115,11 @@ Wildcards cannot be used."; > Delete a file from the guest. Or delete a directory (and all its > contents, recursively). > > +You can use shell glob characters in the specified path; note that such > +metacharacters might require proper escape. For example:It's a little bit unclear -- no problem, I understand your first language isn't English! This seems better to me:> You can use shell glob characters in the specified path. Be > careful to escape glob characters from the host shell if that > is required. For example:> + virt-customize --delete '/var/log/*.log'. > + > See also: I<--upload>, I<--scrub>."; > };Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Pino Toscano
2016-Feb-04 09:26 UTC
Re: [Libguestfs] [PATCH 1/3] sysprep, get-kernel: explicit the Guestfs parameter
On Wednesday 03 February 2016 18:35:01 Richard W.M. Jones wrote:> On Wed, Feb 03, 2016 at 07:28:16PM +0100, Pino Toscano wrote: > > Help the OCaml compiler by expliciting Guestfs.guestfs as type for 'g' > > in some functions. > > Looks mechanical, ACK. > > Does Hindley-Milner type inference have problems here? I've not seen > them in this case.They seem to be needed when adding the additional labelled argument to glob_expand. -- Pino Toscano
Seemingly Similar Threads
- [PATCH 1/3] sysprep, get-kernel: explicit the Guestfs parameter
- [PATCH 3/4] ocaml tools: Use global variables to store trace (-x) and verbose (-v) flags.
- Re: [PATCH 2/5] Make sure every *.ml file has a corresponding *.mli file.
- [PATCH 2/5] Make sure every *.ml file has a corresponding *.mli file.
- [PATCH] sysprep: remove the data and log files of puppet