2013-07-30 17:44:03 -04:00
|
|
|
package chroot
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// StepChrootProvision provisions the instance within a chroot.
|
|
|
|
type StepChrootProvision struct {
|
|
|
|
mounts []string
|
|
|
|
}
|
|
|
|
|
2013-08-31 15:58:55 -04:00
|
|
|
func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
hook := state.Get("hook").(packer.Hook)
|
|
|
|
mountPath := state.Get("mount_path").(string)
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
2013-09-30 12:33:57 -04:00
|
|
|
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper)
|
2013-07-30 17:44:03 -04:00
|
|
|
|
|
|
|
// Create our communicator
|
|
|
|
comm := &Communicator{
|
2013-09-30 12:33:57 -04:00
|
|
|
Chroot: mountPath,
|
|
|
|
CmdWrapper: wrappedCommand,
|
2013-07-30 17:44:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Provision
|
|
|
|
log.Println("Running the provision hook")
|
|
|
|
if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil {
|
2013-08-31 15:58:55 -04:00
|
|
|
state.Put("error", err)
|
2013-07-30 17:44:03 -04:00
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2013-08-31 15:58:55 -04:00
|
|
|
func (s *StepChrootProvision) Cleanup(state multistep.StateBag) {}
|