#!/bin/bash # # Copyright (C) 2010-2011 Greg Methvin # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. APP_PATH=/Applications/Chromium.app URL_PREFIX='http://build.chromium.org/f/chromium/snapshots/Mac' TMPDIR="/tmp/chromium_updater_$$" LATEST=$(curl -s $URL_PREFIX/LATEST) INSTALLED=$(defaults read /Applications/Chromium.app/Contents/Info SVNRevision 2>/dev/null) if [[ $LATEST -eq $INSTALLED ]]; then echo "You have the latest version of Chromium ($LATEST)" exit 0 fi [[ -f $TMPDIR ]] || mkdir $TMPDIR || exit 1 # clean up on exit cleanup () { if [[ -e $TMPDIR ]]; then echo 'Removing temporary files'; rm -rf $TMPDIR; fi } trap cleanup EXIT echo "Retrieving the latest version ($LATEST)" curl -# "$URL_PREFIX/$LATEST/chrome-mac.zip" -o $TMPDIR/chrome-mac.zip if [[ -n $(ps x | grep '\bChromium\b') ]]; then echo -n "Chromium is running. Kill it? (y/n) [y] " read cankill if [[ -z $cankill || $cankill == y ]]; then killall -9 Chromium 2>/dev/null else echo "Chromium must be closed before updating" exit 1 fi fi echo "Unzipping" unzip -qq -o $TMPDIR/chrome-mac.zip -d $TMPDIR || exit 1 echo "Moving new version to /Applications" rm -rf $APP_PATH && mv -f $TMPDIR/chrome-mac/Chromium.app $APP_PATH || exit 1 cleanup echo "Chromium is up to date"