Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
104 lines (94 sloc) 3.4 KB
-- UpdateChromium.applescript
-- Chromium Updater
-- Created by Dom Barnes.
-- Copyright 2011. All rights reserved.
script UpdateChromium
property parent : class "NSObject"
property status_label : missing value
property build_label : missing value
property progress_bar : missing value
property latest : missing value
property curl_URL : missing value
property start_Button : missing value
property header_label : missing value
property curVer : missing value
property appPlist : missing value
property appPath : missing value
on updateChromium_(sender)
header_label's setStringValue_("Checking for newer version")
set curVer to 0
delay 1
set appPath to POSIX path of (path to applications folder) & ""
log appPath
set appPlist to appPath & "/Contents/Info.plist"
log appPlist
tell application "System Events"
set curVer to value of property list item "SCMRevision" of property list file appPlist
end tell
log "curentVersion: " & curVer
end try
set latest to do shell script "curl"
build_label's setStringValue_("Build: " & latest as text)
log "latestVersion: " & latest
set curVer to curVer as number
set latest to latest as number
if curVer is greater than or equal to latest then
status_label's setStringValue_("You already have the latest nightly build.")
header_label's setStringValue_("")
build_label's setStringValue_("")
start_Button's setEnabled_(false)
end if
start_Button's setEnabled_(false)
progress_bar's setUsesThreadedAnimation_(true)
progress_bar's setMinValue_(0)
delay 1
progress_bar's incrementBy_(5)
delay 1
progress_bar's incrementBy_(15)
--download latest build using build number in latest
header_label's setStringValue_("Updating. Please wait")
build_label's setStringValue_("Build: " & latest)
status_label's setStringValue_("Downloading nightly build..." as string)
delay 1
do shell script "mkdir ~/.tmp"
end try
set curl_URL to "curl -L" & latest & "/ -o ~/.tmp/"
do shell script curl_URL
progress_bar's incrementBy_(20)
--unpack and copy
status_label's setStringValue_("Extracting" as string)
delay 1
do shell script "unzip -o ~/.tmp/ -d ~/.tmp/"
progress_bar's incrementBy_(20)
--move existing Chromium and copy new
do shell script "cp -pR /Applications/ /Applications/"
do shell script "rm -R /Applications/"
end try
status_label's setStringValue_("Copying to /Applications" as string)
delay 1
do shell script "mkdir -p /Applications/"
do shell script "mkdir -p /Applications/"
do shell script "cp -pR ~/.tmp/chrome-mac/ /Applications/"
progress_bar's incrementBy_(20)
--Cleanup folders and files
status_label's setStringValue_("Cleaning up" as string)
delay 1
do shell script "rm -R ~/.tmp/chrome*"
progress_bar's incrementBy_(20)
delay 1
do shell script "rm -R /Applications/"
end try
status_label's setStringValue_("Finished!")
--do shell script "echo " & latest & " > .tmp/current_chromium"
end updateChromium_
on QuitUpdater_(sender)
end QuitUpdater_
end script