new bundle fetcher
This commit is contained in:
parent
d1fd3f56a7
commit
959b62a2df
2
.gitignore
vendored
2
.gitignore
vendored
@ -49,4 +49,4 @@ bin/tmp/*
|
|||||||
.idea
|
.idea
|
||||||
scratchpad
|
scratchpad
|
||||||
|
|
||||||
build/builtin-actors/*.car
|
build/builtin-actors/v*
|
||||||
|
2
build/builtin-actors/bundles.env
Normal file
2
build/builtin-actors/bundles.env
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
actors7_release=""
|
||||||
|
actors8_release=a9635268e3b359bd
|
@ -3,50 +3,65 @@ set -e
|
|||||||
|
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
# gateway to use
|
. bundles.env
|
||||||
dweb="dweb.link"
|
|
||||||
|
|
||||||
actors7_cid=""
|
|
||||||
actors7_hash=""
|
|
||||||
actors8_cid="bafybeictmywrut5tprz5fnoti6adfwuvixvrfardhqwldxosmdsfavc56e"
|
|
||||||
actors8_hash="687b38f59b0c32800f55a8f1f303de214ec173c90e653984d67f393bc41c1416"
|
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
echo "$1"
|
echo "$1"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
check() {
|
|
||||||
file=$1
|
|
||||||
hash=$2
|
|
||||||
if [ -e "$file" ]; then
|
|
||||||
echo "$hash $file" | shasum -a 256 --check
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch() {
|
fetch() {
|
||||||
output=$1
|
ver=$1
|
||||||
cid=$2
|
rel=$2
|
||||||
hash=$3
|
|
||||||
if (check "$output" "$hash"); then
|
if [ ! -e $ver ]; then
|
||||||
return 0
|
mkdir $ver
|
||||||
else
|
|
||||||
echo "fetching $cid to $output"
|
|
||||||
curl --retry 3 -k "https://$dweb/ipfs/$cid" -o "$output"
|
|
||||||
check "$output" "$hash" || die "hash mismatch"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -e $ver/release ]; then
|
||||||
|
cur=$(cat $ver/release)
|
||||||
|
if [ $cur == $rel ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
for net in mainnet caterpillarnet butterflynet calibrationnet devnet testing; do
|
||||||
|
fetch_bundle $ver $rel $net
|
||||||
|
done
|
||||||
|
|
||||||
|
# remember the current release so that we don't have to hit github unless we have modified it
|
||||||
|
echo $rel > $ver/release
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -n "$actors7_cid" ]; then
|
fetch_bundle() {
|
||||||
fetch builtin-actors-v7.car "$actors7_cid" "$actors7_hash"
|
ver=$1
|
||||||
else
|
rel=$2
|
||||||
touch builtin-actors-v7.car
|
net=$3
|
||||||
|
|
||||||
|
target=builtin-actors-$net.car
|
||||||
|
hash=builtin-actors-$net.sha256
|
||||||
|
|
||||||
|
pushd $ver
|
||||||
|
|
||||||
|
# fetch the hash first and check if it matches what we (may) already have
|
||||||
|
curl -L --retry 3 https://github.com/filecoin-project/builtin-actors/releases/download/$rel/$hash -o $hash || die "error fetching hash for $ver/$net"
|
||||||
|
if (shasum -a 256 --check $hash); then
|
||||||
|
popd
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# we don't have the (correct) bundle, fetch it
|
||||||
|
curl -L --retry 3 https://github.com/filecoin-project/builtin-actors/releases/download/$rel/$target -o $target || die "error fetching bundle for $ver/$net"
|
||||||
|
# verify
|
||||||
|
shasum -a 256 --check $hash || die "hash mismatch"
|
||||||
|
# all good
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -n "$actors7_release" ]; then
|
||||||
|
fetch v7 "$actors7_release"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$actors8_cid" ]; then
|
if [ -n "$actors8_release" ]; then
|
||||||
fetch builtin-actors-v8.car "$actors8_cid" "$actors8_hash"
|
fetch v8 "$actors8_release"
|
||||||
else
|
|
||||||
touch builtin-actors-v8.car
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user