[Libguestfs] [PATCH] customize: fix running commands on the same architecture

Pino Toscano ptoscano at redhat.com
Mon Aug 31 09:20:32 UTC 2015


Wrap the command around an heredoc only if setarch needs to be used;
otherwise the heredoc will not be run at all.

Fix commit d875346ad441d4762455ea1b41d57ad6174d9b63.
---
 customize/customize_run.ml | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index 2283272..9d97522 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -70,18 +70,20 @@ let run (g : Guestfs.guestfs) root (ops : ops) =
       ) [ "http_proxy"; "https_proxy"; "ftp_proxy"; "no_proxy" ] in
     let env_vars = String.concat "\n" env_vars ^ "\n" in
 
-    let setarch =
+    let cmd =
       match Config.host_cpu, guest_arch with
-      | "x86_64", ("i386"|"i486"|"i586"|"i686") -> "setarch i686"
-      | _ -> "" in
+      | "x86_64", ("i386"|"i486"|"i586"|"i686") ->
+        sprintf "setarch i686 <<\"__EOCMD\"
+%s
+__EOCMD
+" cmd
+      | _ -> cmd in
 
     let cmd = sprintf "\
 exec >>%s 2>&1
 %s
-%s <<\"__EOCMD\"
 %s
-__EOCMD
-" (quote logfile) env_vars setarch cmd in
+" (quote logfile) env_vars cmd in
 
     if verbose () then printf "running command:\n%s\n%!" cmd;
     try ignore (g#sh cmd)
-- 
2.1.0




More information about the Libguestfs mailing list