From e9c4609dcadf70739e34f79680e69df973b24d8e Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 27 Dec 2021 17:18:30 +0100 Subject: [PATCH] fix: update install.sh (#937) * fix: update install.sh Signed-off-by: hackercat * fix: chmod +x install.sh Signed-off-by: hackercat Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- install.sh | 78 +++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) mode change 100644 => 100755 install.sh diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 2fff01b7..178dacd0 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/sh set -e -# Code generated by godownloader on 2019-01-15T06:15:28Z. DO NOT EDIT. +# Code generated by godownloader on 2021-12-22T16:10:52Z. DO NOT EDIT. # usage() { @@ -9,7 +9,7 @@ usage() { $this: download go binaries for nektos/act Usage: $this [-b] bindir [-d] [tag] - -b sets bindir or installation directory, Defaults to /usr/local/bin + -b sets bindir or installation directory, Defaults to ./bin -d turns on debug logging [tag] is a tag from https://github.com/nektos/act/releases @@ -23,15 +23,16 @@ EOF } parse_args() { - #BINDIR is /usr/local/bin unless set be ENV + #BINDIR is ./bin unless set be ENV # over-ridden by flag below - BINDIR=${BINDIR:-/usr/local/bin} - while getopts "b:dh?" arg; do + BINDIR=${BINDIR:-./bin} + 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,43 +43,45 @@ 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 "act" ; 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 + rm -rf "${tmpdir}" } -is_supported_platform() { - platform=$1 - found=1 - case "$platform" in - darwin/amd64) found=0 ;; - darwin/386) found=0 ;; - linux/amd64) found=0 ;; - linux/386) found=0 ;; - windows/amd64) found=0 ;; - windows/386) found=0 ;; +get_binaries() { + case "$PLATFORM" in + darwin/386) BINARIES="act" ;; + darwin/amd64) BINARIES="act" ;; + darwin/arm64) BINARIES="act" ;; + darwin/armv6) BINARIES="act" ;; + darwin/armv7) BINARIES="act" ;; + linux/386) BINARIES="act" ;; + linux/amd64) BINARIES="act" ;; + linux/arm64) BINARIES="act" ;; + linux/armv6) BINARIES="act" ;; + linux/armv7) BINARIES="act" ;; + windows/386) BINARIES="act" ;; + windows/amd64) BINARIES="act" ;; + windows/arm64) BINARIES="act" ;; + windows/armv6) BINARIES="act" ;; + windows/armv7) BINARIES="act" ;; + *) + 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 @@ -96,8 +99,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 @@ -185,7 +188,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" } @@ -245,8 +250,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}" @@ -254,11 +259,6 @@ untar() { ;; esac } -mktmpdir() { - test -z "$TMPDIR" && TMPDIR="$(mktemp -d)" - mkdir -p "${TMPDIR}" - echo "${TMPDIR}" -} http_download_curl() { local_file=$1 source_url=$2 @@ -379,7 +379,7 @@ uname_arch_check "$ARCH" parse_args "$@" -check_platform +get_binaries tag_to_version