[Libguestfs] [PATCH] customize: add a "touch" operation (RHBZ#1212808)

Pino Toscano ptoscano at redhat.com
Tue Apr 28 15:10:08 UTC 2015


---
 builder/cmdline.ml         | 3 ++-
 customize/customize_run.ml | 4 ++++
 generator/customize.ml     | 8 ++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/builder/cmdline.ml b/builder/cmdline.ml
index 7b119d5..ec189ad 100644
--- a/builder/cmdline.ml
+++ b/builder/cmdline.ml
@@ -312,7 +312,8 @@ read the man page virt-builder(1).
           | `Password _ | `RootPassword _ | `Scrub _ | `SSHInject _
           | `Timezone _ | `Truncate _ | `TruncateRecursive _
           | `Upload _ | `Write _ | `Chmod _
-          | `CommandsFromFile _ | `CopyIn _ | `Copy _ | `Move _ -> false
+          | `CommandsFromFile _ | `CopyIn _ | `Copy _ | `Move _
+          | `Touch _ -> false
         ) ops.ops in
         if requires_execute_on_guest then
           error (f_"sorry, cannot run commands on a guest with a different architecture");
diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index f2dbaa2..08cff0b 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -268,6 +268,10 @@ exec >>%s 2>&1
       if not (Timezone.set_timezone g root tz) then
         warning (f_"timezone could not be set for this type of guest")
 
+    | `Touch path ->
+      msg (f_"Running touch: %s") path;
+      g#touch path
+
     | `Update ->
       msg (f_"Updating core packages");
       let cmd = guest_update_command () in
diff --git a/generator/customize.ml b/generator/customize.ml
index 99ff4b9..2980d39 100644
--- a/generator/customize.ml
+++ b/generator/customize.ml
@@ -363,6 +363,14 @@ Set the default timezone of the guest to C<TIMEZONE>.  Use a location
 string like C<Europe/London>";
   };
 
+  { op_name = "touch";
+    op_type = String "FILE";
+    op_discrim = "`Touch";
+    op_shortdesc = "Run touch on a file";
+    op_pod_longdesc = "\
+This command performs a L<touch(1)>-like operation on C<FILE>.";
+  };
+
   { op_name = "update";
     op_type = Unit;
     op_discrim = "`Update";
-- 
2.1.0




More information about the Libguestfs mailing list