Commit 3780b57a authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

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

parent 17f1ee3e
...@@ -14,6 +14,7 @@ IMPROVEMENTS: ...@@ -14,6 +14,7 @@ IMPROVEMENTS:
BUG FIXES: BUG FIXES:
* builder/amazon/chroot: Copying empty directories works. [GH-588]
* builder/amazon/chroot: Chroot commands work with shell provisioners. [GH-581] * builder/amazon/chroot: Chroot commands work with shell provisioners. [GH-581]
* builder/vmware: VMX modifications are now case-insensitive. [GH-608] * builder/vmware: VMX modifications are now case-insensitive. [GH-608]
......
package chroot package chroot
import ( import (
"bytes"
"fmt" "fmt"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"io" "io"
...@@ -9,6 +10,7 @@ import ( ...@@ -9,6 +10,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings"
"syscall" "syscall"
) )
...@@ -85,7 +87,22 @@ func (c *Communicator) UploadDir(dst string, src string, exclude []string) error ...@@ -85,7 +87,22 @@ func (c *Communicator) UploadDir(dst string, src string, exclude []string) error
return err 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 { func (c *Communicator) Download(src string, w io.Writer) error {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment