Commit 7740c8fe authored by Matthew Hooker's avatar Matthew Hooker

using blocking cp method.

parent 5e9ff92f
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 { ...@@ -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
......
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
} }
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