@@ -27,11 +27,12 @@ parse_args() {
27
27
# over-ridden by flag below
28
28
29
29
BINDIR=${BINDIR:- ./ bin}
30
- while getopts " b:dh?" arg; do
30
+ while getopts " b:dh?x " arg; do
31
31
case " $arg " in
32
32
b) BINDIR=" $OPTARG " ;;
33
33
d) log_set_priority 10 ;;
34
34
h | \? ) usage " $0 " ;;
35
+ x) set -x ;;
35
36
esac
36
37
done
37
38
shift $(( OPTIND - 1 ))
@@ -42,44 +43,51 @@ parse_args() {
42
43
# network, either nothing will happen or will syntax error
43
44
# out preventing half-done work
44
45
execute () {
45
- tmpdir=$( mktmpdir )
46
+ tmpdir=$( mktemp -d )
46
47
log_debug " downloading files into ${tmpdir} "
47
48
http_download " ${tmpdir} /${TARBALL} " " ${TARBALL_URL} "
48
49
http_download " ${tmpdir} /${CHECKSUM} " " ${CHECKSUM_URL} "
49
50
hash_sha256_verify " ${tmpdir} /${TARBALL} " " ${tmpdir} /${CHECKSUM} "
50
51
srcdir=" ${tmpdir} /${NAME} "
51
52
rm -rf " ${srcdir} "
52
53
(cd " ${tmpdir} " && untar " ${TARBALL} " )
53
- install -d " ${BINDIR} "
54
- for binexe in " golangci-lint " ; do
54
+ test ! -d " ${BINDIR} " && install -d " ${BINDIR} "
55
+ for binexe in $BINARIES ; do
55
56
if [ " $OS " = " windows" ]; then
56
57
binexe=" ${binexe} .exe"
57
58
fi
58
59
install " ${srcdir} /${binexe} " " ${BINDIR} /"
59
60
log_info " installed ${BINDIR} /${binexe} "
60
61
done
61
- }
62
- is_supported_platform () {
63
- platform=$1
64
- found=1
65
- case " $platform " in
66
- darwin/amd64) found=0 ;;
67
- darwin/386) found=0 ;;
68
- windows/amd64) found=0 ;;
69
- windows/386) found=0 ;;
70
- linux/amd64) found=0 ;;
71
- linux/386) found=0 ;;
62
+ rm -rf " ${tmpdir} "
63
+ }
64
+ get_binaries () {
65
+ case " $PLATFORM " in
66
+ darwin/386) BINARIES=" golangci-lint" ;;
67
+ darwin/amd64) BINARIES=" golangci-lint" ;;
68
+ darwin/arm64) BINARIES=" golangci-lint" ;;
69
+ darwin/armv6) BINARIES=" golangci-lint" ;;
70
+ darwin/armv7) BINARIES=" golangci-lint" ;;
71
+ freebsd/386) BINARIES=" golangci-lint" ;;
72
+ freebsd/amd64) BINARIES=" golangci-lint" ;;
73
+ freebsd/arm64) BINARIES=" golangci-lint" ;;
74
+ freebsd/armv6) BINARIES=" golangci-lint" ;;
75
+ freebsd/armv7) BINARIES=" golangci-lint" ;;
76
+ linux/386) BINARIES=" golangci-lint" ;;
77
+ linux/amd64) BINARIES=" golangci-lint" ;;
78
+ linux/arm64) BINARIES=" golangci-lint" ;;
79
+ linux/armv6) BINARIES=" golangci-lint" ;;
80
+ linux/armv7) BINARIES=" golangci-lint" ;;
81
+ windows/386) BINARIES=" golangci-lint" ;;
82
+ windows/amd64) BINARIES=" golangci-lint" ;;
83
+ windows/arm64) BINARIES=" golangci-lint" ;;
84
+ windows/armv6) BINARIES=" golangci-lint" ;;
85
+ windows/armv7) BINARIES=" golangci-lint" ;;
86
+ * )
87
+ log_crit " platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX} /issues/new"
88
+ exit 1
89
+ ;;
72
90
esac
73
- return $found
74
- }
75
- check_platform () {
76
- if is_supported_platform " $PLATFORM " ; then
77
- # optional logging goes here
78
- true
79
- else
80
- log_crit " platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX} /issues/new"
81
- exit 1
82
- fi
83
91
}
84
92
tag_to_version () {
85
93
if [ -z " ${TAG} " ]; then
@@ -172,8 +180,9 @@ log_crit() {
172
180
uname_os () {
173
181
os=$( uname -s | tr ' [:upper:]' ' [:lower:]' )
174
182
case " $os " in
175
- msys_nt * ) os=" windows" ;;
183
+ cygwin_nt * ) os=" windows" ;;
176
184
mingw* ) os=" windows" ;;
185
+ msys_nt* ) os=" windows" ;;
177
186
esac
178
187
echo " $os "
179
188
}
@@ -242,11 +251,6 @@ untar() {
242
251
;;
243
252
esac
244
253
}
245
- mktmpdir () {
246
- test -z " $TMPDIR " && TMPDIR=" $( mktemp -d) "
247
- mkdir -p " ${TMPDIR} "
248
- echo " ${TMPDIR} "
249
- }
250
254
http_download_curl () {
251
255
local_file=$1
252
256
source_url=$2
@@ -367,7 +371,7 @@ uname_arch_check "$ARCH"
367
371
368
372
parse_args " $@ "
369
373
370
- check_platform
374
+ get_binaries
371
375
372
376
tag_to_version
373
377
0 commit comments