-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappend.rb
More file actions
60 lines (53 loc) · 1.89 KB
/
Copy pathappend.rb
File metadata and controls
60 lines (53 loc) · 1.89 KB
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
#!/usr/bin/env ruby
require 'fileutils'
require 'json'
require 'digest/sha2'
ASB_LEVEL = ARGV[0]
%w[a13 a13-tv a14 a14-tv a15 a16-qpr0 a16-qpr2 a16-tv].each do |variant|
%w[system vendor].each do |img|
%w[arm64 x86_64].each do |arch|
%w[GAPPS VANILLA MAINLINE].each do |type|
json_path = File.join(variant, img == 'system' ? 'system/lineage' : img, "waydroid_#{arch}/#{type}.json")
target_name = "#{variant.include?('tv') ? 'waydroid_tv' : 'waydroid'}_#{arch}"
lineage_ver = \
case variant
when /^a13/
'lineage-20.0'
when /^a14/
'lineage-21.0'
when /^a15/
'lineage-22.2'
when 'a16-qpr0'
'lineage-23.0'
when 'a16-qpr2'
'lineage-23.2'
when 'a16-tv'
'lineage-23.{0,2}'
end
if File.exist?(json_path)
json = JSON.load_file(json_path, symbolize_names: true)
else
FileUtils.mkdir_p(File.dirname(json_path))
json = { response: [] }
end
Dir["#{lineage_ver}-*-#{type}-#{target_name}-#{img}.zip"].each do |zip|
stat = File.stat(zip)
json[:response].delete_if { |e| e[:filename] == zip }
json[:response] << {
datetime: stat.mtime.to_i,
filename: zip,
id: Digest::SHA256.file(zip),
romtype: type,
asb: ASB_LEVEL,
size: stat.size,
url: "https://sourceforge.net/projects/waydroid-atv/files/images/#{img}/#{target_name}/#{zip}/download",
version: zip[/^lineage-(\d+\.\d+)/, 1]
}
end
next if json[:response].empty?
json[:response].sort_by! { |e| - e[:datetime] }
File.write(json_path, JSON.pretty_generate(json) + "\n")
end
end
end
end