-
Notifications
You must be signed in to change notification settings - Fork 77
/
checkdevice.rb
62 lines (51 loc) · 1.28 KB
/
checkdevice.rb
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
require 'rubygems'
require 'json'
if ARGV[0] == nil then
puts "ruby checkdeviceversion.rb <device> <version> <owner>"
exit 1
end
key = ARGV[0]
if ARGV[1] == nil then
puts "ruby checkdeviceversion.rb <device> <version> <owner>"
exit 1
end
if ARGV[2] == nil then
puts "no owner provided, bailing!"
puts "ruby checkdeviceversion.rb <device> <version> <owner>"
exit 1
end
owner = ARGV[2]
devices = JSON.parse(File.open(File.dirname(__FILE__) + "/devices.js").read)
found_device = nil
devices["devices"].each do |device|
if device["key"] == key then
found_device = device
end
end
if found_device == nil then
puts "device not found, adding"
if !devices['owners'][owner] then
puts "Owner not allowed to add. Just building."
exit 1
else
exit 0
end
end
if !devices['owners'][owner] && !(found_device['owners'] && found_device['owners'][owner])
puts "Owner not allowed to update device"
exit 1
end
touch_recovery = ENV['BOARD_TOUCH_RECOVERY'] != nil
if touch_recovery
puts "touch version: "
version = found_device['touch_version']
else
puts "version:"
version = found_device['version']
end
puts version
if version && ARGV[1] <= version
puts "version #{ARGV[1]} is outdated, not updating"
exit 1
end
puts "Updating ROMManagerManifest to #{ARGV[1]}."