From 4ff0185add426a8cfaa1ba75e675500f5f48a436 Mon Sep 17 00:00:00 2001 From: Jeff Stamerjohn Date: Thu, 25 Jul 2013 09:28:04 -0700 Subject: [PATCH] Windows fixes Strip carriage returns from end of lines in virtualbox/driver.go, fixing wait for virtualbox host shutdown. Fix target upload directory path in communicator.go to use forward slashes. (When running on windows path/filepath returns backslashes...which does not work when the target host is unix). --- builder/virtualbox/driver.go | 3 +++ communicator/ssh/communicator.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/builder/virtualbox/driver.go b/builder/virtualbox/driver.go index 3a7e4bfb1..f73658b1b 100644 --- a/builder/virtualbox/driver.go +++ b/builder/virtualbox/driver.go @@ -50,6 +50,9 @@ func (d *VBox42Driver) IsRunning(name string) (bool, error) { } for _, line := range strings.Split(stdout.String(), "\n") { + // Need to trim off CR character when running in windows + line = strings.TrimRight(line, "\r"); + if line == `VMState="running"` { return true, nil } diff --git a/communicator/ssh/communicator.go b/communicator/ssh/communicator.go index b30a392dc..67d21aa6a 100644 --- a/communicator/ssh/communicator.go +++ b/communicator/ssh/communicator.go @@ -130,6 +130,11 @@ func (c *comm) Upload(path string, input io.Reader) error { target_dir := filepath.Dir(path) target_file := filepath.Base(path) + // On windows, filepath.Dir uses backslash seperators (ie. "\tmp"). + // This does not work when the target host is unix. Switch to forward slash + // which works for unix and windows + target_dir = filepath.ToSlash(target_dir) + // Start the sink mode on the other side // TODO(mitchellh): There are probably issues with shell escaping the path log.Println("Starting remote scp process in sink mode")