2014-09-02 04:42:12 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2018-01-22 18:32:33 -05:00
|
|
|
"context"
|
2014-09-02 04:42:12 -04:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2016-12-11 14:13:37 -05:00
|
|
|
|
2018-01-19 19:18:44 -05:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2014-09-02 04:42:12 -04:00
|
|
|
)
|
|
|
|
|
2016-12-11 17:37:41 -05:00
|
|
|
// StepPrepareParallelsTools is a step that prepares parameters related
|
|
|
|
// to Parallels Tools.
|
2014-09-02 04:42:12 -04:00
|
|
|
//
|
|
|
|
// Uses:
|
|
|
|
// driver Driver
|
|
|
|
//
|
|
|
|
// Produces:
|
|
|
|
// parallels_tools_path string
|
|
|
|
type StepPrepareParallelsTools struct {
|
|
|
|
ParallelsToolsFlavor string
|
|
|
|
ParallelsToolsMode string
|
|
|
|
}
|
|
|
|
|
2016-12-16 14:51:55 -05:00
|
|
|
// Run sets the value of "parallels_tools_path".
|
2018-01-22 18:31:41 -05:00
|
|
|
func (s *StepPrepareParallelsTools) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
2014-09-02 04:42:12 -04:00
|
|
|
driver := state.Get("driver").(Driver)
|
|
|
|
|
|
|
|
if s.ParallelsToolsMode == ParallelsToolsModeDisable {
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2016-12-11 13:49:54 -05:00
|
|
|
path, err := driver.ToolsISOPath(s.ParallelsToolsFlavor)
|
2014-09-02 04:42:12 -04:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
state.Put("error", err)
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := os.Stat(path); err != nil {
|
|
|
|
state.Put("error", fmt.Errorf(
|
|
|
|
"Couldn't find Parallels Tools for the '%s' flavor! Please, check the\n"+
|
|
|
|
"value of 'parallels_tools_flavor'. Valid flavors are: 'win', 'lin',\n"+
|
|
|
|
"'mac', 'os2' and 'other'", s.ParallelsToolsFlavor))
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
state.Put("parallels_tools_path", path)
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2016-12-16 14:51:55 -05:00
|
|
|
// Cleanup does nothing.
|
2014-09-02 04:42:12 -04:00
|
|
|
func (s *StepPrepareParallelsTools) Cleanup(multistep.StateBag) {}
|