builder/virtualbox: verify output dir is writable
This commit is contained in:
parent
4d3c9e7104
commit
2920239e6e
|
@ -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]
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue