[Libguestfs] [PATCH] customize: add --copy

Maros Zatko mzatko at redhat.com
Mon Mar 23 18:46:33 UTC 2015


From: Maros Zatko <hacxman at gmail.com>

This adds --copy SOURCE:DEST, equivalent of calling g#cp_a src dst.

RFE: RHBZ#1203817
---
 builder/cmdline.ml         |  2 +-
 customize/customize_run.ml |  4 ++++
 generator/customize.ml     | 10 ++++++++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/builder/cmdline.ml b/builder/cmdline.ml
index debc789..c863ad2 100644
--- a/builder/cmdline.ml
+++ b/builder/cmdline.ml
@@ -315,7 +315,7 @@ read the man page virt-builder(1).
           | `Password _ | `RootPassword _ | `Scrub _ | `SSHInject _
           | `Timezone _ | `Truncate _ | `TruncateRecursive _
           | `Upload _ | `Write _ | `Chmod _
-          | `CommandsFromFile _ | `CopyIn _ -> false
+          | `CommandsFromFile _ | `CopyIn _ | `Copy _ -> 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 73b4d8a..47dda72 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -171,6 +171,10 @@ exec >>%s 2>&1
        * read when their arguments are met. *)
       ()
 
+    | `Copy (src, dest) ->
+      msg (f_"Copying (in image): %s to %s") src dest;
+      g#cp_a src dest
+
     | `CopyIn (localpath, remotedir) ->
       msg (f_"Copying: %s to %s") localpath remotedir;
       g#copy_in localpath remotedir
diff --git a/generator/customize.ml b/generator/customize.ml
index bfb37f7..96c4c48 100644
--- a/generator/customize.ml
+++ b/generator/customize.ml
@@ -85,6 +85,16 @@ as if they were specified as I<--delete /some/file> on the command
 line.";
   };
 
+  { op_name = "copy";
+    op_type = StringPair "SOURCE:DEST";
+    op_discrim = "`Copy";
+    op_shortdesc = "Copy files in disk image";
+    op_pod_longdesc = "\
+Copy files or directories recursively inside the guest.
+
+Wildcards cannot be used.";
+  };
+
   { op_name = "copy-in";
     op_type = StringPair "LOCALPATH:REMOTEDIR";
     op_discrim = "`CopyIn";
-- 
1.9.3




More information about the Libguestfs mailing list