new go version 1.17.1

This commit is contained in:
ston1th 2021-09-11 15:10:21 +02:00
commit d8a4cc4772

View file

@ -1,10 +1,8 @@
#!/bin/bash #!/bin/bash
set -e set -e
if [ $(id -u) -ne 0 ]; then errx() { echo "error: $1">&2; exit 1; }
echo "error: this script must be run as root">&2 [[ $(id -u) -ne 0 ]] && errx "this script must be run as root"
exit 1
fi
install_dir="/usr/local" install_dir="/usr/local"
go_dir="${install_dir}/go" go_dir="${install_dir}/go"
@ -16,46 +14,48 @@ bootstrap="${install_dir}/bootstrap-${v14}"
tgz14="${v14}.tar.gz" tgz14="${v14}.tar.gz"
path_v14="${install_dir}/${tgz14}" path_v14="${install_dir}/${tgz14}"
new="go1.17" v="${1-1.17.1}"
new_sum="d912e9db0fcbf69b7dacde058ee1675d0e3998905b8b2ab1080a5deb6df18f5d" case $v in
1.16.7) new_sum="07502f16366fbc697b1b09b842d29116e6d6607c9dc42b1d7c54b96f528c7952";;
1.17.1) new_sum="670ce36e100669f9be572a1603858ce4a64eb4b21a31fa5cdefb778609c40337";;
*) errx "no hash found for version ${v}";;
esac
new="go$v"
new_dir="${install_dir}/go-${new}"
tgznew="${new}.tar.gz" tgznew="${new}.tar.gz"
path_new="${install_dir}/${tgznew}" path_new="${install_dir}/${tgznew}"
rm -rf ${go_dir} rm -f ${go_dir}
if [[ ! -d "${bootstrap}" ]]; then if [[ ! -d "${bootstrap}" ]]; then
wget -q ${url}/${tgz14} -O ${path_v14} curl -sSL "${url}/${tgz14}" >${path_v14}
if [[ "$(sha256sum ${path_v14}|cut -d" " -f1)" != "${v14_sum}" ]]; then [[ "$(sha256sum ${path_v14}|cut -d" " -f1)" != "${v14_sum}" ]] && errx "wrong checksum: ${path_v14}"
echo "error: wrong checksum: ${path_v14}">&2
exit 1
fi
tar xfz ${path_v14} -C ${install_dir} tar xfz ${path_v14} -C ${install_dir}
mv ${install_dir}/go-${v14} ${bootstrap} mv ${install_dir}/go-${v14} ${bootstrap}
fi fi
wget -q ${url}/${tgznew} -O ${path_new} if [[ ! -d "${new_dir}" ]]; then
if [[ "$(sha256sum ${path_new}|cut -d" " -f1)" != "${new_sum}" ]]; then curl -sSL "${url}/${tgznew}" >${path_new}
echo "error: wrong checksum: ${path_new}">&2 [[ "$(sha256sum ${path_new}|cut -d" " -f1)" != "${new_sum}" ]] && errx "wrong checksum: ${path_new}"
exit 1 tar xfz ${path_new} -C ${install_dir}
fi fi
tar xfz ${path_new} -C ${install_dir}
mv ${install_dir}/go-${new} ${go_dir}
export CGO_ENABLED=0 export CGO_ENABLED=0
if [[ ! -x "${bootstrap}/bin/go" ]]; then if [[ ! -x "${bootstrap}/bin/go" ]]; then
cd ${bootstrap}/src cd ${bootstrap}/src
#./make.bash &> /dev/null
./make.bash ./make.bash
fi fi
export GOROOT_BOOTSTRAP=${bootstrap} if [[ ! -x "${new_dir}/bin/go" ]]; then
export GOROOT_BOOTSTRAP=${bootstrap}
[[ "$(uname -m)" == "x86_64" ]] && export GOARCH=amd64 || export GOARCH=386
cd ${new_dir}/src
./make.bash
fi
[[ "$(uname -m)" == "x86_64" ]] && export GOARCH=amd64 || export GOARCH=386 ln -s ${new_dir} ${go_dir}
cd ${go_dir}/src
./make.bash
#./make.bash &> /dev/null
export GOROOT=${go_dir} export GOROOT=${go_dir}
export PATH=${PATH}:${GOROOT}/bin:~/go/bin export PATH=${PATH}:${GOROOT}/bin:~/go/bin
@ -67,7 +67,7 @@ export CGO_ENABLED=${CGO_ENABLED}
export GOPATH=~/go export GOPATH=~/go
export GOROOT=${GOROOT} export GOROOT=${GOROOT}
export GO111MODULE=on export GO111MODULE=on
export PATH=\${PATH}:${GOROOT}:~/go/bin export PATH=\${PATH}:\${GOROOT}/bin:~/go/bin
EOF EOF