Added time-keeping and kernel downloading
This commit is contained in:
1 parent
c5e75e3b0a
commit
0bb6d48c68
7 files changed
+634
-11
No files matched your search
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
# Fetches the ANISE kernels listed in data/kernels.tsv and verifies their
|
||||
# checksums. Idempotent: a file that is already present and correct is left alone.
|
||||
#
|
||||
# Usage: scripts/fetch-kernels.sh [directory]
|
||||
# ASTROKIT_KERNELS=/somewhere scripts/fetch-kernels.sh
|
||||
|
||||
set -e
|
||||
|
||||
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
manifest="$root/data/kernels.tsv"
|
||||
target=${1:-${ASTROKIT_KERNELS:-$root/data/kernels}}
|
||||
|
||||
if [ ! -f "$manifest" ]; then
|
||||
echo "no manifest at $manifest" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$target"
|
||||
echo "kernels -> $target"
|
||||
|
||||
status=0
|
||||
while IFS="$(printf '\t')" read -r name sha downloaded url purpose; do
|
||||
case "$name" in '' | \#*) continue ;; esac
|
||||
|
||||
path="$target/$name"
|
||||
if [ -f "$path" ] && [ "$(sha256sum "$path" | cut -d' ' -f1)" = "$sha" ]; then
|
||||
echo " ok $name"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo " fetching $name (pinned $downloaded)"
|
||||
if ! curl -sfL --retry 3 -o "$path.partial" "$url"; then
|
||||
echo " FAILED $name: could not download $url" >&2
|
||||
rm -f "$path.partial"
|
||||
status=1
|
||||
continue
|
||||
fi
|
||||
|
||||
got=$(sha256sum "$path.partial" | cut -d' ' -f1)
|
||||
if [ "$got" != "$sha" ]; then
|
||||
echo " FAILED $name: checksum mismatch" >&2
|
||||
echo " expected $sha" >&2
|
||||
echo " got $got" >&2
|
||||
rm -f "$path.partial"
|
||||
status=1
|
||||
continue
|
||||
fi
|
||||
|
||||
mv "$path.partial" "$path"
|
||||
echo " verified $name"
|
||||
done < "$manifest"
|
||||
|
||||
exit $status
|
||||
Reference in new issue
Block a user