meta: make auto-update more robust

This commit is contained in:
Connor Olding 2022-10-12 07:22:31 -07:00
parent 76d6e8213e
commit c98b2c0fa5

View file

@ -27,19 +27,22 @@ latest() { : \
&& { [ -d "$dir" ] && [ -f "$dir/$df" ] && [ -s "$dir/$df" ] \
|| { note "missing $df, skipping $dir ($tag)"; continue ;} \
;} \
&& ours="$(grep -F "$tag"= "$dir/$df" | grep -Eo '[0-9a-f]{40}')" \
&& grep -Fq "$tag=" "$dir/$df" \
&& ours="$(grep -F "$tag=" "$dir/$df" | cut -d= -f2-)" \
&& theirs="$(latest "$url")" ours="${ours%%$n*}" theirs="${theirs%%$n*}" \
&& if [ ${#ours} = 0 ] || [ ${#theirs} = 0 ] \
&& if [ ${#theirs} = 0 ] \
;then note "failed to retrieve update for $dir ($tag)" \
;elif [ "$ours" != "$theirs" ] \
;then any=1 && note "updating $dir ($tag)" \
&& other="${tag%_COMMIT}_SHA256" && tgz="${url%/}" \
&& tgz="${tgz%%/tree/*}" && tgz="$tgz/archive/$theirs.tar.gz" \
&& { sum="$(curl $flags "$tgz" | sha256sum - | awk '{print $1}')" \
&& notwa-util/shed "$dir/$df" "s/$ours/$theirs/g" \
&& notwa-util/shed "$dir/$df" "s/$tag=$ours/$tag=$theirs/g" \
&& notwa-util/shed "$dir/$df" "s/$other=.*/$other=$sum/g" \
;} \
|| note "failed to apply update for $dir ($tag)" \
;fi ;done \
;fi \
|| note "failed to determine update for $dir ($tag)" \
;done \
&& { [ $any = 1 ] || note "no new updates" ;} \
;