forked from koush/ROMManagerManifest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmerger.rb
53 lines (44 loc) · 1.37 KB
/
merger.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
require 'rubygems'
require 'json'
require 'open-uri'
data = File.open('manual_manifests.js').read
parsed_data = JSON.parse(data)
manifests = parsed_data['manifests']
romshare_manifests = JSON.parse(open('http://romshare.deployfu.com/manifest').read)
threads = []
for manifest in romshare_manifests['manifests']:
manifest['free'] = false
manifests << manifest
end
File.open('manifests.js', 'w').write(JSON.pretty_generate(parsed_data))
device_manifests = {}
devices = JSON.parse(open('devices.js').read)
for device in devices['devices']:
device = device['key']
device_manifest = {}
device_manifest['minversion'] = parsed_data['minversion']
device_manifest['manifests'] = []
device_manifests[device] = device_manifest
end
for manifest in manifests:
for device in manifest['roms'].keys:
if device == 'all' then
for device_manifest in device_manifests.values:
device_manifest['manifests'] << manifest
end
else
device_manifest = device_manifests[device]
if device_manifest == nil
puts "Missing device: " + device
next
end
device_manifest['manifests'] << manifest
end
end
manifest.delete 'roms'
end
for device in device_manifests.keys:
device_manifest = device_manifests[device]
device_file = 'manifest/' + device + ".js"
File.open(device_file, 'w').write(JSON.pretty_generate(device_manifest))
end