From c15bb284913b76d393951c48c2a6d65240b8a66e Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Fri, 27 Sep 2013 01:28:06 +0000 Subject: [PATCH] bugfixes, wip --- builder/amazon/chroot/copy_files.go | 2 ++ builder/amazon/chroot/step_chroot_provision.go | 7 +++---- builder/amazon/chroot/step_copy_files.go | 5 ++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/builder/amazon/chroot/copy_files.go b/builder/amazon/chroot/copy_files.go index 81be8a9c8..f44c7da96 100644 --- a/builder/amazon/chroot/copy_files.go +++ b/builder/amazon/chroot/copy_files.go @@ -3,11 +3,13 @@ package chroot import ( "fmt" "os/exec" + "log" ) 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) if err := localCmd.Run(); err != nil { return err } diff --git a/builder/amazon/chroot/step_chroot_provision.go b/builder/amazon/chroot/step_chroot_provision.go index bb53e0603..6b76d9541 100644 --- a/builder/amazon/chroot/step_chroot_provision.go +++ b/builder/amazon/chroot/step_chroot_provision.go @@ -14,15 +14,14 @@ type StepChrootProvision struct { func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction { hook := state.Get("hook").(packer.Hook) mountPath := state.Get("mount_path").(string) - chrootCommand := state.Get("chroot_command").(string) - copyCommand := state.Get("copy_command").(string) + config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) // Create our communicator comm := &Communicator{ Chroot: mountPath, - ChrootCommand: chrootCommand, - CopyCommand: copyCommand, + ChrootCommand: config.ChrootCommand, + CopyCommand: config.CopyCommand, } // Provision diff --git a/builder/amazon/chroot/step_copy_files.go b/builder/amazon/chroot/step_copy_files.go index 4b8298928..102967423 100644 --- a/builder/amazon/chroot/step_copy_files.go +++ b/builder/amazon/chroot/step_copy_files.go @@ -5,7 +5,6 @@ import ( "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" "log" - "os" "path/filepath" ) @@ -31,7 +30,7 @@ func (s *StepCopyFiles) Run(state multistep.StateBag) multistep.StepAction { chrootPath := filepath.Join(mountPath, path) log.Printf("Copying '%s' to '%s'", path, chrootPath) - if err := copySingle(chrootPath, path, config.ChrootCommand); err != nil { + if err := copySingle(chrootPath, path, config.CopyCommand); err != nil { err := fmt.Errorf("Error copying file: %s", err) state.Put("error", err) ui.Error(err.Error()) @@ -57,7 +56,7 @@ func (s *StepCopyFiles) CleanupFunc(multistep.StateBag) error { if s.files != nil { for _, file := range s.files { log.Printf("Removing: %s", file) - if err := os.Remove(file); err != nil { + if err := copySingle(file, "", "rm"); err != nil { return err } }