From abe9bf8581e261982a6fc19d38fcadb348d2d6ff Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 24 Apr 2014 23:32:42 -0400 Subject: [PATCH] Ensure parent directories are created for base boxes --- post-processor/vagrant/util.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/post-processor/vagrant/util.go b/post-processor/vagrant/util.go index d6a1a750a..3cce14a82 100644 --- a/post-processor/vagrant/util.go +++ b/post-processor/vagrant/util.go @@ -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