bugfixes, wip

This commit is contained in:
Matthew Hooker 2013-09-27 01:28:06 +00:00
parent 1104ad3e17
commit c15bb28491
3 changed files with 7 additions and 7 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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
}
}