[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH] customize: add --truncate option (RHBZ#119673)



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

diff --git a/builder/cmdline.ml b/builder/cmdline.ml
index b8227cc..b7e7e07 100644
--- a/builder/cmdline.ml
+++ b/builder/cmdline.ml
@@ -313,7 +313,7 @@ read the man page virt-builder(1).
           | `Delete _ | `Edit _ | `FirstbootCommand _ | `FirstbootPackages _
           | `FirstbootScript _ | `Hostname _ | `Link _ | `Mkdir _
           | `Password _ | `RootPassword _ | `Scrub _ | `SSHInject _
-          | `Timezone _ | `Upload _ | `Write _ | `Chmod _
+          | `Truncate _ | `Timezone _ | `Upload _ | `Write _ | `Chmod _
           | `CommandsFromFile _ | `CopyIn _ -> false
         ) ops.ops in
         if requires_execute_on_guest then
diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index 980df7e..921bc7e 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -247,6 +247,10 @@ exec >>%s 2>&1
       | _ ->
         warning (f_"SSH key could be injected for this type of guest"))
 
+    | `Truncate path ->
+      msg (f_"Truncating: %s") path;
+      g#truncate path
+
     | `Timezone tz ->
       msg (f_"Setting the timezone: %s") tz;
       if not (Timezone.set_timezone g root tz) then
diff --git a/generator/customize.ml b/generator/customize.ml
index 7fe0f4d..f7ec3f2 100644
--- a/generator/customize.ml
+++ b/generator/customize.ml
@@ -317,6 +317,15 @@ You can have multiple I<--ssh-inject> options, for different users
 and also for more keys for each user."
   };
 
+  { op_name = "truncate";
+    op_type = String "FILE";
+    op_discrim = "`Truncate";
+    op_shortdesc = "Truncate a file to zero size";
+    op_pod_longdesc = "\
+This command truncates \"path\" to a zero-length file. The file must exist
+already.";
+  };
+
   { op_name = "timezone";
     op_type = String "TIMEZONE";
     op_discrim = "`Timezone";
-- 
1.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]