From 3592d67093768d52280ddd8226ff08b784a5927c Mon Sep 17 00:00:00 2001 From: Alexander Kurilo Date: Wed, 17 Sep 2014 21:51:20 -0400 Subject: [PATCH] Fix detecting guest additions URL When system property exists with empty value, packer treats that empty value as a URL. The issue has been spotted on Arch with Virtualbox 4.3.16. --- builder/virtualbox/common/driver_4_2.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/builder/virtualbox/common/driver_4_2.go b/builder/virtualbox/common/driver_4_2.go index f77b29a57..e31959041 100644 --- a/builder/virtualbox/common/driver_4_2.go +++ b/builder/virtualbox/common/driver_4_2.go @@ -49,11 +49,12 @@ func (d *VBox42Driver) Iso() (string, error) { return "", err } - DefaultGuestAdditionsRe := regexp.MustCompile("Default Guest Additions ISO:(.*)") + DefaultGuestAdditionsRe := regexp.MustCompile("Default Guest Additions ISO:(.+)") for _, line := range strings.Split(stdout.String(), "\n") { // Need to trim off CR character when running in windows - line = strings.TrimRight(line, "\r") + // Trimming whitespaces at this point helps to filter out empty value + line = strings.TrimRight(line, " \r") matches := DefaultGuestAdditionsRe.FindStringSubmatch(line) if matches == nil { @@ -66,7 +67,7 @@ func (d *VBox42Driver) Iso() (string, error) { return isoname, nil } - return "", fmt.Errorf("Cannot find \"Default Guest Additions ISO\" in vboxmanage output") + return "", fmt.Errorf("Cannot find \"Default Guest Additions ISO\" in vboxmanage output (or it is empty)") } func (d *VBox42Driver) Import(name string, path string, flags []string) error {