Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding my 'bin/update_chromium' script, yay.

  • Loading branch information...
commit b843540d8cbb7910c85b378de7aed53e7a58cfb0 1 parent b877231
@cowboy authored
Showing with 142 additions and 0 deletions.
  1. +112 −0 bin/update_chromium
  2. +30 −0 conf/update_chromium_etc.sh
View
112 bin/update_chromium
@@ -0,0 +1,112 @@
+#!/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/$(basename "$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
+bin=$(echo $0 | perl -pe 's/$/-bin/')
+devtools=~/.dotfiles/caches/chromium/devtools
+"$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!"
View
30 conf/update_chromium_etc.sh
@@ -0,0 +1,30 @@
+# I use this (optional) file to make the font larger for presentations - Cowboy
+
+echo -n "Modifying fonts..."
+css=$(cat <<'CSS'
+/* === Added on `date` === */
+
+/* LARGER fonts in WebKit Inspector */
+
+/* Yes, this is intentional (selector specificity, etc) */
+body[class*="platform-"][class*="platform-"] .monospace,
+body[class*="platform-"][class*="platform-"] .source-code,
+.console-group-messages .outline-disclosure,
+.console-group-messages .outline-disclosure ol {
+ font-size: 20px !important;
+ line-height: 1.15em !important;
+}
+
+.styles-element-state-pane { margin-top: -53px !important; }
+.styles-element-state-pane.expanded { margin-top: 0 !important; }
+
+.section .header::before { top: -5px !important; }
+.section {
+ margin-top: 0.3em !important;
+ margin-bottom: 0.5em !important;
+}
+CSS
+)
+
+find "$devtools_path" \( -name devTools.css \) -exec bash -c "echo '$css' >> {}" \;
+echo "OK"
Please sign in to comment.
Something went wrong with that request. Please try again.