meta: make auto-update more robust
This commit is contained in:
parent
76d6e8213e
commit
c98b2c0fa5
1 changed files with 7 additions and 4 deletions
11
auto-update
11
auto-update
|
@ -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" ;} \
|
||||
;
|
||||
|
|
Loading…
Reference in a new issue