|
|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
package vm
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
|
|
|
|
|
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
|
|
|
|
"github.com/hashicorp/packer/common"
|
|
|
|
|
@ -32,7 +32,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|
|
|
|
|
|
|
|
|
// Run executes a Packer build and returns a packer.Artifact representing
|
|
|
|
|
// a VirtualBox appliance.
|
|
|
|
|
func (b *Builder) Run(ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
|
|
|
|
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
|
|
|
|
// Create the driver that we'll use to communicate with VirtualBox
|
|
|
|
|
driver, err := vboxcommon.NewDriver()
|
|
|
|
|
if err != nil {
|
|
|
|
|
@ -154,7 +154,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
|
|
|
|
}
|
|
|
|
|
// Run the steps.
|
|
|
|
|
b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state)
|
|
|
|
|
b.runner.Run(state)
|
|
|
|
|
b.runner.Run(ctx, state)
|
|
|
|
|
|
|
|
|
|
// Report any errors.
|
|
|
|
|
if rawErr, ok := state.GetOk("error"); ok {
|
|
|
|
|
@ -176,11 +176,3 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
|
|
|
|
return vboxcommon.NewArtifact(b.config.OutputDir)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cancel.
|
|
|
|
|
func (b *Builder) Cancel() {
|
|
|
|
|
if b.runner != nil {
|
|
|
|
|
log.Println("Cancelling the step runner...")
|
|
|
|
|
b.runner.Cancel()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|