diff --git a/core/os/device/remotessh/commands.go b/core/os/device/remotessh/commands.go index 62082e5142..a1e35cc80c 100644 --- a/core/os/device/remotessh/commands.go +++ b/core/os/device/remotessh/commands.go @@ -22,6 +22,7 @@ import ( "net" "os" "path" + "runtime" "strings" "sync" @@ -185,8 +186,16 @@ func (b binding) PushFile(ctx context.Context, source, dest string) error { if err != nil { return err } + mode := permission.Mode() + // If we are on windows pushing to Linux, we lose the executable + // bit, get it back. + if (b.os == device.Linux || + b.os == device.OSX) && + runtime.GOOS == "windows" { + mode |= 0550 + } - return b.WriteFile(ctx, infile, permission.Mode(), dest) + return b.WriteFile(ctx, infile, mode, dest) } // doTunnel tunnels a single connection through the SSH connection. @@ -287,7 +296,7 @@ func (b binding) GetEnv(ctx context.Context) (*shell.Env, error) { // ListExecutables returns the executables in a particular directory as given by path func (b binding) ListExecutables(ctx context.Context, inPath string) ([]string, error) { if inPath == "" { - inPath = "." + inPath = b.GetURIRoot() } files, err := b.Shell("find", `"`+inPath+`"`, "-mindepth", "1", "-maxdepth", "1", "-type", "f", "-executable", "-printf", `%f\\n`).Call(ctx) if err != nil { @@ -305,7 +314,7 @@ func (b binding) ListExecutables(ctx context.Context, inPath string) ([]string, // ListDirectories returns a list of directories rooted at a particular path func (b binding) ListDirectories(ctx context.Context, inPath string) ([]string, error) { if inPath == "" { - inPath = "." + inPath = b.GetURIRoot() } dirs, err := b.Shell("find", `"`+inPath+`"`, "-mindepth", "1", "-maxdepth", "1", "-type", "d", "-printf", `%f\\n`).Call(ctx) if err != nil { @@ -346,3 +355,7 @@ func (b binding) IsDirectory(ctx context.Context, inPath string) (bool, error) { func (b binding) GetWorkingDirectory(ctx context.Context) (string, error) { return b.Shell("pwd").Call(ctx) } + +func (b binding) GetURIRoot() string { + return "/" +} diff --git a/core/os/device/remotessh/device.go b/core/os/device/remotessh/device.go index 27c8171bdf..df46993af0 100644 --- a/core/os/device/remotessh/device.go +++ b/core/os/device/remotessh/device.go @@ -26,6 +26,7 @@ import ( "github.com/golang/protobuf/jsonpb" "github.com/google/gapid/core/app/layout" + "github.com/google/gapid/core/log" "github.com/google/gapid/core/os/device" "github.com/google/gapid/core/os/device/bind" "github.com/google/gapid/core/os/shell" @@ -196,12 +197,20 @@ func GetConnectedDevice(ctx context.Context, c Configuration) (Device, error) { return nil, err } - devInfo, err := b.Shell("./device-info").In(dir).Call(ctx) + stderr := bytes.Buffer{} + stdout := bytes.Buffer{} + + err = b.Shell("./device-info").In(dir).Capture(&stdout, &stderr).Run(ctx) if err != nil { return nil, err } + if stderr.String() != "" { + log.W(ctx, "Deviceinfo succeeded, but returned error string %s", stderr.String()) + } + devInfo := stdout.String() + var device device.Instance if err := jsonpb.Unmarshal(bytes.NewReader([]byte(devInfo)), &device); err != nil {