Ensure parent directories are created for base boxes

This commit is contained in:
Seth Vargo 2014-04-24 23:32:42 -04:00
parent 8dcabe977d
commit abe9bf8581
1 changed files with 7 additions and 0 deletions

View File

@ -39,6 +39,13 @@ func CopyContents(dst, src string) error {
// actually a proper box. This is an expected precondition.
func DirToBox(dst, dir string, ui packer.Ui, level int) error {
log.Printf("Turning dir into box: %s => %s", dir, dst)
// Make the containing directory, if it does not already exist
err := os.MkdirAll(filepath.Dir(dst), 0755)
if err != nil {
return err
}
dstF, err := os.Create(dst)
if err != nil {
return err