fix chroot Upload command.
This commit is contained in:
parent
de83755c00
commit
cebbcc51a6
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -57,17 +58,13 @@ func (c *Communicator) Start(cmd *packer.RemoteCmd) error {
|
|||
func (c *Communicator) Upload(dst string, r io.Reader) error {
|
||||
dst = filepath.Join(c.Chroot, dst)
|
||||
log.Printf("Uploading to chroot dir: %s", dst)
|
||||
f, err := os.Create(dst)
|
||||
tf, err := ioutil.TempFile("", "packer-amazon-chroot")
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("Error preparing shell script: %s", err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
if _, err := io.Copy(f, r); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
defer os.Remove(tf.Name())
|
||||
io.Copy(tf, r)
|
||||
return copySingle(dst, tf.Name(), c.CopyCommand)
|
||||
}
|
||||
|
||||
func (c *Communicator) UploadDir(dst string, src string, exclude []string) error {
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
func copySingle(dest string, src string, copyCommand string) error {
|
||||
cpCommand := fmt.Sprintf("%s %s %s", copyCommand, src, dest)
|
||||
localCmd := exec.Command("/bin/sh", "-c", cpCommand)
|
||||
log.Println(localCmd.Args)
|
||||
log.Printf("Executing copy: %s %#v", localCmd.Path, localCmd.Args)
|
||||
if err := localCmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue