bugfixes, wip

This commit is contained in:
Matthew Hooker 2013-09-27 01:28:06 +00:00
parent 308b148bb4
commit 6d158eaa29
3 changed files with 7 additions and 7 deletions

View File

@ -3,11 +3,13 @@ package chroot
import ( import (
"fmt" "fmt"
"os/exec" "os/exec"
"log"
) )
func copySingle(dest string, src string, copyCommand string) error { func copySingle(dest string, src string, copyCommand string) error {
cpCommand := fmt.Sprintf("%s %s %s", copyCommand, src, dest) cpCommand := fmt.Sprintf("%s %s %s", copyCommand, 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 { if err := localCmd.Run(); err != nil {
return err return err
} }

View File

@ -14,15 +14,14 @@ type StepChrootProvision struct {
func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction { func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction {
hook := state.Get("hook").(packer.Hook) hook := state.Get("hook").(packer.Hook)
mountPath := state.Get("mount_path").(string) mountPath := state.Get("mount_path").(string)
chrootCommand := state.Get("chroot_command").(string) config := state.Get("config").(*Config)
copyCommand := state.Get("copy_command").(string)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
// Create our communicator // Create our communicator
comm := &Communicator{ comm := &Communicator{
Chroot: mountPath, Chroot: mountPath,
ChrootCommand: chrootCommand, ChrootCommand: config.ChrootCommand,
CopyCommand: copyCommand, CopyCommand: config.CopyCommand,
} }
// Provision // Provision

View File

@ -5,7 +5,6 @@ import (
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log" "log"
"os"
"path/filepath" "path/filepath"
) )
@ -31,7 +30,7 @@ func (s *StepCopyFiles) Run(state multistep.StateBag) multistep.StepAction {
chrootPath := filepath.Join(mountPath, path) chrootPath := filepath.Join(mountPath, path)
log.Printf("Copying '%s' to '%s'", path, chrootPath) 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) err := fmt.Errorf("Error copying file: %s", err)
state.Put("error", err) state.Put("error", err)
ui.Error(err.Error()) ui.Error(err.Error())
@ -57,7 +56,7 @@ func (s *StepCopyFiles) CleanupFunc(multistep.StateBag) error {
if s.files != nil { if s.files != nil {
for _, file := range s.files { for _, file := range s.files {
log.Printf("Removing: %s", file) log.Printf("Removing: %s", file)
if err := os.Remove(file); err != nil { if err := copySingle(file, "", "rm"); err != nil {
return err return err
} }
} }