Commit a2f7950f authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Make sure the cache dir is absolute

parent 6b04876e
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"path/filepath"
"runtime" "runtime"
) )
...@@ -34,13 +35,17 @@ func main() { ...@@ -34,13 +35,17 @@ func main() {
log.Printf("Packer config: %+v", config) log.Printf("Packer config: %+v", config)
defer plugin.CleanupClients()
cacheDir := os.Getenv("PACKER_CACHE_DIR") cacheDir := os.Getenv("PACKER_CACHE_DIR")
if cacheDir == "" { if cacheDir == "" {
cacheDir = "packer_cache" cacheDir = "packer_cache"
} }
cacheDir, err = filepath.Abs(cacheDir)
if err != nil {
fmt.Fprintf(os.Stderr, "Error preparing cache directory: \n\n%s\n", err)
os.Exit(1)
}
if err := os.MkdirAll(cacheDir, 0755); err != nil { if err := os.MkdirAll(cacheDir, 0755); err != nil {
fmt.Fprintf(os.Stderr, "Error preparing cache directory: \n\n%s\n", err) fmt.Fprintf(os.Stderr, "Error preparing cache directory: \n\n%s\n", err)
os.Exit(1) os.Exit(1)
...@@ -49,6 +54,8 @@ func main() { ...@@ -49,6 +54,8 @@ func main() {
log.Printf("Setting cache directory: %s", cacheDir) log.Printf("Setting cache directory: %s", cacheDir)
cache := &packer.FileCache{CacheDir: cacheDir} cache := &packer.FileCache{CacheDir: cacheDir}
defer plugin.CleanupClients()
envConfig := packer.DefaultEnvironmentConfig() envConfig := packer.DefaultEnvironmentConfig()
envConfig.Cache = cache envConfig.Cache = cache
envConfig.Commands = config.CommandNames() envConfig.Commands = config.CommandNames()
......
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