Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 124 lines (101 sloc) 3.05 KB
#!/bin/bash
# Author: chaopeng
# Date: 2017-01-31
# This script is fork from https://github.com/scheib/chromium-latest-linux
# This also support Mac and Windows(Cygwin) now.
# Check https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html first when you want to download a very old build.
BASE_DIR=~/chromium-downloads
GREEN='\033[0;32m'
RESET='\033[0m'
if [[ "$OSTYPE" == "linux-gnu" ]]; then
export OS="LINUX"
elif [[ "$OSTYPE" == "darwin"* ]]; then
export OS="MAC"
elif [[ "$OSTYPE" == "cygwin" ]]; then
export OS="WIN"
else
echo "only support linux, mac, windows(cygwin) for now"
exit 1
fi
function last_change_url {
if [[ "$OS" == "LINUX" ]]; then
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2FLAST_CHANGE?alt=media"
elif [[ "$OS" == "MAC" ]]; then
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Mac%2FLAST_CHANGE?alt=media"
else
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Win%2FLAST_CHANGE?alt=media"
fi
}
function download_url {
if [[ "$OS" == "LINUX" ]]; then
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${1}%2Fchrome-linux.zip?alt=media"
elif [[ "$OS" == "MAC" ]]; then
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Mac%2F${1}%2Fchrome-mac.zip?alt=media"
else
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Win%2F${1}%2Fchrome-win32.zip?alt=media"
fi
}
function get_latest_rev {
LASTCHANGE_URL=`last_change_url`
REVISION=$(curl -s -S $LASTCHANGE_URL)
echo $REVISION
}
function get_closest_rev {
REVISION=$1
while true; do
curl -I 2>/dev/null `download_url $REVISION` | head -1 | grep 404 >/dev/null
if (($? == 1)); then
break
fi
REVISION=$(($REVISION-1))
done
echo $REVISION
}
function download_and_unzip {
REVISION=$1
if [ -d $REVISION ] ; then
return 0
fi
ZIP_URL=`download_url $REVISION`
ZIP_FILE="${REVISION}.zip"
rm -rf $REVISION
mkdir $REVISION
pushd $REVISION
curl -# $ZIP_URL > $ZIP_FILE
unzip -qq $ZIP_FILE
if [ -d chrome-linux ]; then
mv chrome-linux/* .
elif [ -d chrome-mac ]; then
mv chrome-mac/* .
elif [ -d chrome-win32 ]; then
mv chrome-win32/* .
fi
popd
}
if (($# < 1)); then
printf "usage: \n"
printf " ./get_chromuim [-r] latest - will get the latest chromium\n"
printf " ./get_chromuim [-r] rev - will get chromium by revision\n"
printf "\nYou can get revision here https://omahaproxy.appspot.com/ <Branch Base Position>\n"
exit 1
fi
mkdir -p $BASE_DIR
cd $BASE_DIR
last=${@: -1}
if [[ "$last" == "latest" ]]; then
REVISION=`get_latest_rev`
else
REVISION=`get_closest_rev $last`
fi
download_and_unzip $REVISION
if [[ "$last" == "latest" ]]; then
rm -f ./latest
ln -s $REVISION/ ./latest
fi
printf "${GREEN}GOT Chromium ${REVISION}${RESET}\n"
if (($# == 1)); then
exit 0
fi
if [[ "$1" == "-r" ]]; then
`run-chromium $REVISION`
fi