Skip to content

Commit c42d4a3

Browse files
authored
(llorllale#50) Fix checksum error in download script (llorllale#51)
1 parent 491757f commit c42d4a3

File tree

1 file changed

+27
-41
lines changed

1 file changed

+27
-41
lines changed

download-gitlint.sh

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
set -e
3-
# Code generated by godownloader on 2019-03-02T16:09:54Z. DO NOT EDIT.
3+
# Code generated by godownloader on 2019-08-18T15:25:39Z. DO NOT EDIT.
44
#
55

66
usage() {
@@ -43,43 +43,36 @@ parse_args() {
4343
# network, either nothing will happen or will syntax error
4444
# out preventing half-done work
4545
execute() {
46-
tmpdir=$(mktmpdir)
46+
tmpdir=$(mktemp -d)
4747
log_debug "downloading files into ${tmpdir}"
4848
http_download "${tmpdir}/${TARBALL}" "${TARBALL_URL}"
4949
http_download "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}"
5050
hash_sha256_verify "${tmpdir}/${TARBALL}" "${tmpdir}/${CHECKSUM}"
5151
srcdir="${tmpdir}"
5252
(cd "${tmpdir}" && untar "${TARBALL}")
53-
install -d "${BINDIR}"
54-
for binexe in "gitlint" ; do
53+
test ! -d "${BINDIR}" && install -d "${BINDIR}"
54+
for binexe in $BINARIES; do
5555
if [ "$OS" = "windows" ]; then
5656
binexe="${binexe}.exe"
5757
fi
5858
install "${srcdir}/${binexe}" "${BINDIR}/"
5959
log_info "installed ${BINDIR}/${binexe}"
6060
done
61-
}
62-
is_supported_platform() {
63-
platform=$1
64-
found=1
65-
case "$platform" in
66-
linux/386) found=0 ;;
67-
linux/amd64) found=0 ;;
68-
windows/386) found=0 ;;
69-
windows/amd64) found=0 ;;
70-
darwin/386) found=0 ;;
71-
darwin/amd64) found=0 ;;
61+
rm -rf "${tmpdir}"
62+
}
63+
get_binaries() {
64+
case "$PLATFORM" in
65+
darwin/386) BINARIES="gitlint" ;;
66+
darwin/amd64) BINARIES="gitlint" ;;
67+
linux/386) BINARIES="gitlint" ;;
68+
linux/amd64) BINARIES="gitlint" ;;
69+
windows/386) BINARIES="gitlint" ;;
70+
windows/amd64) BINARIES="gitlint" ;;
71+
*)
72+
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"
73+
exit 1
74+
;;
7275
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
8376
}
8477
tag_to_version() {
8578
if [ -z "${TAG}" ]; then
@@ -97,28 +90,24 @@ tag_to_version() {
9790
VERSION=${TAG#v}
9891
}
9992
adjust_format() {
100-
# change format (tar.gz or zip) based on ARCH
93+
# change format (tar.gz or zip) based on OS
10194
true
10295
}
10396
adjust_os() {
10497
# adjust archive name based on OS
10598
case ${OS} in
106-
386) OS=i386 ;;
99+
386) OS=x86_32 ;;
107100
amd64) OS=x86_64 ;;
108-
darwin) OS=Darwin ;;
109-
linux) OS=Linux ;;
110-
windows) OS=Windows ;;
101+
darwin) OS=osx ;;
111102
esac
112103
true
113104
}
114105
adjust_arch() {
115106
# adjust archive name based on ARCH
116107
case ${ARCH} in
117-
386) ARCH=i386 ;;
108+
386) ARCH=x86_32 ;;
118109
amd64) ARCH=x86_64 ;;
119-
darwin) ARCH=Darwin ;;
120-
linux) ARCH=Linux ;;
121-
windows) ARCH=Windows ;;
110+
darwin) ARCH=osx ;;
122111
esac
123112
true
124113
}
@@ -183,7 +172,9 @@ log_crit() {
183172
uname_os() {
184173
os=$(uname -s | tr '[:upper:]' '[:lower:]')
185174
case "$os" in
186-
msys_nt) os="windows" ;;
175+
cygwin_nt*) os="windows" ;;
176+
mingw*) os="windows" ;;
177+
msys_nt*) os="windows" ;;
187178
esac
188179
echo "$os"
189180
}
@@ -252,11 +243,6 @@ untar() {
252243
;;
253244
esac
254245
}
255-
mktmpdir() {
256-
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
257-
mkdir -p "${TMPDIR}"
258-
echo "${TMPDIR}"
259-
}
260246
http_download_curl() {
261247
local_file=$1
262248
source_url=$2
@@ -377,7 +363,7 @@ uname_arch_check "$ARCH"
377363

378364
parse_args "$@"
379365

380-
check_platform
366+
get_binaries
381367

382368
tag_to_version
383369

0 commit comments

Comments
 (0)