github.com/cnboonhan/delve@v0.0.0-20230908061759-363f2388c2fb/_scripts/test_linux.sh (about) 1 #!/bin/bash 2 set -e 3 set -x 4 5 apt-get -qq update 6 apt-get install -y gcc curl jq lsof 7 8 version=$1 9 arch=$2 10 11 12 if [ "$arch" != "ppc64le" ]; then 13 apt-get install -y dwz 14 dwz --version 15 fi 16 17 function getgo { 18 export GOROOT=/usr/local/go/$1 19 if [ ! -d "$GOROOT" ]; then 20 curl -sO https://dl.google.com/go/"$1".linux-"${arch}".tar.gz 21 mkdir -p /usr/local/go 22 tar -C /usr/local/go -xzf "$1".linux-"${arch}".tar.gz 23 mv -f /usr/local/go/go "$GOROOT" 24 fi 25 } 26 27 if [ "$version" = "gotip" ]; then 28 echo Building Go from tip 29 getgo $(curl https://go.dev/VERSION?m=text | head -1) 30 export GOROOT_BOOTSTRAP=$GOROOT 31 export GOROOT=/usr/local/go/go-tip 32 apt-get install -y git 33 git clone https://go.googlesource.com/go /usr/local/go/go-tip 34 cd /usr/local/go/go-tip/src 35 ./make.bash 36 cd - 37 else 38 echo Finding latest patch version for $version 39 echo "Go $version on $arch" 40 version=$(curl 'https://go.dev/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.|beta|rc)' | sort -rV | head -1) 41 if [ "x$version" = "x" ]; then 42 version=$(curl 'https://go.dev/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.)' | sort -rV | head -1) 43 fi 44 getgo $version 45 fi 46 47 48 GOPATH=$(pwd)/go 49 export GOPATH 50 export PATH=$PATH:$GOROOT/bin:$GOPATH/bin 51 go version 52 if [ "$arch" != "ppc64le" ]; then 53 go install honnef.co/go/tools/cmd/staticcheck@2023.1 || true 54 fi 55 56 uname -a 57 echo "$PATH" 58 echo "$GOROOT" 59 echo "$GOPATH" 60 cd delve 61 62 # Starting with go1.18 'go build' and 'go run' will try to stamp the build 63 # with the current VCS revision, which does not work with TeamCity 64 if [ "$version" = "gotip" ]; then 65 export GOFLAGS=-buildvcs=false 66 elif [ ${version:4:2} -gt 17 ]; then 67 export GOFLAGS=-buildvcs=false 68 fi 69 70 if [ "$arch" = "386" ]; then 71 ver=$(go version) 72 if [ "$ver" = "go version go1.19 linux/386" ]; then 73 export CGO_CFLAGS='-g -O0 -fno-stack-protector' 74 fi 75 fi 76 77 set +e 78 go run _scripts/make.go test 79 x=$? 80 if [ "$version" = "gotip" ]; then 81 exit 0 82 else 83 exit $x 84 fi