Commit 2920239e authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox: verify output dir is writable

parent 4d3c9e71
......@@ -31,6 +31,8 @@ IMPROVEMENTS:
* builder/qemu: Next `run_once` option tells Qemu to run only once,
which is useful for Windows installs that handle reboots for you.
[GH-687]
* builder/virtualbox: Nice errors if Packer can't write to
the output directory.
* provisioner/puppet-masterless: Can now specify a `manifest_dir` to
upload manifests to the remote machine for imports. [GH-655]
......
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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment