- sprintf "ssh root@%s \
-LIBGUESTFS_BACKEND_SETTINGS=network_bridge=br0 \
-base_image=%s \
-format=%s \
-name=%s \
-output=%s \
-%s \
-%s \
-%s build"
- (quote hostname)
- (quote template_info.Template.base_image) (* base_image *)
- format (* format *)
- name (* name *)
- (quote remote_image) (* output *)
- (match !size with
- | 0L -> ""
- | size -> sprintf "size=%Ldb" size) (* size *)
- (match !timezone with
- | "" -> ""
- | tz -> quote "timezone=" ^ tz) (* timezone *)
- remote_filename in
+ fpf "export LIBGUESTFS_BACKEND_SETTINGS=network_bridge=br0\n";
+ fpf "export base_image=%s\n" (quote template_info.Template.base_image);
+ fpf "export format=%s\n" (quote format);
+ fpf "export name=%s\n" (quote name);
+ fpf "export output=%s\n" (quote remote_image);
+ (match size with
+ | 0L -> ()
+ | size -> fpf "export size=%s\n" (quote (sprintf "--size %Ldb" size))
+ );
+ (match !timezone with
+ | "" -> ()
+ | tz -> fpf "export timezone=%s\n" (quote (sprintf "--timezone %s" tz))
+ );
+ fpf "%s build\n" remote_template;
+ close_out chan;
+ Unix.chmod remote_template_wrapper 0o755 in
+
+ let cmd =
+ sprintf "scp %s root@%s:%s"
+ (quote remote_template_wrapper) (quote hostname)
+ (quote remote_template_wrapper) in
+ if verbose then printf "%s\n%!" cmd;
+ if Sys.command cmd <> 0 then (
+ eprintf "mclu: scp template wrapper to remote failed\n";
+ exit 1
+ );
+
+ let cmd =
+ sprintf "ssh root@%s %s" (quote hostname) (quote remote_template_wrapper) in