2022-10-04 19:12:49 -07:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2022-10-05 01:20:20 -07:00
|
|
|
note() { printf >&2 '\033[1m%s\033[0m\n' "$*" ;}
|
2022-10-04 19:12:49 -07:00
|
|
|
|
|
|
|
investigate() {
|
|
|
|
url="${1?huh}"
|
|
|
|
[ "${url#"https://github.com/"}" = "$url" ] \
|
|
|
|
&& re='/commit/' || re='/spoofed_commit_check/'
|
|
|
|
curl $curlflags "$url" | grep -F "$re" | grep -Eo '[0-9a-f]{40}'
|
|
|
|
}
|
|
|
|
|
2022-10-05 01:20:20 -07:00
|
|
|
me="$(readlink -f "$0")" && cd "${me%/*}" || exit
|
|
|
|
curlflags="-L --no-progress-meter"
|
|
|
|
any=0
|
2022-10-04 19:12:49 -07:00
|
|
|
set -- \
|
|
|
|
cosmo COSMO_COMMIT https://github.com/jart/cosmopolitan \
|
|
|
|
cosmo-kuroko KUROKO_COMMIT https://github.com/kuroko-lang/kuroko \
|
|
|
|
cosmo-muon MUON_COMMIT https://git.sr.ht/~lattis/muon \
|
|
|
|
cosmo-perl PERL_COMMIT https://github.com/G4Vi/perl5/tree/cosmo \
|
|
|
|
cosmo-python PYTHON_COMMIT https://github.com/ahgamut/cpython/tree/cosmo_py311 \
|
|
|
|
cosmo-yices KISSAT_COMMIT https://github.com/BrunoDutertre/kissat \
|
|
|
|
cosmo-yices YICES_COMMIT https://github.com/SRI-CSL/yices2 \
|
|
|
|
;
|
|
|
|
|
|
|
|
while [ $# != 0 ]; do
|
|
|
|
dir="$1" tag="$2" url="$3"
|
|
|
|
shift && shift && shift || { note 'not a multiple of 3!'; exit 255 ;}
|
2022-10-05 01:20:20 -07:00
|
|
|
if ! [ -d "$dir" -a -f "$dir/Dockerfile" -a -s "$dir/Dockerfile" ]; then
|
|
|
|
note "missing Dockerfile, skipping $dir ($tag)"
|
|
|
|
continue
|
|
|
|
fi
|
2022-10-04 19:12:49 -07:00
|
|
|
ours="$(grep -F "$tag"= "$dir/Dockerfile" | grep -Eo '[0-9a-f]{40}' | head -n1)"
|
|
|
|
theirs="$(investigate "$url" | head -n1)"
|
2022-10-05 01:20:20 -07:00
|
|
|
if [ ${#ours} == 0 -o ${#theirs} == 0 ]; then
|
|
|
|
note "failed to retrieve update for $dir ($tag)"
|
2022-10-04 19:12:49 -07:00
|
|
|
elif [ "$ours" != "$theirs" ]; then
|
2022-10-05 01:20:20 -07:00
|
|
|
any=1 && note "updating $dir ($tag)"
|
2022-10-04 19:12:49 -07:00
|
|
|
other="${tag%_COMMIT}_SHA256"
|
2022-10-05 01:20:20 -07:00
|
|
|
tgz="${url%/}" && tgz="${tgz%%/tree/*}" && tgz="$tgz/archive/$theirs.tar.gz"
|
|
|
|
{ : \
|
|
|
|
&& sum="$(curl $curlflags "$tgz" | sha256sum - | awk '{print $1}')" \
|
|
|
|
&& notwa-util/shed "$dir/Dockerfile" "s/$ours/$theirs/g" \
|
|
|
|
&& notwa-util/shed "$dir/Dockerfile" "s/$other=.*/$other=$sum/g" \
|
|
|
|
;} \
|
|
|
|
|| note "failed to apply update for $dir ($tag)"
|
2022-10-04 19:12:49 -07:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
[ $any = 1 ] || note "no new updates"
|