Skip to content

Commit b843540

Browse files
committed
Adding my 'bin/update_chromium' script, yay.
1 parent b877231 commit b843540

2 files changed

Lines changed: 142 additions & 0 deletions

File tree

bin/update_chromium

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/bin/bash
2+
3+
if [[ "$1" == "-h" || "$1" == "--help" ]]; then cat <<HELP
4+
Chromium Updater
5+
http://benalman.com/
6+
7+
Usage: `basename "$0"` [revision]
8+
9+
Download and install the latest Chromium and dev tools, modifying the binary
10+
to use those custom dev tools (downloaded into ~/.dotfiles/caches/chromium).
11+
See ~.dotfiles/conf/update_chromium_etc.sh for sample dev tools customization.
12+
13+
If a revision isn't specified, the latest stable revision will be installed.
14+
15+
Copyright (c) 2011 "Cowboy" Ben Alman
16+
Licensed under the MIT license.
17+
http://benalman.com/about/license/
18+
HELP
19+
exit; fi
20+
21+
if [[ "$OSTYPE" =~ ^darwin ]]; then
22+
os="Mac"
23+
app_file="chrome-mac.zip"
24+
app_path="/Applications"
25+
else
26+
echo "Linux unsupported (for now)."
27+
exit 1
28+
fi
29+
30+
url_base="http://commondatastorage.googleapis.com/chromium-browser-continuous/$os"
31+
dev_file="devtools_frontend.zip"
32+
33+
dev_path=~/.dotfiles/caches/chromium
34+
current_revision=$(cat "$dev_path/REVISION" 2>/dev/null)
35+
36+
revision=$1
37+
38+
if [[ ! "$revision" ]]; then
39+
echo -n "Checking latest Chromium version..."
40+
revision=$(curl -s "$url_base/LAST_CHANGE")
41+
if [[ "$revision" =~ ^[0-9]+$ ]]; then
42+
echo "OK"
43+
else
44+
echo "ERROR"
45+
echo "Error loading revision data from $url_base/LAST_CHANGE, aborting update."
46+
exit 1
47+
fi
48+
fi
49+
50+
echo "Attempting to update Chromium to revision $revision."
51+
52+
if [[ "$revision" == "$current_revision" ]]; then
53+
if [[ "$1" ]]; then
54+
echo "Revision $revision is already installed!"
55+
else
56+
echo "Already up-to-date!"
57+
fi
58+
exit
59+
fi
60+
61+
echo
62+
63+
tmp="$(mktemp -d /tmp/chromiumer.XXXXX)"
64+
for f in "$app_file" "$dev_file"; do
65+
echo "Downloading $f."
66+
curl -fLo "$tmp/$f" --progress-bar "$url_base/$revision/$f"
67+
if [[ ! -f "$tmp/$f" ]]; then
68+
echo "Error downloading $f, aborting update."
69+
rm -rf "$tmp"
70+
exit 1
71+
fi
72+
done
73+
74+
echo -en "\nDeleting existing files..."
75+
rm -rf "$app_path/Chromium.app" "$dev_path"
76+
echo "OK"
77+
78+
echo -n "Creating new files..."
79+
mkdir -p "$dev_path"
80+
devtools_path="$dev_path/devtools"
81+
echo "$revision" > "$dev_path/REVISION"
82+
unzip -qo "$tmp/$dev_file" -d "$devtools_path"
83+
unzip -qo "$tmp/$app_file" -d "$tmp"
84+
echo "OK"
85+
86+
mv "$tmp/$(basename "$app_file" .zip)/Chromium.app" "$app_path/"
87+
88+
echo -n "Modifying Chromium bin file to use --debug-devtools-frontend..."
89+
bin_path="$app_path/Chromium.app/Contents/MacOS"
90+
bin_file="$bin_path/Chromium"
91+
mv "$bin_file" "$bin_path/Chromium-bin"
92+
93+
cat > "$bin_file" <<'BASH'
94+
#!/bin/bash
95+
bin=$(echo $0 | perl -pe 's/$/-bin/')
96+
devtools=~/.dotfiles/caches/chromium/devtools
97+
"$bin" --debug-devtools-frontend="$devtools"
98+
BASH
99+
chmod +x "$bin_file"
100+
echo "OK"
101+
102+
echo -n "Cleaning up..."
103+
rm -rf "$tmp"
104+
echo "OK"
105+
106+
additional=~/.dotfiles/conf/update_chromium_etc.sh
107+
if [[ -f "$additional" ]]; then
108+
echo -e "\nRunning update_chromium_etc.sh..."
109+
source "$additional"
110+
fi
111+
112+
echo -e "\nAll done!"

conf/update_chromium_etc.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# I use this (optional) file to make the font larger for presentations - Cowboy
2+
3+
echo -n "Modifying fonts..."
4+
css=$(cat <<'CSS'
5+
/* === Added on `date` === */
6+
7+
/* LARGER fonts in WebKit Inspector */
8+
9+
/* Yes, this is intentional (selector specificity, etc) */
10+
body[class*="platform-"][class*="platform-"] .monospace,
11+
body[class*="platform-"][class*="platform-"] .source-code,
12+
.console-group-messages .outline-disclosure,
13+
.console-group-messages .outline-disclosure ol {
14+
font-size: 20px !important;
15+
line-height: 1.15em !important;
16+
}
17+
18+
.styles-element-state-pane { margin-top: -53px !important; }
19+
.styles-element-state-pane.expanded { margin-top: 0 !important; }
20+
21+
.section .header::before { top: -5px !important; }
22+
.section {
23+
margin-top: 0.3em !important;
24+
margin-bottom: 0.5em !important;
25+
}
26+
CSS
27+
)
28+
29+
find "$devtools_path" \( -name devTools.css \) -exec bash -c "echo '$css' >> {}" \;
30+
echo "OK"

0 commit comments

Comments
 (0)