meta: improve error-handling in update-all
This commit is contained in:
parent
0cf6e31d07
commit
79fdae6e2d
1 changed files with 18 additions and 18 deletions
36
auto-update
36
auto-update
|
@ -1,9 +1,6 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
note() {
|
note() { printf >&2 '\033[1m%s\033[0m\n' "$*" ;}
|
||||||
local IFS=' '
|
|
||||||
printf '\033[1m%s\033[0m\n' "$*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
investigate() {
|
investigate() {
|
||||||
url="${1?huh}"
|
url="${1?huh}"
|
||||||
|
@ -12,6 +9,9 @@ investigate() {
|
||||||
curl $curlflags "$url" | grep -F "$re" | grep -Eo '[0-9a-f]{40}'
|
curl $curlflags "$url" | grep -F "$re" | grep -Eo '[0-9a-f]{40}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
me="$(readlink -f "$0")" && cd "${me%/*}" || exit
|
||||||
|
curlflags="-L --no-progress-meter"
|
||||||
|
any=0
|
||||||
set -- \
|
set -- \
|
||||||
cosmo COSMO_COMMIT https://github.com/jart/cosmopolitan \
|
cosmo COSMO_COMMIT https://github.com/jart/cosmopolitan \
|
||||||
cosmo-kuroko KUROKO_COMMIT https://github.com/kuroko-lang/kuroko \
|
cosmo-kuroko KUROKO_COMMIT https://github.com/kuroko-lang/kuroko \
|
||||||
|
@ -22,27 +22,27 @@ cosmo-yices KISSAT_COMMIT https://github.com/BrunoDutertre/kissat \
|
||||||
cosmo-yices YICES_COMMIT https://github.com/SRI-CSL/yices2 \
|
cosmo-yices YICES_COMMIT https://github.com/SRI-CSL/yices2 \
|
||||||
;
|
;
|
||||||
|
|
||||||
me="$(readlink -f "$0")" && cd "${me%/*}" || exit
|
|
||||||
curlflags="-L --no-progress-meter"
|
|
||||||
any=0
|
|
||||||
|
|
||||||
while [ $# != 0 ]; do
|
while [ $# != 0 ]; do
|
||||||
dir="$1" tag="$2" url="$3"
|
dir="$1" tag="$2" url="$3"
|
||||||
shift && shift && shift || { note 'not a multiple of 3!'; exit 255 ;}
|
shift && shift && shift || { note 'not a multiple of 3!'; exit 255 ;}
|
||||||
|
if ! [ -d "$dir" -a -f "$dir/Dockerfile" -a -s "$dir/Dockerfile" ]; then
|
||||||
|
note "missing Dockerfile, skipping $dir ($tag)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
ours="$(grep -F "$tag"= "$dir/Dockerfile" | grep -Eo '[0-9a-f]{40}' | head -n1)"
|
ours="$(grep -F "$tag"= "$dir/Dockerfile" | grep -Eo '[0-9a-f]{40}' | head -n1)"
|
||||||
theirs="$(investigate "$url" | head -n1)"
|
theirs="$(investigate "$url" | head -n1)"
|
||||||
if [ ${#theirs} == 0 ]; then
|
if [ ${#ours} == 0 -o ${#theirs} == 0 ]; then
|
||||||
note "failed to retrieve update for $tag"
|
note "failed to retrieve update for $dir ($tag)"
|
||||||
elif [ "$ours" != "$theirs" ]; then
|
elif [ "$ours" != "$theirs" ]; then
|
||||||
any=1
|
any=1 && note "updating $dir ($tag)"
|
||||||
note "updating $dir"
|
|
||||||
other="${tag%_COMMIT}_SHA256"
|
other="${tag%_COMMIT}_SHA256"
|
||||||
tgz="${url%/}"
|
tgz="${url%/}" && tgz="${tgz%%/tree/*}" && tgz="$tgz/archive/$theirs.tar.gz"
|
||||||
tgz="${tgz%%/tree/*}"
|
{ : \
|
||||||
tgz="$tgz/archive/$theirs.tar.gz"
|
&& sum="$(curl $curlflags "$tgz" | sha256sum - | awk '{print $1}')" \
|
||||||
sum="$(curl $curlflags "$tgz" | sha256sum - | awk '{print $1}')"
|
&& notwa-util/shed "$dir/Dockerfile" "s/$ours/$theirs/g" \
|
||||||
notwa-util/shed "$dir/Dockerfile" "s/$ours/$theirs/g"
|
&& notwa-util/shed "$dir/Dockerfile" "s/$other=.*/$other=$sum/g" \
|
||||||
notwa-util/shed "$dir/Dockerfile" "s/$other=.*/$other=$sum/g"
|
;} \
|
||||||
|
|| note "failed to apply update for $dir ($tag)"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
[ $any = 1 ] || note "no new updates"
|
[ $any = 1 ] || note "no new updates"
|
||||||
|
|
Loading…
Add table
Reference in a new issue