From 95f5cea2858768f459ca1a340f253353bf51285d Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 26 Sep 2013 01:07:01 -0700 Subject: [PATCH] wip --- builder/amazon/chroot/communicator.go | 5 ++- builder/amazon/chroot/copy_files.go | 3 -- builder/amazon/chroot/step_copy_files.go | 45 ------------------------ 3 files changed, 2 insertions(+), 51 deletions(-) diff --git a/builder/amazon/chroot/communicator.go b/builder/amazon/chroot/communicator.go index 2af07833c..ba71d8605 100644 --- a/builder/amazon/chroot/communicator.go +++ b/builder/amazon/chroot/communicator.go @@ -72,10 +72,9 @@ func (c *Communicator) UploadDir(dst string, src string, exclude []string) error } 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) - return copySingle(dst, "", c.CopyCommand) - //return c.Upload(dstPath, f) + return copySingle(dst, fullPath, c.CopyCommand) } log.Printf("Uploading directory '%s' to '%s'", src, dst) diff --git a/builder/amazon/chroot/copy_files.go b/builder/amazon/chroot/copy_files.go index 8d75cb65d..0c4ef2dbc 100644 --- a/builder/amazon/chroot/copy_files.go +++ b/builder/amazon/chroot/copy_files.go @@ -2,10 +2,7 @@ package chroot import ( "log" - "os" "os/exec" - "path/filepath" - "syscall" ) func copySingle(dst string, src string, copyCommand string) error { diff --git a/builder/amazon/chroot/step_copy_files.go b/builder/amazon/chroot/step_copy_files.go index efe411354..5e779efa8 100644 --- a/builder/amazon/chroot/step_copy_files.go +++ b/builder/amazon/chroot/step_copy_files.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" - "io" "log" "os" "path/filepath" @@ -68,47 +67,3 @@ func (s *StepCopyFiles) CleanupFunc(multistep.StateBag) error { s.files = 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 -}