jpignata (owner)

Fork Of

gist: 228538 by rtomayko Fetch and install the lates...

Revisions

gist: 228912 Download_button fork
public
Public Clone URL: git://gist.github.com/228912.git
Embed All Files: show embed
nightly-chromium #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
# Fetch and install the latest Chromium mac nightly build, but only
# if it's different from the currently installed version. An existing
# Chromium.app is backed up to .Chromium.app in the same directory.
#
# Install with:
# $ curl -L http://bit.ly/night-chrome > ~/bin/nightly-chromium
# $ chmod +x ~/bin/nightly-chromium
#
# To upgrade to latest chromium version:
# $ nightly-chromium
#
# With cron, use this to get email only when an upgrade happens:
# nightly-chromium 2> /dev/null
#
set -e
 
build_url="http://build.chromium.org/buildbot/snapshots/chromium-rel-mac"
install_dir="/Applications/Chromium.app"
 
# determine the currently installed chromium build number
current=0
test -d "$install_dir" && current=$(
    cat "$install_dir/Contents/Info.plist" |
    grep -A1 "<key>SVNRevision</key>" |
    tail -n 1 |
    sed 's/.*<string>\(.*\)<\/string>.*/\1/'
)
 
# most recent version build available from google
latest=$(curl -s "$build_url/LATEST")
if [ "$current" != "$latest" ]; then
echo "==> Fetching Chromium build $latest" 1>&2
 
    # setup a temp dir to do some work
    tmpdir="/tmp/$(basename $0)-$latest"
    trap "cd / && rm -rf $tmpdir" EXIT
    mkdir -p "$tmpdir"
    cd "$tmpdir"
 
    # fetch it
    curl -O "$build_url/$latest/chrome-mac.zip"
 
    printf "\n==> Extracting ...\n" 1>&2
    unzip -q chrome-mac.zip
 
    # remove the previous backup
    backup_dir="$(dirname $install_dir)/.$(basename $install_dir)"
    rm -rf "$backup_dir"
 
    # backup the currently installed Chromium.app
    test -d "$install_dir" &&
    mv "$install_dir" "$backup_dir"
 
    # move the new one into place
    mv "chrome-mac/Chromium.app" "$install_dir"
    echo "==> Chromium upgraded to build $latest (from $current)."
else
echo "==> You already have build $latest." 1>&2
fi