Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 81fdcf7de7
Fetching contributors…

Cannot retrieve contributors at this time

executable file 112 lines (89 sloc) 2.765 kB
#!/bin/bash
if [[ "$1" == "-h" || "$1" == "--help" ]]; then cat <<HELP
Chromium Updater
http://benalman.com/
Usage: $(basename "$0") [revision]
Download and install the latest Chromium and dev tools, modifying the binary
to use those custom dev tools (downloaded into ~/.dotfiles/caches/chromium).
See ~.dotfiles/conf/update_chromium_etc.sh for sample dev tools customization.
If a revision isn't specified, the latest stable revision will be installed.
Copyright (c) 2011 "Cowboy" Ben Alman
Licensed under the MIT license.
http://benalman.com/about/license/
HELP
exit; fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
os="Mac"
app_file="chrome-mac.zip"
app_path="/Applications"
else
echo "Linux unsupported (for now)."
exit 1
fi
url_base="http://commondatastorage.googleapis.com/chromium-browser-continuous/$os"
dev_file="devtools_frontend.zip"
dev_path=~/.dotfiles/caches/chromium
current_revision=$(cat "$dev_path/REVISION" 2>/dev/null)
revision=$1
if [[ ! "$revision" ]]; then
echo -n "Checking latest Chromium version..."
revision=$(curl -s "$url_base/LAST_CHANGE")
if [[ "$revision" =~ ^[0-9]+$ ]]; then
echo "OK"
else
echo "ERROR"
echo "Error loading revision data from $url_base/LAST_CHANGE, aborting update."
exit 1
fi
fi
echo "Attempting to update Chromium to revision $revision."
if [[ "$revision" == "$current_revision" ]]; then
if [[ "$1" ]]; then
echo "Revision $revision is already installed!"
else
echo "Already up-to-date!"
fi
exit
fi
echo
tmp="$(mktemp -d /tmp/chromiumer.XXXXX)"
for f in "$app_file" "$dev_file"; do
echo "Downloading $f."
curl -fLo "$tmp/$f" --progress-bar "$url_base/$revision/$f"
if [[ ! -f "$tmp/$f" ]]; then
echo "Error downloading $f, aborting update."
rm -rf "$tmp"
exit 1
fi
done
echo -en "\nDeleting existing files..."
rm -rf "$app_path/Chromium.app" "$dev_path"
echo "OK"
echo -n "Creating new files..."
mkdir -p "$dev_path"
devtools_path="$dev_path/devtools"
echo "$revision" > "$dev_path/REVISION"
unzip -qo "$tmp/$dev_file" -d "$devtools_path"
unzip -qo "$tmp/$app_file" -d "$tmp"
echo "OK"
mv "$tmp/${app_file%.zip}/Chromium.app" "$app_path/"
echo -n "Modifying Chromium bin file to use --debug-devtools-frontend..."
bin_path="$app_path/Chromium.app/Contents/MacOS"
bin_file="$bin_path/Chromium"
mv "$bin_file" "$bin_path/Chromium-bin"
cat > "$bin_file" <<'BASH'
#!/bin/bash
devtools=~/.dotfiles/caches/chromium/devtools
"$0-bin" --debug-devtools-frontend="$devtools"
BASH
chmod +x "$bin_file"
echo "OK"
echo -n "Cleaning up..."
rm -rf "$tmp"
echo "OK"
additional=~/.dotfiles/conf/update_chromium_etc.sh
if [[ -f "$additional" ]]; then
echo -e "\nRunning update_chromium_etc.sh..."
source "$additional"
fi
echo -e "\nAll done!"
Jump to Line
Something went wrong with that request. Please try again.