using blocking cp method.
This commit is contained in:
parent
5e9ff92ff3
commit
7740c8fed5
|
@ -1,6 +1,7 @@
|
||||||
package chroot
|
package chroot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
@ -21,7 +22,7 @@ type Communicator struct {
|
||||||
func (c *Communicator) Start(cmd *packer.RemoteCmd) error {
|
func (c *Communicator) Start(cmd *packer.RemoteCmd) error {
|
||||||
|
|
||||||
chrootCommand := fmt.Sprintf("%s %s %s", c.ChrootCommand, c.Chroot, cmd.Command)
|
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.Stdin = cmd.Stdin
|
||||||
localCmd.Stdout = cmd.Stdout
|
localCmd.Stdout = cmd.Stdout
|
||||||
localCmd.Stderr = cmd.Stderr
|
localCmd.Stderr = cmd.Stderr
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
package chroot
|
package chroot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"fmt"
|
||||||
"os/exec"
|
"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)
|
cpCommand := fmt.Sprintf("sudo cp -fn %s %s", src, dest)
|
||||||
localcmd := exec.Command("/bin/sh", "-c", cpCommand)
|
localCmd := exec.Command("/bin/sh", "-c", cpCommand)
|
||||||
log.Println(localcmd.Args)
|
if err := localCmd.Run(); err != nil {
|
||||||
out, err := localcmd.CombinedOutput()
|
return err
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
}
|
||||||
log.Printf("output: %s", out)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue