Commit ce3725ef authored by Matthew Hooker's avatar Matthew Hooker

wip

parent 36326ee8
...@@ -72,10 +72,9 @@ func (c *Communicator) UploadDir(dst string, src string, exclude []string) error ...@@ -72,10 +72,9 @@ func (c *Communicator) UploadDir(dst string, src string, exclude []string) error
} }
dstPath := filepath.Join(dst, path) dstPath := filepath.Join(dst, path)
dst = filepath.Join(c.Chroot, dst) dst := filepath.Join(c.Chroot, dst)
log.Printf("Uploading to chroot dir: %s", dst) log.Printf("Uploading to chroot dir: %s", dst)
return copySingle(dst, "", c.CopyCommand) return copySingle(dst, fullPath, c.CopyCommand)
//return c.Upload(dstPath, f)
} }
log.Printf("Uploading directory '%s' to '%s'", src, dst) log.Printf("Uploading directory '%s' to '%s'", src, dst)
......
...@@ -2,10 +2,7 @@ package chroot ...@@ -2,10 +2,7 @@ package chroot
import ( import (
"log" "log"
"os"
"os/exec" "os/exec"
"path/filepath"
"syscall"
) )
func copySingle(dst string, src string, copyCommand string) error { func copySingle(dst string, src string, copyCommand string) error {
......
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"io"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
...@@ -68,47 +67,3 @@ func (s *StepCopyFiles) CleanupFunc(multistep.StateBag) error { ...@@ -68,47 +67,3 @@ func (s *StepCopyFiles) CleanupFunc(multistep.StateBag) error {
s.files = nil s.files = nil
return nil return nil
} }
/* TODO: move to util file.
* change prototype to
func copySingle(dst string, src string, copyCommand string) error
* I think we should switch to cp for copying files, then allow specifying a copy_files_command or something.
Maybe we should just do a execute_wrapper that allows you to wrap every command...
*/
func (s *StepCopyFiles) copySingle(dst, src string) error {
// Stat the src file so we can copy the mode later
srcInfo, err := os.Stat(src)
if err != nil {
return err
}
// Remove any existing destination file
if err := os.Remove(dst); err != nil {
return err
}
// Copy the files
srcF, err := os.Open(src)
if err != nil {
return err
}
defer srcF.Close()
dstF, err := os.Create(dst)
if err != nil {
return err
}
defer dstF.Close()
if _, err := io.Copy(dstF, srcF); err != nil {
return err
}
dstF.Close()
// Match the mode
if err := os.Chmod(dst, srcInfo.Mode()); err != nil {
return err
}
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