9
9
# Environment variables:
10
10
# - INSTALL_DIRECTORY (optional): defaults to $GOPATH/bin
11
11
# - DEP_RELEASE_TAG (optional): defaults to fetching the latest release
12
+ # - DEP_FAKE_OS (optional): use a fake value for OS (mostly for testing)
13
+ # - DEP_FAKE_ARCH (optional): use a fake value for ARCH (mostly for testing)
12
14
#
13
15
# You can install using this script:
14
16
# $ curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
@@ -34,9 +36,9 @@ downloadJSON() {
34
36
exit 1
35
37
fi
36
38
if [ " $code " != 200 ]; then
37
- echo " Request failed with code $code "
38
- exit 1
39
- fi
39
+ echo " Request failed with code $code "
40
+ exit 1
41
+ fi
40
42
41
43
eval " $1 ='$body '"
42
44
}
@@ -56,9 +58,9 @@ downloadFile() {
56
58
fi
57
59
58
60
if [ " $code " != 200 ]; then
59
- echo " Request failed with code $code "
60
- exit 1
61
- fi
61
+ echo " Request failed with code $code "
62
+ exit 1
63
+ fi
62
64
}
63
65
64
66
findGoBinDirectory () {
@@ -77,34 +79,42 @@ findGoBinDirectory() {
77
79
}
78
80
79
81
initArch () {
80
- ARCH=$( uname -m)
81
- case $ARCH in
82
+ ARCH=$( uname -m)
83
+ if [ -n " $DEP_FAKE_ARCH " ]; then
84
+ echo " Using DEP_FAKE_ARCH"
85
+ ARCH=" $DEP_FAKE_ARCH "
86
+ fi
87
+ case $ARCH in
82
88
amd64) ARCH=" amd64" ;;
83
- x86_64) ARCH=" amd64" ;;
89
+ x86_64) ARCH=" amd64" ;;
84
90
i386) ARCH=" 386" ;;
85
91
* ) echo " Architecture ${ARCH} is not supported by this installation script" ; exit 1;;
86
- esac
87
- echo " ARCH = $ARCH "
92
+ esac
93
+ echo " ARCH = $ARCH "
88
94
}
89
95
90
96
initOS () {
91
- OS=$( uname | tr ' [:upper:]' ' [:lower:]' )
92
-
93
- case " $OS " in
97
+ OS=$( uname | tr ' [:upper:]' ' [:lower:]' )
98
+ if [ -n " $DEP_FAKE_OS " ]; then
99
+ echo " Using DEP_FAKE_OS"
100
+ OS=" $DEP_FAKE_OS "
101
+ fi
102
+ case " $OS " in
94
103
darwin) OS=' darwin' ;;
95
104
linux) OS=' linux' ;;
96
105
freebsd) OS=' freebsd' ;;
97
- mingw* ) OS=' windows' ;;
98
- msys* ) OS=' windows' ;;
106
+ mingw* ) OS=' windows' ;;
107
+ msys* ) OS=' windows' ;;
99
108
* ) echo " OS ${OS} is not supported by this installation script" ; exit 1;;
100
- esac
101
- echo " OS = $OS "
109
+ esac
110
+ echo " OS = $OS "
102
111
}
103
112
104
113
# identify platform based on uname output
105
114
initArch
106
115
initOS
107
116
117
+ # determine install directory if required
108
118
if [ -z " $INSTALL_DIRECTORY " ]; then
109
119
findGoBinDirectory INSTALL_DIRECTORY
110
120
fi
@@ -113,6 +123,11 @@ echo "Will install into $INSTALL_DIRECTORY"
113
123
# assemble expected release artifact name
114
124
BINARY=" dep-${OS} -${ARCH} "
115
125
126
+ # add .exe if on windows
127
+ if [ " $OS " = " windows" ]; then
128
+ BINARY=" $BINARY .exe"
129
+ fi
130
+
116
131
# if DEP_RELEASE_TAG was not provided, assume latest
117
132
if [ -z " $DEP_RELEASE_TAG " ]; then
118
133
downloadJSON LATEST_RELEASE " $RELEASES_URL /latest"
0 commit comments