From 7740c8fed527860e72ab4ea70bb2533cebc6df46 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 26 Sep 2013 01:32:53 -0700 Subject: [PATCH] using blocking cp method. --- builder/amazon/chroot/communicator.go | 3 ++- builder/amazon/chroot/copy_files.go | 13 +++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/builder/amazon/chroot/communicator.go b/builder/amazon/chroot/communicator.go index 741de2d83..9d4e4ce09 100644 --- a/builder/amazon/chroot/communicator.go +++ b/builder/amazon/chroot/communicator.go @@ -1,6 +1,7 @@ package chroot import ( + "fmt" "github.com/mitchellh/packer/packer" "io" "log" @@ -21,7 +22,7 @@ type Communicator struct { func (c *Communicator) Start(cmd *packer.RemoteCmd) error { chrootCommand := fmt.Sprintf("%s %s %s", c.ChrootCommand, c.Chroot, cmd.Command) - localcmd := exec.Command("/bin/sh", "-c", chrootCommand) + localCmd := exec.Command("/bin/sh", "-c", chrootCommand) localCmd.Stdin = cmd.Stdin localCmd.Stdout = cmd.Stdout localCmd.Stderr = cmd.Stderr diff --git a/builder/amazon/chroot/copy_files.go b/builder/amazon/chroot/copy_files.go index 0c4ef2dbc..ef5cd70b5 100644 --- a/builder/amazon/chroot/copy_files.go +++ b/builder/amazon/chroot/copy_files.go @@ -1,18 +1,15 @@ package chroot import ( - "log" + "fmt" "os/exec" ) -func copySingle(dst string, src string, copyCommand string) error { +func copySingle(dest string, src string, copyCommand string) error { cpCommand := fmt.Sprintf("sudo cp -fn %s %s", src, dest) - localcmd := exec.Command("/bin/sh", "-c", cpCommand) - log.Println(localcmd.Args) - out, err := localcmd.CombinedOutput() - if err != nil { - log.Println(err) + localCmd := exec.Command("/bin/sh", "-c", cpCommand) + if err := localCmd.Run(); err != nil { + return err } - log.Printf("output: %s", out) return nil }