X-Git-Url: https://iankelling.org/git/?p=buildscripts;a=blobdiff_plain;f=go;fp=go;h=eb86add76d56653f26c924a8a23490657add80fa;hp=9175d0cd00c5496e9cad49abb2fcfdf11efab699;hb=a92d67f31b2f8359baf97eabb0833e17c59ba92f;hpb=c426f5dc07b0a086a3163697db3abb516955566c diff --git a/go b/go index 9175d0c..eb86add 100755 --- a/go +++ b/go @@ -13,39 +13,48 @@ m() { printf "$pre %s\n" "$*"; "$@"; } e() { printf "$pre %s\n" "$*"; } err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $0: $*" >&2; } + m cd /a/opt/go.git -m git fetch -vers=($(git tag | sort -Vr | grep -E '^go[0-9.]+$' | head)) - -ver=${vers[0]} -dl() { - arch=$(dpkg --print-architecture) - f=${ver}.linux-${arch}.tar.gz - - if [[ -e $f ]]; then - timestamp=$(stat -c %Y $f) - else - timestamp=0 - fi - m wget -N https://dl.google.com/go/$f || ret=$? -} -dl -# 8 is return code for 404. for a new release, they might not have a binary out yet -if [[ $ret == 8 ]]; then - ver=${vers[1]} +# don't check for updates on go more than once a day +yesterday=$(( $(date +%s) - 60*60*24 )) +if (( $(stat -c %Y FETCH_HEAD) < yesterday )); then + m git fetch + touch ~/.local/gofetch + + vers=($(git tag | sort -Vr | grep -E '^go[0-9.]+$' | head)) + + ver=${vers[0]} + dl() { + arch=$(dpkg --print-architecture) + f=${ver}.linux-${arch}.tar.gz + + if [[ -e $f ]]; then + timestamp=$(stat -c %Y $f) + else + timestamp=0 + fi + m wget -N https://dl.google.com/go/$f || ret=$? + } dl -fi + # 8 is return code for 404. for a new release, they might not have a binary out yet + if [[ $ret == 8 ]]; then + ver=${vers[1]} + dl + fi + + new_timestamp=$(stat -c %Y $f) + if [[ $timestamp != $new_timestamp || ! -e /usr/local/go/bin/go ]]; then + m sudo rm -rf /usr/local/go + m sudo tar -C /usr/local -xzf $f + fi + + shopt -s nullglob + for x in go*.tar.gz; do + if [[ $x == $f ]]; then continue; fi + rm -fv $x + done -new_timestamp=$(stat -c %Y $f) -if [[ $timestamp != $new_timestamp || ! -e /usr/local/go/bin/go ]]; then - m sudo rm -rf /usr/local/go - m sudo tar -C /usr/local -xzf $f fi -shopt -s nullglob -for x in go*.tar.gz; do - if [[ $x == $f ]]; then continue; fi - rm -fv $x -done go get -u mvdan.cc/fdroidcl