github.com/containers/podman/v5@v5.1.0-rc1/hack/install_golangci.sh (about) 1 #!/usr/bin/env bash 2 3 # This script is intended to be a convenience, to be called from the 4 # Makefile `.install.golangci-lint` target. Any other usage is not recommended. 5 6 die() { echo "${1:-No error message given} (from $(basename $0))"; exit 1; } 7 8 [ -n "$VERSION" ] || die "\$VERSION is empty or undefined" 9 10 function install() { 11 local retry=$1 12 13 local msg="Installing golangci-lint v$VERSION into $BIN" 14 if [[ $retry -ne 0 ]]; then 15 msg+=" - retry #$retry" 16 fi 17 echo $msg 18 19 curl -sSL --retry 5 https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$VERSION 20 } 21 22 # Undocumented behavior: golangci-lint installer requires $BINDIR in env, 23 # will default to ./bin but we can't rely on that. 24 export BINDIR="./bin" 25 BIN="$BINDIR/golangci-lint" 26 if [ ! -x "$BIN" ]; then 27 # This flakes much too frequently with "crit unable to find v1.51.1" 28 for retry in $(seq 0 5); do 29 install $retry && exit 0 30 sleep 5 31 done 32 else 33 # Prints its own file name as part of --version output 34 $BIN --version | grep "$VERSION" 35 if [ $? -eq 0 ]; then 36 echo "Using existing $BINDIR/$($BIN --version)" 37 else 38 install 39 fi 40 fi