[Libguestfs] [PATCH 3/3] customize: add globbing for --delete

Pino Toscano ptoscano at redhat.com
Wed Feb 3 18:28:18 UTC 2016


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




More information about the Libguestfs mailing list