Skip to content

Commit c480eba

Browse files
committed
lib: add fetch-picolib script
1 parent be44c78 commit c480eba

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

lib/fetch-picolib.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
PICOLIB_VERSION=$1
4+
5+
if [ $PICOLIB_VERSION = "1.8.5" ]; then
6+
PICOLIB_SHA="5168a7ea6522717ec5867e0105a224fe7e3779371b095deedc2cd58da369d8cc"
7+
fi
8+
9+
# Name of the pre-created compiled directories.
10+
ZIP_FILE=libtock-picolib-$PICOLIB_VERSION.zip
11+
12+
# List of mirrors we support.
13+
MIRRORS=(\
14+
"https://www.cs.virginia.edu/~bjc8c/archive/tock"\
15+
"https://alpha.mirror.svc.schuermann.io/files"\
16+
)
17+
18+
let FOUND=0
19+
20+
# Try from each mirror until we successfully download a .zip file.
21+
for MIRROR in ${MIRRORS[@]}; do
22+
URL=$MIRROR/$ZIP_FILE
23+
echo "Fetching picolib from ${MIRROR}..."
24+
echo " Fetching ${URL}..."
25+
wget -q "$URL" && (echo "$PICOLIB_SHA $ZIP_FILE" | sha256sum -c)
26+
if [ $? -ne 0 ]; then
27+
echo " WARNING: Fetching picolib from mirror $MIRROR failed!" >&2
28+
else
29+
let FOUND=1
30+
break
31+
fi
32+
done
33+
34+
if [[ $FOUND -ne 0 ]]; then
35+
unzip $ZIP_FILE
36+
else
37+
echo "ERROR: Unable to find tock-picolib"
38+
exit -1
39+
fi

0 commit comments

Comments
 (0)