forked from koush/ROMManagerManifest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devices.rb
40 lines (34 loc) · 898 Bytes
/
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
require 'rubygems'
require 'json'
if ARGV[0] == nil then
puts "ruby devices.rb <device> <version>"
exit
end
key = ARGV[0]
if ARGV[1] == nil then
puts "ruby devices.rb <device> <version>"
exit
end
version = ARGV[1]
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
devices["devices"].push found_device
end
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
File.open("devices.js", "w").write(JSON.pretty_generate(devices))