@@ -309,13 +309,29 @@ func cmdUpgrade() error {
309309}
310310
311311func upgradeBoot2DockerBinary () error {
312+ var (
313+ goos , arch string
314+ )
312315 latestVersion , err := getLatestReleaseName ("https://api.github.com/repos/boot2docker/boot2docker-cli/releases" )
313316 if err != nil {
314317 return fmt .Errorf ("Error attempting to get the latest boot2docker-cli release: %s" , err )
315318 }
316319 baseUrl := "https://github.com/boot2docker/boot2docker-cli/releases/download"
317- goos := "darwin"
318- arch := "amd64"
320+
321+ switch runtime .GOARCH {
322+ case "amd64" :
323+ arch = "amd64"
324+ }
325+
326+ switch runtime .GOOS {
327+ case "darwin" , "linux" :
328+ goos = runtime .GOOS
329+ case "windows" :
330+ goos = "windows"
331+
332+ // hack
333+ arch = "windows.exe"
334+ }
319335 binaryUrl := fmt .Sprintf ("%s/%s/boot2docker-%s-%s-%s" , baseUrl , latestVersion , latestVersion , goos , arch )
320336 currentBoot2DockerVersion := Version
321337 if err := attemptUpgrade (binaryUrl , "boot2docker" , latestVersion , currentBoot2DockerVersion ); err != nil {
@@ -342,16 +358,20 @@ func upgradeDockerClientBinary() error {
342358 if err != nil {
343359 return fmt .Errorf ("Error getting local Docker client version: %s" , err )
344360 }
345- clientOsOutput , err := exec .Command ("uname" , "-s" ).Output ()
346- if err != nil {
347- return fmt .Errorf ("Error executing `uname -s` to find Docker client OS: %s" , err )
361+ switch runtime .GOARCH {
362+ case "amd64" :
363+ clientArch = "x86_64"
364+ // todo: wishful thinking?
365+ case "arm" :
366+ clientArch = "armv7l"
348367 }
349- clientArchOutput , err := exec .Command ("uname" , "-m" ).Output ()
350- if err != nil {
351- return fmt .Errorf ("Error executing `uname -m` to find Docker client arch: %s" , err )
368+
369+ switch runtime .GOOS {
370+ case "darwin" :
371+ clientOs = "Darwin"
372+ case "linux" :
373+ clientOs = "Linux"
352374 }
353- clientOs = strings .TrimSpace (string (clientOsOutput ))
354- clientArch = strings .TrimSpace (string (clientArchOutput ))
355375 binaryUrl := fmt .Sprintf ("https://get.docker.com/builds/%s/%s/docker-latest" , clientOs , clientArch )
356376 if err := attemptUpgrade (binaryUrl , "docker" , latestVersion , localClientVersion ); err != nil {
357377 return fmt .Errorf ("Error attempting upgrade: %s" , err )
0 commit comments