sixarma-bt 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,140 @@
1
+ module SixArma
2
+ module Bt
3
+ class Builder
4
+ private
5
+ # Writes svn changelists
6
+ # cfg:: Mod Config Object
7
+ # cfg2:: Mod Stats Object
8
+ def svn_write_list(cfg, cfg2)
9
+ SixCore::info "Writing SVN Changelog..."
10
+ cfg.subfolders.each_with_index do |folder,idx|
11
+ folder2 = cfg2.subfolders[idx]
12
+ case folder.type
13
+ when "addons"
14
+ t = folder2.add + folder2.change
15
+ t.uniq!
16
+ t.sort!
17
+ binfiles = File.open("#{cfg.lists}/#{@config.listbin}_#{folder.name}.txt") { |file|
18
+ file.readlines.map { |line| SixCore::clean(line) }
19
+ }
20
+ pbofiles = File.open("#{cfg.lists}/#{@config.listpbo}_#{folder.name}.txt") { |file|
21
+ file.readlines.map { |line| SixCore::clean(line) }
22
+ }
23
+ thirdparty_pbo = File.open("#{cfg.lists}/#{@config.list3rd_pbo}_#{folder.name}.txt") { |file|
24
+ file.readlines.map { |line| SixCore::clean(line) }
25
+ }
26
+ tmp = []
27
+ File.open("#{cfg.changes}/#{@config.work3rd_pbo}_#{folder.name}.txt", "w") do |f|
28
+ f.flush
29
+ t.each do |addon|
30
+ if thirdparty_pbo.include?(addon)
31
+ f.puts(addon)
32
+ tmp << addon
33
+ end
34
+ end
35
+ t = t - tmp
36
+ end
37
+
38
+ tmp = []
39
+ File.open("#{cfg.changes}/#{@config.workbin}_#{folder.name}.txt", "w") do |f|
40
+ f.flush
41
+ t.each do |addon|
42
+ if binfiles.include?(addon)
43
+ f.puts(addon)
44
+ tmp << addon
45
+ end
46
+ end
47
+ t = t - tmp
48
+ end
49
+
50
+ tmp = []
51
+ File.open("#{cfg.changes}/#{@config.workpbo}_#{folder.name}.txt", "w") do |f|
52
+ f.flush
53
+ t.each do |addon|
54
+ if pbofiles.include?(addon)
55
+ f.puts(addon)
56
+ tmp << addon
57
+ end
58
+ end
59
+ t = t - tmp
60
+ end
61
+
62
+ if t.size > 0
63
+ SixCore::info "ABORT: Changed but not found in lists: #{t}"
64
+ Process.exit
65
+ end
66
+
67
+ File.open("#{cfg.changes}/#{@config.workdel}_#{folder.name}.txt", "w") do |f|
68
+ f.flush
69
+ folder2.del.each do |addon| f.puts(addon) end
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ # Generates svn changelists
76
+ # cfg:: Mod Config Object
77
+ # cfg2:: Mod Stats Object
78
+ def svn_generate(cfg, cfg2)
79
+ SixCore::info "Generating SVN Changelog..."
80
+ svn = SixCore::Svn.new("#{cfg.path}#{cfg.source}", cfg.svn.user, cfg.svn.pass)
81
+
82
+ svn.diff(cfg2.oldrev, cfg2.newrev).each do |entry|
83
+ # only want to process folders under the given folder
84
+ cfg.subfolders.each_with_index do |f, idx|
85
+ entrymod = entry.gsub("#{svn.repos}\\#{f.name}\\", "")
86
+ if entrymod != entry
87
+ f2 = cfg2.subfolders[idx]
88
+ if f.type == "addons"
89
+ folders = true
90
+ else
91
+ folders = false
92
+ end
93
+ parsed = svn.parse_entry(entrymod, folders)
94
+ case parsed[0]
95
+ when 0
96
+ f2.add << parsed[1]
97
+ when 1
98
+ f2.change << parsed[1]
99
+ when 2
100
+ f2.del << parsed[1]
101
+ end
102
+ end
103
+ end
104
+
105
+ # clean and sort arrays
106
+ cfg2.subfolders.each do |f|
107
+ f.add.uniq!
108
+ f.add.sort!
109
+ f.change.uniq!
110
+ f.change.sort!
111
+ f.del.uniq!
112
+ f.del.sort!
113
+ end
114
+ end
115
+ end
116
+
117
+ public
118
+ # Meta method, runs generate and write_list for every mod
119
+ def svn_do()
120
+ @config.mods.each_with_index do |mod,idx|
121
+ SixCore::infos("SVN Sync - #{mod.destination}", COMPONENT)
122
+ # Clean arrays
123
+ @stats.mods[idx].subfolders.each do |f|
124
+ f.add = []
125
+ f.del = []
126
+ f.change = []
127
+ end
128
+ # TODO: Proper this lame stuff
129
+ if idx == 0
130
+ @stats.mods[idx].subfolders[0].change << @config.veraddon unless @stats.mods[idx].subfolders[0].change.include?(@config.veraddon)
131
+ end
132
+ svn_generate(mod, @stats.mods[idx])
133
+ svn_write_list(mod, @stats.mods[idx])
134
+ end
135
+ write_stats()
136
+ SixCore::halt() if @halt
137
+ end
138
+ end
139
+ end
140
+ end