Last active
August 28, 2018 22:00
-
-
Save NiKoTron/b74999a63ee720a47adc769bef8282d4 to your computer and use it in GitHub Desktop.
Dart tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
chan="dev" | |
os=$(uname -s) | |
if [[ ${os} == "Linux" ]] | |
then | |
os="linux" | |
else | |
os="macos" | |
fi | |
arch=$(uname -m) | |
if [ ${arch} == "x86_64" ]; then | |
arch="x64" | |
else | |
arch="ia32" | |
fi | |
remote="https://storage.googleapis.com/dart-archive/channels/${chan}/release/latest/sdk/dartsdk-${os}-${arch}-release.zip" | |
if [[ -e dart-sdk ]]; then | |
localVersion=$(stat -c %x dart-sdk) | |
localVersion=$(date -d "${localVersion}" +"%s") | |
key="Last-Modified:" | |
lastModified=$(wget -S --spider $remote 2>&1 | grep -i $key) | |
lastModified="${lastModified#"${lastModified%%[![:space:]]*}"}" | |
lastModified=${lastModified#"$key"} | |
lastModified="${lastModified#"${lastModified%%[![:space:]]*}"}" | |
lastModified=$(date -d "${lastModified}" +"%s") | |
if [[ $localVersion -ge $lastModified ]]; then | |
echo "up to date" | |
exit 0 | |
fi | |
fi | |
remoteSum="${remote}.sha256sum" | |
wget -N $remote | |
wget -N $remoteSum | |
localArchive="dartsdk-${os}-${arch}-release.zip" | |
localArchiveSum="${localArchive}.sha256sum" | |
sha256sum -c $localArchiveSum | |
if [[ $? -gt 0 ]]; then | |
echo "wrong checksum" | |
exit 1 | |
fi | |
rm -rf dart-sdk | |
unzip $localArchive | |
rm $localArchiveSum | |
rm $localArchive |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment