|
|
|
|
@ -1,11 +1,14 @@
|
|
|
|
|
package virtualbox
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type stepPrepareOutputDir struct{}
|
|
|
|
|
@ -19,11 +22,22 @@ func (stepPrepareOutputDir) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
|
os.RemoveAll(config.OutputDir)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the directory
|
|
|
|
|
if err := os.MkdirAll(config.OutputDir, 0755); err != nil {
|
|
|
|
|
state.Put("error", err)
|
|
|
|
|
return multistep.ActionHalt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure we can write in the directory
|
|
|
|
|
f, err := os.Create(filepath.Join(config.OutputDir, "_packer_perm_check"))
|
|
|
|
|
if err != nil {
|
|
|
|
|
err = fmt.Errorf("Couldn't write to output directory: %s", err)
|
|
|
|
|
state.Put("error", err)
|
|
|
|
|
return multistep.ActionHalt
|
|
|
|
|
}
|
|
|
|
|
f.Close()
|
|
|
|
|
os.Remove(f.Name())
|
|
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|