veyron/services/mgmt/lib/binary: Fix cross-fs rename

DownloadToFile writes to a temporary file and then uses Rename when the
download is complete. By default, temp files are written to /tmp, which
is very often on a different filesystem, e.g. tmpfs.

This change puts the temporary file in the same directory as the final
filename.

E0127 13:59:12.732582 10162 impl.go:176] Rename(/tmp/709474347,
/home/veyron/device_manager/dmroot/app-ENvZ2SNjuooscKLZ6TYZ-A/installation-_9GBPvF5uWA/2015-01-27T13:58:48.684075-08:00/pkg/acl)
failed: rename /tmp/709474347
/home/veyron/device_manager/dmroot/app-ENvZ2SNjuooscKLZ6TYZ-A/installation-_9GBPvF5uWA/2015-01-27T13:58:48.684075-08:00/pkg/acl:
invalid cross-device link

Change-Id: If89b1d310ed0de63b98461cfc2172e8f3fd80b23
diff --git a/services/mgmt/lib/binary/impl.go b/services/mgmt/lib/binary/impl.go
index 8b5472d..2630395 100644
--- a/services/mgmt/lib/binary/impl.go
+++ b/services/mgmt/lib/binary/impl.go
@@ -8,6 +8,7 @@
 	"bytes"
 	"crypto/md5"
 	"encoding/hex"
+	"fmt"
 	"io"
 	"io/ioutil"
 	"os"
@@ -151,7 +152,8 @@
 }
 
 func DownloadToFile(ctx *context.T, von, path string) error {
-	dir, prefix := "", ""
+	dir := filepath.Dir(path)
+	prefix := fmt.Sprintf(".download.%s.", filepath.Base(path))
 	file, err := ioutil.TempFile(dir, prefix)
 	if err != nil {
 		vlog.Errorf("TempFile(%v, %v) failed: %v", dir, prefix, err)