-
Notifications
You must be signed in to change notification settings - Fork 5
/
UpdateChromium.applescript
104 lines (94 loc) · 3.4 KB
/
UpdateChromium.applescript
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
-- UpdateChromium.applescript
-- Chromium Updater
-- Created by Dom Barnes.
-- Copyright 2011. All rights reserved.
script UpdateChromium
property parent : class "NSObject"
--Outlets
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
--Actions
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) & "Chromium.app"
log appPath
set appPlist to appPath & "/Contents/Info.plist"
log appPlist
try
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 http://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/LAST_CHANGE"
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)
return
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
try
do shell script "mkdir ~/.tmp"
end try
set curl_URL to "curl -L http://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/" & latest & "/chrome-mac.zip -o ~/.tmp/chrome-mac.zip"
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/chrome-mac.zip -d ~/.tmp/"
progress_bar's incrementBy_(20)
--move existing Chromium and copy new
try
do shell script "cp -pR /Applications/Chromium.app /Applications/Chromium.old.app"
do shell script "rm -R /Applications/Chromium.app"
end try
status_label's setStringValue_("Copying to /Applications" as string)
delay 1
do shell script "mkdir -p /Applications/Chromium.app"
do shell script "mkdir -p /Applications/Chromium.app/Contents"
do shell script "cp -pR ~/.tmp/chrome-mac/Chromium.app/Contents /Applications/Chromium.app"
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
try
do shell script "rm -R /Applications/Chromium.old.app"
end try
status_label's setStringValue_("Finished!")
--do shell script "echo " & latest & " > .tmp/current_chromium"
end updateChromium_
on QuitUpdater_(sender)
quit
end QuitUpdater_
end script