Skip to content

Commit c87c372

Browse files
authored
dev: update install.sh (#672)
1 parent 95d5b2c commit c87c372

File tree

4 files changed

+39
-67
lines changed

4 files changed

+39
-67
lines changed

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ tools/go.mod:
7979

8080
tools/godownloader: Makefile tools/go.mod
8181
# https://github.com/goreleaser/godownloader/issues/133
82-
cd tools && GOBIN=$(CURDIR)/tools GO111MODULE=off go get github.com/goreleaser/godownloader
82+
cd tools && GOBIN=$(CURDIR)/tools GO111MODULE=off go get -u github.com/goreleaser/godownloader
8383

8484
tools/svg-term:
8585
@mkdir -p tools
@@ -93,10 +93,8 @@ tools/Dracula.itermcolors:
9393
docs/demo.svg: tools/svg-term tools/Dracula.itermcolors
9494
PATH=$(CURDIR)/tools:$${PATH} svg-term --cast=183662 --out docs/demo.svg --window --width 110 --height 30 --from 2000 --to 20000 --profile ./tools/Dracula.itermcolors --term iterm2
9595

96-
install.sh:
97-
# dependencies: tools/godownloader .goreleaser.yml
98-
# TODO: use when Windows installation will be fixed in the upstream
99-
#PATH=$(CURDIR)/tools:$${PATH} tools/godownloader .goreleaser.yml | sed '/DO NOT EDIT/s/ on [0-9TZ:-]*//' > $@
96+
install.sh: tools/godownloader .goreleaser.yml
97+
PATH=$(CURDIR)/tools:$${PATH} tools/godownloader .goreleaser.yml | sed '/DO NOT EDIT/s/ on [0-9TZ:-]*//' > $@
10098

10199
README.md: FORCE golangci-lint
102100
go run ./scripts/gen_readme/main.go

README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,6 @@ Latest version: ![GitHub release](https://img.shields.io/github/release/golangci
5656

5757
Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version):
5858

59-
```bash
60-
# binary will be $(go env GOPATH)/bin/golangci-lint
61-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin vX.Y.Z
62-
63-
# or install it into ./bin/
64-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z
65-
66-
# In alpine linux (as it does not come with curl by default)
67-
wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z
68-
69-
golangci-lint --version
70-
```
71-
72-
As a fallback you can also use `raw.githubusercontent.com`
73-
7459
```bash
7560
# binary will be $(go env GOPATH)/bin/golangci-lint
7661
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin vX.Y.Z

README.tmpl.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,6 @@ Latest version: ![GitHub release](https://img.shields.io/github/release/golangci
5656

5757
Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version):
5858

59-
```bash
60-
# binary will be $(go env GOPATH)/bin/golangci-lint
61-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin vX.Y.Z
62-
63-
# or install it into ./bin/
64-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z
65-
66-
# In alpine linux (as it does not come with curl by default)
67-
wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z
68-
69-
golangci-lint --version
70-
```
71-
72-
As a fallback you can also use `raw.githubusercontent.com`
73-
7459
```bash
7560
# binary will be $(go env GOPATH)/bin/golangci-lint
7661
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin vX.Y.Z

install.sh

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ parse_args() {
2727
# over-ridden by flag below
2828

2929
BINDIR=${BINDIR:-./bin}
30-
while getopts "b:dh?" arg; do
30+
while getopts "b:dh?x" arg; do
3131
case "$arg" in
3232
b) BINDIR="$OPTARG" ;;
3333
d) log_set_priority 10 ;;
3434
h | \?) usage "$0" ;;
35+
x) set -x ;;
3536
esac
3637
done
3738
shift $((OPTIND - 1))
@@ -42,44 +43,51 @@ parse_args() {
4243
# network, either nothing will happen or will syntax error
4344
# out preventing half-done work
4445
execute() {
45-
tmpdir=$(mktmpdir)
46+
tmpdir=$(mktemp -d)
4647
log_debug "downloading files into ${tmpdir}"
4748
http_download "${tmpdir}/${TARBALL}" "${TARBALL_URL}"
4849
http_download "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}"
4950
hash_sha256_verify "${tmpdir}/${TARBALL}" "${tmpdir}/${CHECKSUM}"
5051
srcdir="${tmpdir}/${NAME}"
5152
rm -rf "${srcdir}"
5253
(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
5556
if [ "$OS" = "windows" ]; then
5657
binexe="${binexe}.exe"
5758
fi
5859
install "${srcdir}/${binexe}" "${BINDIR}/"
5960
log_info "installed ${BINDIR}/${binexe}"
6061
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+
;;
7290
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
8391
}
8492
tag_to_version() {
8593
if [ -z "${TAG}" ]; then
@@ -172,8 +180,9 @@ log_crit() {
172180
uname_os() {
173181
os=$(uname -s | tr '[:upper:]' '[:lower:]')
174182
case "$os" in
175-
msys_nt*) os="windows" ;;
183+
cygwin_nt*) os="windows" ;;
176184
mingw*) os="windows" ;;
185+
msys_nt*) os="windows" ;;
177186
esac
178187
echo "$os"
179188
}
@@ -242,11 +251,6 @@ untar() {
242251
;;
243252
esac
244253
}
245-
mktmpdir() {
246-
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
247-
mkdir -p "${TMPDIR}"
248-
echo "${TMPDIR}"
249-
}
250254
http_download_curl() {
251255
local_file=$1
252256
source_url=$2
@@ -367,7 +371,7 @@ uname_arch_check "$ARCH"
367371

368372
parse_args "$@"
369373

370-
check_platform
374+
get_binaries
371375

372376
tag_to_version
373377

0 commit comments

Comments
 (0)