six-arma-builder 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'rake/testtask'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = 'six-arma-builder'
15
- s.version = '0.1.6'
15
+ s.version = '0.1.7'
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ['README', 'LICENSE']
18
18
  s.summary = 'Your summary here'
@@ -58,7 +58,33 @@ module Six
58
58
  when :addons
59
59
  new = Hash.new
60
60
  new[:type] = change.type
61
- change.path[/\A(#{path[:folder]})\/(\w*)\/?(.*)/]
61
+ change.path[/\A(#{path[:folder]})\/([\w_\.]*)\/?(.*)/]
62
+ new[:base], new[:folder], new[:file] = $1, $2, $3
63
+ path = "#{new[:base]}/#{new[:folder]}"
64
+ unless stat[:changed].include?(path)
65
+ #log.info "#{change.typ} #{change.path}"
66
+ case new[:type]
67
+ when 'deleted'
68
+ if FileTest.exist?(File.join(@config[:source], path))
69
+ new[:type] = 'modified'
70
+ end
71
+ #when 'modified'
72
+ when 'new'
73
+ # if already existed, it was not added but modified, dont matter actually
74
+ new[:type] = 'modified'
75
+ end
76
+
77
+ case new[:type]
78
+ when 'deleted'
79
+ stat[:deleted] << path unless stat[:deleted].include?(path)
80
+ when 'modified'
81
+ stat[:changed] << path
82
+ end
83
+ end
84
+ when :store
85
+ new = Hash.new
86
+ new[:type] = change.type
87
+ change.path[/\A(#{path[:folder]})\/([\w_\.]*)\/?(.*)/]
62
88
  new[:base], new[:folder], new[:file] = $1, $2, $3
63
89
  path = "#{new[:base]}/#{new[:folder]}"
64
90
  unless stat[:changed].include?(path)
@@ -97,15 +123,15 @@ module Six
97
123
  end
98
124
 
99
125
  # Prepare file diffs
100
- @source.diff(@config[:revision][:previous],@config[:revision][:current]).each do |diff|
101
- @config[:paths].each_with_index do |path,index|
126
+ @source.diff(@config[:revision][:previous], @config[:revision][:current]).each do |diff|
127
+ @config[:paths].each_with_index do |path, index|
102
128
  process_change(diff, path, @stats[index])#, 'Addons')
103
129
  end
104
130
  end
105
131
 
106
132
  # Process file and comment history
107
133
  history = @source.log(LOG_LIMIT)
108
- @config[:paths].each_with_index do |path,index|
134
+ @config[:paths].each_with_index do |path, index|
109
135
  # Process Stats
110
136
  stat = @stats[index]
111
137
  stat[:changed].sort!
@@ -172,7 +198,7 @@ module Six
172
198
  def process_files
173
199
  puts
174
200
  log.info "Processing Files ..."
175
- @config[:paths].each_with_index do |path,index|
201
+ @config[:paths].each_with_index do |path, index|
176
202
  puts
177
203
  log.info "Path: #{path[:folder]}"
178
204
  stat = @stats[index]
@@ -184,6 +210,8 @@ module Six
184
210
  #sign_changed_addons(path, stat)
185
211
  # TODO: Make choice
186
212
  #sign_all_addons(path, stat, true)
213
+ when :store
214
+ process_changed_files(path, stat)
187
215
  end
188
216
  end
189
217
  end
@@ -191,7 +219,7 @@ module Six
191
219
  def sign_files
192
220
  puts
193
221
  #log.info "Signing ..."
194
- @config[:paths].each_with_index do |path,index|
222
+ @config[:paths].each_with_index do |path, index|
195
223
  puts
196
224
  log.info "Path: #{path[:folder]}"
197
225
  stat = @stats[index]
@@ -249,7 +277,7 @@ module Six
249
277
  end
250
278
  stat[:changed].each do |change|
251
279
  log.info "Building #{change}"
252
- file = File.join(@config[:source],change)
280
+ file = File.join(@config[:source], change)
253
281
  fol_path = File.join(@config[:destination], path[:folder])
254
282
  obj = Six::Arma::Tools::Pbo.new(file, fol_path)
255
283
  overriden = false
@@ -280,6 +308,46 @@ module Six
280
308
  end
281
309
  end
282
310
 
311
+ def process_changed_files(path, stat)
312
+ des_path = File.join(@config[:destination], path[:folder])
313
+ src_path = File.join(@config[:source], path[:folder])
314
+
315
+ FileUtils.mkdir_p des_path unless File.exists?(des_path)
316
+
317
+ stat[:deleted].each do |change|
318
+ log.info "Deleting #{change}"
319
+ change[/(.*)\/(.*)/]
320
+ folder, file = $1, $2
321
+ ppath = File.join(src_path, folder)
322
+ unless File.exists? ppath
323
+ # TODO: Add PREFIX_ instead of * ?
324
+ FileUtils.rm_f File.join(@config[:destination], path[:folder], "#{folder}.tar")
325
+ end
326
+ end
327
+
328
+ stat[:changed].each do |change|
329
+ log.info "Building #{change}"
330
+ file = File.join(@config[:source], change)
331
+ # TODO: Also for adodn folders!
332
+ change[/(.*)\/(.*)/]
333
+ f = $2
334
+
335
+ if !File.directory?(file)
336
+ FileUtils.cp(file, des_path) # TODO: apply proper file date
337
+ @destination_changed = true
338
+ else
339
+ if File.exists?(File.join(file, "$IGNORE$"))
340
+ else
341
+ Dir.chdir src_path do
342
+ o = %x[tar -c #{f} > #{f}.tar]
343
+ FileUtils.mv(File.join(src_path, "#{f}.tar"), des_path)
344
+ end
345
+ @destination_changed = true
346
+ end
347
+ end
348
+ end
349
+ end
350
+
283
351
  # FIXME: !!
284
352
  def sign_changed_addons(path, stat)
285
353
  if @destination_changed
@@ -315,34 +383,34 @@ module Six
315
383
  def sign_all_addons(path, stat, force = false)
316
384
  if @destination_changed || force
317
385
  if stat[:changed].size > 0
318
- if @config[:key]
319
- else
320
- key = "#{@config[:name]}_b#{@build}"
321
- d = "C:/projects/keys"
322
- unless File.exists?(File.join(d, "#{key}.biprivatekey"))
323
- Dir.chdir d
324
- system "C:/tools/dsutils/dsCreateKey #{key}"
386
+ if @config[:key]
387
+ else
388
+ key = "#{@config[:name]}_b#{@build}"
389
+ d = "C:/projects/keys"
390
+ unless File.exists?(File.join(d, "#{key}.biprivatekey"))
391
+ Dir.chdir d
392
+ system "C:/tools/dsutils/dsCreateKey #{key}"
393
+ end
394
+ Dir[File.join(@config[:destination], "keys", '*.bikey')].each do |f|
395
+ FileUtils.rm_f(f)
396
+ end
397
+ FileUtils.cp(File.join(d, "#{key}.bikey"), File.join(@config[:destination], "keys", "#{key}.bikey"))
325
398
  end
326
- Dir[File.join(@config[:destination], "keys", '*.bikey')].each do |f|
327
- FileUtils.rm_f(f)
399
+ puts
400
+ log.info "Signing All..."
401
+ destination = File.join(@config[:destination], path[:folder])
402
+ Dir.chdir destination
403
+ Dir[File.join(destination, "*.bisign")].each do |f|
404
+ FileUtils::rm_f f
328
405
  end
329
- FileUtils.cp(File.join(d, "#{key}.bikey"), File.join(@config[:destination], "keys", "#{key}.bikey"))
330
- end
331
- puts
332
- log.info "Signing All..."
333
- destination = File.join(@config[:destination], path[:folder])
334
- Dir.chdir destination
335
- Dir[File.join(destination, "*.bisign")].each do |f|
336
- FileUtils::rm_f f
337
- end
338
- Dir['*.pbo'].each do |pbo|
339
- log.info "Signing #{pbo}"
340
- file = File.join(@config[:destination], path[:folder], pbo)
341
- obj = Six::Arma::Tools::Pbo.new(file, File.join(@config[:destination], path[:folder]))
342
- obj.sign({:key => File.join(d, "#{key}.biprivatekey")})
343
- end
344
- @destination_changed = true
406
+ Dir['*.pbo'].each do |pbo|
407
+ log.info "Signing #{pbo}"
408
+ file = File.join(@config[:destination], path[:folder], pbo)
409
+ obj = Six::Arma::Tools::Pbo.new(file, File.join(@config[:destination], path[:folder]))
410
+ obj.sign({:key => File.join(d, "#{key}.biprivatekey")})
345
411
  end
412
+ @destination_changed = true
413
+ end
346
414
  end
347
415
  end
348
416
 
@@ -351,7 +419,7 @@ module Six
351
419
  puts
352
420
  log.info "Writing Changelog..."
353
421
  msgs = ["h2. #{Time.now}\n\nBuild #{@build}\nUpdated to source:@#{@config[:revision][:current]}"]
354
- @config[:paths].each_with_index do |path,index|
422
+ @config[:paths].each_with_index do |path, index|
355
423
  stat = @stats[index]
356
424
  #msgs << "Path: #{path[:folder]}"
357
425
  #msgs += stat[:changelog]
@@ -4,11 +4,11 @@ require 'six/arma/builder/options'
4
4
  module Six
5
5
  module Arma
6
6
  module Builder
7
- TEST = false #true
7
+ TEST = false #false #true
8
8
  #parse_options
9
9
  initialize
10
10
  @config[:mods].each do |config|
11
- if true #['six'].include? config[:name]
11
+ if true #['ace', 'six'].include? config[:name]
12
12
  mod = Mod.new(config)
13
13
  # TODO: First reset the package repositories ?
14
14
  mod.process_diffs
@@ -18,7 +18,7 @@ require 'six/arma/builder/mod'
18
18
  module Six
19
19
  module Arma
20
20
  module Builder
21
- VERSION = '0.1.6'
21
+ VERSION = '0.1.7'
22
22
  COMPONENT = 'six-arma-builder'
23
23
  BASE_PATH = Dir.pwd
24
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: six-arma-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sickboy