builder/amazon/chroot: allow no such file errors on upload [GH-588]

This commit is contained in:
Mitchell Hashimoto 2013-11-08 10:53:54 -08:00
parent 17f1ee3e98
commit 3780b57a1f
2 changed files with 19 additions and 1 deletions

View File

@ -14,6 +14,7 @@ IMPROVEMENTS:
BUG FIXES:
* builder/amazon/chroot: Copying empty directories works. [GH-588]
* builder/amazon/chroot: Chroot commands work with shell provisioners. [GH-581]
* builder/vmware: VMX modifications are now case-insensitive. [GH-608]

View File

@ -1,6 +1,7 @@
package chroot
import (
"bytes"
"fmt"
"github.com/mitchellh/packer/packer"
"io"
@ -9,6 +10,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"
"syscall"
)
@ -85,7 +87,22 @@ func (c *Communicator) UploadDir(dst string, src string, exclude []string) error
return err
}
return ShellCommand(cpCmd).Run()
var stderr bytes.Buffer
cmd := ShellCommand(cpCmd)
cmd.Env = append(cmd.Env, os.Environ()...)
cmd.Env = append(cmd.Env, "LANG=C")
cmd.Stderr = &stderr
err := cmd.Run()
if err == nil {
return err
}
if strings.Contains(stderr.String(), "No such file") {
// This just means that the directory was empty. Just ignore it.
return nil
}
return err
}
func (c *Communicator) Download(src string, w io.Writer) error {