From e6e564ff791a6c5614935ddd1d3ea07415f3c88e Mon Sep 17 00:00:00 2001 From: Sergey Maskalik Date: Tue, 11 Feb 2020 21:55:13 -0800 Subject: [PATCH] Update install script to match latest goreleaser --- install.sh | 87 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/install.sh b/install.sh index d347a30..a3f882b 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/sh set -e -# Code generated by godownloader on 2018-11-15T15:08:53Z. DO NOT EDIT. +# Code generated by godownloader on 2020-02-12T05:48:19Z. DO NOT EDIT. # usage() { @@ -23,15 +23,16 @@ EOF } parse_args() { - #BINDIR is ./bin unless set be ENV + #BINDIR is /usr/local/bin unless set be ENV # over-ridden by flag below BINDIR=${BINDIR:-/usr/local/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,41 +43,41 @@ 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 "sqsmover" ; 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 - linux/amd64) found=0 ;; - linux/386) found=0 ;; - darwin/amd64) found=0 ;; - darwin/386) found=0 ;; + rm -rf "${tmpdir}" +} +get_binaries() { + case "$PLATFORM" in + darwin/amd64) BINARIES="sqsmover" ;; + darwin/arm64) BINARIES="sqsmover" ;; + darwin/armv6) BINARIES="sqsmover" ;; + linux/386) BINARIES="sqsmover" ;; + linux/amd64) BINARIES="sqsmover" ;; + linux/arm64) BINARIES="sqsmover" ;; + linux/armv6) BINARIES="sqsmover" ;; + windows/386) BINARIES="sqsmover" ;; + windows/amd64) BINARIES="sqsmover" ;; + windows/arm64) BINARIES="sqsmover" ;; + windows/armv6) BINARIES="sqsmover" ;; + *) + 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 @@ -94,15 +95,32 @@ tag_to_version() { VERSION=${TAG#v} } adjust_format() { - # change format (tar.gz or zip) based on ARCH + # change format (tar.gz or zip) based on OS + case ${OS} in + windows) FORMAT=zip ;; + esac true } adjust_os() { # adjust archive name based on OS + case ${OS} in + 386) OS=i386 ;; + amd64) OS=x86_64 ;; + darwin) OS=Darwin ;; + linux) OS=Linux ;; + windows) OS=Windows ;; + esac true } adjust_arch() { # adjust archive name based on ARCH + case ${ARCH} in + 386) ARCH=i386 ;; + amd64) ARCH=x86_64 ;; + darwin) ARCH=Darwin ;; + linux) ARCH=Linux ;; + windows) ARCH=Windows ;; + esac true } @@ -166,7 +184,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" } @@ -226,8 +246,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}" @@ -235,11 +255,6 @@ untar() { ;; esac } -mktmpdir() { - test -z "$TMPDIR" && TMPDIR="$(mktemp -d)" - mkdir -p "${TMPDIR}" - echo "${TMPDIR}" -} http_download_curl() { local_file=$1 source_url=$2 @@ -360,7 +375,7 @@ uname_arch_check "$ARCH" parse_args "$@" -check_platform +get_binaries tag_to_version @@ -372,7 +387,7 @@ adjust_arch log_info "found version: ${VERSION} for ${TAG}/${OS}/${ARCH}" -NAME=${PROJECT_NAME}_${VERSION}_${OS}_${ARCH} +NAME=${PROJECT_NAME}_${OS}_${ARCH} TARBALL=${NAME}.${FORMAT} TARBALL_URL=${GITHUB_DOWNLOAD}/${TAG}/${TARBALL} CHECKSUM=checksums.txt