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