forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade_instructions.go
70 lines (60 loc) · 1.99 KB
/
upgrade_instructions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package libkb
import (
"os/exec"
"runtime"
)
func platformSpecificUpgradeInstructions(g *GlobalContext, upgradeURI string) {
switch runtime.GOOS {
case "linux":
linuxUpgradeInstructions(g)
case "darwin":
darwinUpgradeInstructions(g, upgradeURI)
case "windows":
windowsUpgradeInstructions(g, upgradeURI)
}
}
func linuxUpgradeInstructions(g *GlobalContext) {
hasPackageManager := func(name string) bool {
// Not all package managers are in /usr/bin. (openSUSE for example puts
// Yast in /usr/sbin.) Better to just do the full check now than to get
// confused later.
_, err := exec.LookPath(name)
return err == nil
}
packageName := "keybase"
if DefaultRunMode == DevelRunMode {
packageName = "kbdev"
} else if DefaultRunMode == StagingRunMode {
packageName = "kbstage"
}
if hasPackageManager("apt-get") {
printUpgradeCommand(g, "sudo apt-get update && sudo apt-get install "+packageName)
} else if hasPackageManager("dnf") {
printUpgradeCommand(g, "sudo dnf upgrade "+packageName)
} else if hasPackageManager("yum") {
printUpgradeCommand(g, "sudo yum upgrade "+packageName)
}
}
func darwinUpgradeInstructions(g *GlobalContext, upgradeURI string) {
packageName := "keybase"
if DefaultRunMode == DevelRunMode {
packageName = "keybase/beta/kbdev"
} else if DefaultRunMode == StagingRunMode {
packageName = "keybase/beta/kbstage"
}
if IsBrewBuild {
printUpgradeCommand(g, "brew update && brew upgrade "+packageName)
} else {
g.Log.Warning(" Please download a new version from " + upgradeURI)
}
// TODO: non-brew update instructions
}
func windowsUpgradeInstructions(g *GlobalContext, upgradeURI string) {
g.Log.Warning("To upgrade, download the latest Keybase installer from " + upgradeURI)
}
func printUpgradeCommand(g *GlobalContext, command string) {
g.Log.Warning("To upgrade, run the following command:")
g.Log.Warning(" " + command)
}