customize: fix running commands on the same architecture

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

Fix commit d875346ad4.
This commit is contained in:
Pino Toscano
2015-08-31 11:17:45 +02:00
parent 2596b78bcb
commit 7bdb3e0df9

View File

@@ -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)