mirror of
https://github.com/securego/gosec.git
synced 2024-11-05 19:45:51 +00:00
re-generate install.sh with latest godownloader (#446)
This commit is contained in:
parent
7525fe4bb7
commit
c998389da2
1 changed files with 23 additions and 32 deletions
53
install.sh
53
install.sh
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
# Code generated by godownloader on 2018-10-05T09:52:28Z. DO NOT EDIT.
|
# Code generated by godownloader on 2020-03-02T13:35:13Z. DO NOT EDIT.
|
||||||
#
|
#
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
@ -27,11 +27,12 @@ parse_args() {
|
||||||
# over-ridden by flag below
|
# over-ridden by flag below
|
||||||
|
|
||||||
BINDIR=${BINDIR:-./bin}
|
BINDIR=${BINDIR:-./bin}
|
||||||
while getopts "b:dh?" arg; do
|
while getopts "b:dh?x" arg; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
b) BINDIR="$OPTARG" ;;
|
b) BINDIR="$OPTARG" ;;
|
||||||
d) log_set_priority 10 ;;
|
d) log_set_priority 10 ;;
|
||||||
h | \?) usage "$0" ;;
|
h | \?) usage "$0" ;;
|
||||||
|
x) set -x ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
|
@ -42,40 +43,33 @@ parse_args() {
|
||||||
# network, either nothing will happen or will syntax error
|
# network, either nothing will happen or will syntax error
|
||||||
# out preventing half-done work
|
# out preventing half-done work
|
||||||
execute() {
|
execute() {
|
||||||
tmpdir=$(mktmpdir)
|
tmpdir=$(mktemp -d)
|
||||||
log_debug "downloading files into ${tmpdir}"
|
log_debug "downloading files into ${tmpdir}"
|
||||||
http_download "${tmpdir}/${TARBALL}" "${TARBALL_URL}"
|
http_download "${tmpdir}/${TARBALL}" "${TARBALL_URL}"
|
||||||
http_download "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}"
|
http_download "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}"
|
||||||
hash_sha256_verify "${tmpdir}/${TARBALL}" "${tmpdir}/${CHECKSUM}"
|
hash_sha256_verify "${tmpdir}/${TARBALL}" "${tmpdir}/${CHECKSUM}"
|
||||||
srcdir="${tmpdir}"
|
srcdir="${tmpdir}"
|
||||||
(cd "${tmpdir}" && untar "${TARBALL}")
|
(cd "${tmpdir}" && untar "${TARBALL}")
|
||||||
install -d "${BINDIR}"
|
test ! -d "${BINDIR}" && install -d "${BINDIR}"
|
||||||
for binexe in "gosec" ; do
|
for binexe in $BINARIES; do
|
||||||
if [ "$OS" = "windows" ]; then
|
if [ "$OS" = "windows" ]; then
|
||||||
binexe="${binexe}.exe"
|
binexe="${binexe}.exe"
|
||||||
fi
|
fi
|
||||||
install "${srcdir}/${binexe}" "${BINDIR}/"
|
install "${srcdir}/${binexe}" "${BINDIR}/"
|
||||||
log_info "installed ${BINDIR}/${binexe}"
|
log_info "installed ${BINDIR}/${binexe}"
|
||||||
done
|
done
|
||||||
|
rm -rf "${tmpdir}"
|
||||||
}
|
}
|
||||||
is_supported_platform() {
|
get_binaries() {
|
||||||
platform=$1
|
case "$PLATFORM" in
|
||||||
found=1
|
darwin/amd64) BINARIES="gosec" ;;
|
||||||
case "$platform" in
|
linux/amd64) BINARIES="gosec" ;;
|
||||||
darwin/amd64) found=0 ;;
|
windows/amd64) BINARIES="gosec" ;;
|
||||||
linux/amd64) found=0 ;;
|
*)
|
||||||
windows/amd64) found=0 ;;
|
|
||||||
esac
|
|
||||||
return $found
|
|
||||||
}
|
|
||||||
check_platform() {
|
|
||||||
if is_supported_platform "$PLATFORM"; then
|
|
||||||
# optional logging goes here
|
|
||||||
true
|
|
||||||
else
|
|
||||||
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"
|
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"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
tag_to_version() {
|
tag_to_version() {
|
||||||
if [ -z "${TAG}" ]; then
|
if [ -z "${TAG}" ]; then
|
||||||
|
@ -93,7 +87,7 @@ tag_to_version() {
|
||||||
VERSION=${TAG#v}
|
VERSION=${TAG#v}
|
||||||
}
|
}
|
||||||
adjust_format() {
|
adjust_format() {
|
||||||
# change format (tar.gz or zip) based on ARCH
|
# change format (tar.gz or zip) based on OS
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
adjust_os() {
|
adjust_os() {
|
||||||
|
@ -165,7 +159,9 @@ log_crit() {
|
||||||
uname_os() {
|
uname_os() {
|
||||||
os=$(uname -s | tr '[:upper:]' '[:lower:]')
|
os=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
case "$os" in
|
case "$os" in
|
||||||
msys_nt) os="windows" ;;
|
cygwin_nt*) os="windows" ;;
|
||||||
|
mingw*) os="windows" ;;
|
||||||
|
msys_nt*) os="windows" ;;
|
||||||
esac
|
esac
|
||||||
echo "$os"
|
echo "$os"
|
||||||
}
|
}
|
||||||
|
@ -225,8 +221,8 @@ uname_arch_check() {
|
||||||
untar() {
|
untar() {
|
||||||
tarball=$1
|
tarball=$1
|
||||||
case "${tarball}" in
|
case "${tarball}" in
|
||||||
*.tar.gz | *.tgz) tar -xzf "${tarball}" ;;
|
*.tar.gz | *.tgz) tar --no-same-owner -xzf "${tarball}" ;;
|
||||||
*.tar) tar -xf "${tarball}" ;;
|
*.tar) tar --no-same-owner -xf "${tarball}" ;;
|
||||||
*.zip) unzip "${tarball}" ;;
|
*.zip) unzip "${tarball}" ;;
|
||||||
*)
|
*)
|
||||||
log_err "untar unknown archive format for ${tarball}"
|
log_err "untar unknown archive format for ${tarball}"
|
||||||
|
@ -234,11 +230,6 @@ untar() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
mktmpdir() {
|
|
||||||
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
|
|
||||||
mkdir -p "${TMPDIR}"
|
|
||||||
echo "${TMPDIR}"
|
|
||||||
}
|
|
||||||
http_download_curl() {
|
http_download_curl() {
|
||||||
local_file=$1
|
local_file=$1
|
||||||
source_url=$2
|
source_url=$2
|
||||||
|
@ -359,7 +350,7 @@ uname_arch_check "$ARCH"
|
||||||
|
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
|
|
||||||
check_platform
|
get_binaries
|
||||||
|
|
||||||
tag_to_version
|
tag_to_version
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue