diff --git a/godownloader.sh b/godownloader.sh index 8cdb3c9..bee5dc2 100755 --- a/godownloader.sh +++ b/godownloader.sh @@ -1,6 +1,6 @@ #!/bin/sh set -e -# Code generated by godownloader on 2018-04-11T21:50:22Z. DO NOT EDIT. +# Code generated by godownloader on 2021-01-18T14:35:11Z. DO NOT EDIT. # usage() { @@ -27,11 +27,12 @@ parse_args() { # over-ridden by flag below BINDIR=${BINDIR:-./bin} - while getopts "b:dh?" arg; do + while getopts "b:dh?x" arg; do case "$arg" in b) BINDIR="$OPTARG" ;; d) log_set_priority 10 ;; h | \?) usage "$0" ;; + x) set -x ;; esac done shift $((OPTIND - 1)) @@ -42,55 +43,50 @@ parse_args() { # network, either nothing will happen or will syntax error # out preventing half-done work execute() { - tmpdir=$(mktmpdir) + tmpdir=$(mktemp -d) log_debug "downloading files into ${tmpdir}" http_download "${tmpdir}/${TARBALL}" "${TARBALL_URL}" http_download "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}" hash_sha256_verify "${tmpdir}/${TARBALL}" "${tmpdir}/${CHECKSUM}" srcdir="${tmpdir}" (cd "${tmpdir}" && untar "${TARBALL}") - install -d "${BINDIR}" - for binexe in "htmltest" ; do + test ! -d "${BINDIR}" && install -d "${BINDIR}" + for binexe in $BINARIES; do if [ "$OS" = "windows" ]; then binexe="${binexe}.exe" fi install "${srcdir}/${binexe}" "${BINDIR}/" log_info "installed ${BINDIR}/${binexe}" done -} -is_supported_platform() { - platform=$1 - found=1 - case "$platform" in - windows/386) found=0 ;; - windows/amd64) found=0 ;; - - windows/arm64) found=0 ;; - darwin/386) found=0 ;; - darwin/amd64) found=0 ;; - - darwin/arm64) found=0 ;; - linux/386) found=0 ;; - linux/amd64) found=0 ;; - - linux/arm64) found=0 ;; - windows/armv6) found=0 ;; - windows/armv7) found=0 ;; - darwin/armv6) found=0 ;; - darwin/armv7) found=0 ;; - linux/armv6) found=0 ;; - linux/armv7) found=0 ;; + rm -rf "${tmpdir}" +} +get_binaries() { + case "$PLATFORM" in + darwin/386) BINARIES="htmltest" ;; + darwin/amd64) BINARIES="htmltest" ;; + darwin/arm64) BINARIES="htmltest" ;; + darwin/armv6) BINARIES="htmltest" ;; + darwin/armv7) BINARIES="htmltest" ;; + linux/386) BINARIES="htmltest" ;; + linux/amd64) BINARIES="htmltest" ;; + linux/arm64) BINARIES="htmltest" ;; + linux/armv6) BINARIES="htmltest" ;; + linux/armv7) BINARIES="htmltest" ;; + openbsd/386) BINARIES="htmltest" ;; + openbsd/amd64) BINARIES="htmltest" ;; + openbsd/arm64) BINARIES="htmltest" ;; + openbsd/armv6) BINARIES="htmltest" ;; + openbsd/armv7) BINARIES="htmltest" ;; + windows/386) BINARIES="htmltest" ;; + windows/amd64) BINARIES="htmltest" ;; + windows/arm64) BINARIES="htmltest" ;; + windows/armv6) BINARIES="htmltest" ;; + windows/armv7) BINARIES="htmltest" ;; + *) + 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 + ;; 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" - exit 1 - fi } tag_to_version() { if [ -z "${TAG}" ]; then @@ -108,8 +104,8 @@ tag_to_version() { VERSION=${TAG#v} } adjust_format() { - # change format (tar.gz or zip) based on ARCH - case ${ARCH} in + # change format (tar.gz or zip) based on OS + case ${OS} in windows) FORMAT=zip ;; esac true @@ -119,8 +115,9 @@ adjust_os() { case ${OS} in 386) OS=i386 ;; amd64) OS=amd64 ;; - darwin) OS=osx ;; + darwin) OS=macos ;; linux) OS=linux ;; + openbsd) OS=openbsd ;; windows) OS=windows ;; esac true @@ -130,8 +127,9 @@ adjust_arch() { case ${ARCH} in 386) ARCH=i386 ;; amd64) ARCH=amd64 ;; - darwin) ARCH=osx ;; + darwin) ARCH=macos ;; linux) ARCH=linux ;; + openbsd) ARCH=openbsd ;; windows) ARCH=windows ;; esac true @@ -197,7 +195,9 @@ log_crit() { uname_os() { os=$(uname -s | tr '[:upper:]' '[:lower:]') case "$os" in - msys_nt) os="windows" ;; + cygwin_nt*) os="windows" ;; + mingw*) os="windows" ;; + msys_nt*) os="windows" ;; esac echo "$os" } @@ -257,8 +257,8 @@ uname_arch_check() { untar() { tarball=$1 case "${tarball}" in - *.tar.gz | *.tgz) tar -xzf "${tarball}" ;; - *.tar) tar -xf "${tarball}" ;; + *.tar.gz | *.tgz) tar --no-same-owner -xzf "${tarball}" ;; + *.tar) tar --no-same-owner -xf "${tarball}" ;; *.zip) unzip "${tarball}" ;; *) log_err "untar unknown archive format for ${tarball}" @@ -266,11 +266,6 @@ untar() { ;; esac } -mktmpdir() { - test -z "$TMPDIR" && TMPDIR="$(mktemp -d)" - mkdir -p "${TMPDIR}" - echo "${TMPDIR}" -} http_download_curl() { local_file=$1 source_url=$2 @@ -391,7 +386,7 @@ uname_arch_check "$ARCH" parse_args "$@" -check_platform +get_binaries tag_to_version