-
Notifications
You must be signed in to change notification settings - Fork 77
/
devices.rb
57 lines (49 loc) · 1.28 KB
/
devices.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
require 'rubygems'
require 'json'
if ENV['NO_UPLOAD'] != nil
puts "Bailing due to NO_UPLOAD env variable being set."
exit 0
end
if ARGV[0] == nil then
puts "ruby devices.rb <device> <version> <lunchcombo>"
exit
end
key = ARGV[0]
if ARGV[1] == nil then
puts "ruby devices.rb <device> <version> <lunchcombo>"
exit
end
version = ARGV[1]
if ARGV[2] == nil then
puts "ruby devices.rb <device> <version> <lunchcombo>"
exit
end
lunch = ARGV[2]
devices = JSON.parse(File.open("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
found_device = {}
found_device["key"] = key
found_device["init"] = "init." + key + ".rc"
found_device["name"] = key
found_device["legacy_versions"] = []
devices["devices"].push found_device
end
if ENV['BOARD_TOUCH_RECOVERY'] == nil then
if found_device["version"] != nil then
if found_device["legacy_versions"] == nil then
found_device["legacy_versions"] = []
end
found_device["legacy_versions"].push found_device["version"]
end
found_device["version"] = version
found_device['lunch'] = lunch
else
found_device["touch_version"] = version
end
File.open("devices.js", "w").write(JSON.pretty_generate(devices))