From c0f9dbde4108dbca8cb4d04345a44f989ca39675 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 3 Sep 2014 21:08:57 -0700 Subject: [PATCH] builder/virtualbox: search VBOX_MSI_INSTALL_PATH [GH-1337] --- CHANGELOG.md | 2 ++ builder/virtualbox/common/driver.go | 30 ++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d715b702..980c0c500 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ BUG FIXES: * builder/parallels/all: Added some navigation keys [GH-1442] * builder/qemu: If headless, sdl display won't be used. [GH-1395] * builder/qemu: Use `512M` as `-m` default. [GH-1444] + * builder/virtualbox/all: Search `VBOX_MSI_INSTALL_PATH` for path to + `VBoxManage` on Windows. [GH-1337] * builder/virtualbox/all: Seed RNG to avoid same ports. [GH-1386] * builder/virtualbox/all: Better error if guest additions URL couldn't be detected. [GH-1439] diff --git a/builder/virtualbox/common/driver.go b/builder/virtualbox/common/driver.go index 08d86eb4a..b95bf81ae 100644 --- a/builder/virtualbox/common/driver.go +++ b/builder/virtualbox/common/driver.go @@ -55,15 +55,16 @@ func NewDriver() (Driver, error) { // On Windows, we check VBOX_INSTALL_PATH env var for the path if runtime.GOOS == "windows" { - if installPath := os.Getenv("VBOX_INSTALL_PATH"); installPath != "" { - log.Printf("[DEBUG] builder/virtualbox: VBOX_INSTALL_PATH: %s", - installPath) - for _, path := range strings.Split(installPath, ";") { - path = filepath.Join(path, "VBoxManage.exe") - if _, err := os.Stat(path); err == nil { - vboxmanagePath = path - break - } + vars := []string{"VBOX_INSTALL_PATH", "VBOX_MSI_INSTALL_PATH"} + for _, key := range vars { + value := os.Getenv(key) + if value != "" { + log.Printf( + "[DEBUG] builder/virtualbox: %s = %s", key, value) + vboxmanagePath = findVBoxManageWindows(value) + } + if vboxmanagePath != "" { + break } } } @@ -84,3 +85,14 @@ func NewDriver() (Driver, error) { return driver, nil } + +func findVBoxManageWindows(paths string) string { + for _, path := range strings.Split(paths, ";") { + path = filepath.Join(path, "VBoxManage.exe") + if _, err := os.Stat(path); err == nil { + return path + } + } + + return "" +}