six-updater 0.11.6 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/lib/six/updater-app.rb +24 -21
  3. data/lib/six/updater.rb +164 -162
  4. metadata +2 -2
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-updater'
15
- s.version = '0.11.6'
15
+ s.version = '0.12.1'
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ['README', 'LICENSE']
18
18
  s.summary = 'Your summary here'
@@ -17,13 +17,13 @@ module Six
17
17
  found = false
18
18
  out.split("\n").each do |line|
19
19
  line[/\Aruby\.exe[\t| ]*([0-9]*)/]
20
- p = $1
21
- if p
22
- if p.size > 0
23
- pid = pid.to_i
24
- found = true if pid == p.to_i
25
- end
20
+ p = $1
21
+ if p
22
+ if p.size > 0
23
+ pid = pid.to_i
24
+ found = true if pid == p.to_i
26
25
  end
26
+ end
27
27
  #end
28
28
  end
29
29
  if found
@@ -42,25 +42,28 @@ module Six
42
42
  mods = []
43
43
  puts
44
44
  log.info "Processing:"
45
- @config[:folders].each do |config|
46
- # TODO: Only display message when there are actually todo's
47
- puts
48
- log.info "= #{config[:folder]}"
49
- mod = Mod.new(config, @config)
50
- mods << mod
51
- @todo.each { |t| mod.send t }
52
- #mod.install
45
+ @config[:folders].each_with_index do |config, index|
46
+ unless config[:skip] || config[:disabled]
47
+ # TODO: Only display message when there are actually todo's
48
+ puts
49
+ log.info "= #{config[:folder]}"
50
+ mod = Mod.new(config, @config)
51
+ mods[index] = mod
52
+ @todo.each { |t| mod.send t }
53
+ end
53
54
  end
54
55
 
55
56
  puts
56
57
  log.info "Postprocessing:"
57
- @config[:folders].each_with_index do |config,index|
58
- mod = mods[index]
59
- if mod.changed || @config[:force]
60
- # TODO: Only display message when there are actually todo's
61
- puts
62
- log.info "= #{config[:folder]}"
63
- @second_todo.each { |t| mod.send t }
58
+ @config[:folders].each_with_index do |config, index|
59
+ unless config[:skip] || config[:disabled]
60
+ mod = mods[index]
61
+ if mod.changed || @config[:force]
62
+ # TODO: Only display message when there are actually todo's
63
+ puts
64
+ log.info "= #{config[:folder]}"
65
+ @second_todo.each { |t| mod.send t }
66
+ end
64
67
  end
65
68
  end
66
69
 
@@ -1,4 +1,4 @@
1
- # encoding: UTF-8
1
+ # encoding: UTF-8
2
2
 
3
3
  require 'yaml'
4
4
  require 'fileutils'
@@ -44,7 +44,7 @@ end
44
44
  module Six
45
45
  # TODO: Evaluate if this module should be a class instead?
46
46
  module Updater
47
- VERSION = '0.11.6'
47
+ VERSION = '0.12.1'
48
48
  COMPONENT = 'six-updater'
49
49
 
50
50
  # Configuration
@@ -141,6 +141,168 @@ module Six
141
141
  end
142
142
 
143
143
  module_function
144
+ def initialize
145
+ # Banner
146
+ log.info "Updater (v#{VERSION}) by Sickboy <sb_at_dev-heaven.net>"
147
+ log.info 'Run with --help for help'
148
+ log.warn "WARNING: Please make sure anything ArmA related has been closed / shutdown, incl explorer windows, etc"
149
+ log.debug "BASE_PATH: #{BASE_PATH}"
150
+ log.debug "TOOL_PATH: #{TOOL_PATH}"
151
+ log.debug "@config #{@config}"
152
+
153
+ # Process the config file
154
+ config = "#{COMPONENT}.yml"
155
+ config = File.join(BASE_PATH, config)
156
+ if ARGV[0]
157
+ # FIXME: This is not a very good catch..
158
+ if ARGV[0][/.*\..*/]
159
+ if FileTest.exist?(ARGV[0])
160
+ config = ARGV[0]
161
+ else
162
+ log.warn "#{ARGV[0]} not found, trying #{config}"
163
+ end
164
+ end
165
+ end
166
+
167
+ unless FileTest.exist?(config)
168
+ log.error "ERROR: #{config} config missing!"
169
+ wait
170
+ exit
171
+ end
172
+
173
+ File.open(config) { |file| @config.merge!(YAML::load(file)) }
174
+ @config[:folders] = [] unless @config[:folders]
175
+ @config[:server][:folders] = [] unless @config[:server][:folders]
176
+
177
+ # Parses CLI Parameters, merges configuration and gets todo list
178
+ parse_options
179
+
180
+ # Backwards compatibility
181
+ @config[:app_path] = @config[:armapath] if @config[:armapath]
182
+ @config[:app_exe] = @config[:armaexe] if @config[:armaexe]
183
+ @config[:app_params] = @config[:armaparams] if @config[:armaparams]
184
+ @config[:git_path] = @config[:gitpath] if @config[:gitpath]
185
+ @config[:server_path] = @config[:serverpath] if @config[:serverpath]
186
+
187
+ # Determine arma distribution and location
188
+ unless @config[:app_path]
189
+ begin
190
+ @config[:app_path] = Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, ARMA2_STEAM[0])[ARMA2_STEAM[1]]
191
+ log.info "ArmA 2 Steam Distribution detected"
192
+ rescue
193
+ begin
194
+ @config[:app_path] = Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, ARMA2_ALT[0])[ARMA2_ALT[1]]
195
+ log.info "ArmA 2 Alt Distribution detected"
196
+ rescue
197
+ begin
198
+ @config[:app_path] = Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, ARMA2[0])[ARMA2[1]]
199
+ log.info "ArmA 2 Standard Distribution detected"
200
+ rescue
201
+ log.warn "No (known) ArmA 2 Distribution detected"
202
+ end
203
+ end
204
+ end
205
+ end
206
+
207
+ # Verify installation folder
208
+ if @config[:app_path]
209
+ log.info "Installation Path: #{@config[:app_path]}"
210
+ if FileTest.exists?(@config[:app_path])
211
+ @config[:app_path].gsub!('\\', '/')
212
+ else
213
+ log.error "No valid installation folder found, please abort!"
214
+ wait
215
+ exit
216
+ end
217
+ else
218
+ log.error "No valid installation folder found, please abort!"
219
+ wait
220
+ exit
221
+ end
222
+
223
+ # Nasty workaround for cygwin on Vista vs XP, vs acl's
224
+ =begin
225
+ @config[:app_path][/\A(\w\:)/]
226
+ str = "#{$1}/ /six-app-root ntfs noacl 0 0"
227
+ etc = File.join(TOOL_PATH, 'etc')
228
+ FileUtils.mkdir_p etc
229
+ File.open(File.join(etc, 'fstab'), 'w') { |file| file.puts str }
230
+ ENV['six-app-root'] = '/six-app-root'
231
+ =end
232
+ puts
233
+ if @config[:server][:repository]
234
+ log.info "Checking for latest updates of #{@config[:server][:name]} server info"
235
+ path = File.join(@config[:server_path], @config[:server][:name])
236
+
237
+ opts = {}
238
+ opts.merge!({:log => log}) if @config[:verbose]
239
+
240
+ case @config[:server][:repository][0]
241
+ when /\Agit:\/\//
242
+ repo = GitRepo.new(@config[:server][:repository], path)
243
+ when /\Arsync:\/\//
244
+ repo = RsyncRepo.new(@config[:server][:repository], path)
245
+ end
246
+
247
+ if FileTest.exist?(File.join(path, '.git')) || FileTest.exist?(File.join(path, '.rsync'))
248
+ repo.reset(:hard => true)
249
+ repo.update
250
+ else
251
+ #FileUtils::mkdir_p path
252
+ repo.clone
253
+ end
254
+
255
+ begin
256
+ srv = File.join(path, 'server.yml')
257
+ File.open(srv) do |f|
258
+ cfg = YAML::load(f)
259
+ @config[:folders].each do |f|
260
+ cfg[:folders].each do |f2|
261
+ @config[:folders] -= [f] if f2[:folder] == f[:folder]
262
+ end
263
+ end
264
+ @config[:folders] = cfg[:folders] + @config[:folders]
265
+ @config[:server] = cfg.merge @config[:server]
266
+ end
267
+ rescue
268
+ log.warn "WARNING: Server configured but unable to get data from repository"
269
+ log.debug "#{$!}"
270
+ end
271
+ end
272
+
273
+ @config[:folders].uniq!
274
+ log.debug "@config #{@config}"
275
+
276
+ # PreProcess the config data
277
+ @mods = []
278
+ @mods << @config[:mods] if @config[:mods]
279
+
280
+ @config[:folders].each do |folder|
281
+ unless folder[:disabled]
282
+ folder[:folder].gsub!('\\', '/')
283
+ if folder[:mods]
284
+ @mods << folder[:mods]
285
+ else
286
+ @mods << folder[:folder]
287
+ end
288
+ end
289
+ end
290
+ @mods = @mods.join(';')
291
+
292
+ # Output processed config data
293
+ log.info "Manager for: #{@mods}"
294
+
295
+
296
+ # Prepare stats
297
+ @stats = []
298
+ @config[:folders].each do |folder|
299
+ stat = Hash.new
300
+ @stats << stat
301
+ path = File.join(@config[:app_path], folder[:folder])
302
+ stat[:changelog] = []
303
+ end
304
+ end
305
+
144
306
  def log
145
307
  @@log
146
308
  end
@@ -308,166 +470,6 @@ module Six
308
470
  require 'git'
309
471
  end
310
472
  end
311
-
312
- def initialize
313
- # Banner
314
- log.info "Updater (v#{VERSION}) by Sickboy <sb_at_dev-heaven.net>"
315
- log.info 'Run with --help for help'
316
- log.warn "WARNING: Please make sure anything ArmA related has been closed / shutdown, incl explorer windows, etc"
317
- log.debug "BASE_PATH: #{BASE_PATH}"
318
- log.debug "TOOL_PATH: #{TOOL_PATH}"
319
- log.debug "@config #{@config}"
320
-
321
- # Process the config file
322
- config = "#{COMPONENT}.yml"
323
- config = File.join(BASE_PATH, config)
324
- if ARGV[0]
325
- # FIXME: This is not a very good catch..
326
- if ARGV[0][/.*\..*/]
327
- if FileTest.exist?(ARGV[0])
328
- config = ARGV[0]
329
- else
330
- log.warn "#{ARGV[0]} not found, trying #{config}"
331
- end
332
- end
333
- end
334
-
335
- unless FileTest.exist?(config)
336
- log.error "ERROR: #{config} config missing!"
337
- wait
338
- exit
339
- end
340
-
341
- File.open(config) { |file| @config.merge!(YAML::load(file)) }
342
- @config[:folders] = [] unless @config[:folders]
343
- @config[:server][:folders] = [] unless @config[:server][:folders]
344
-
345
- # Parses CLI Parameters, merges configuration and gets todo list
346
- parse_options
347
-
348
- # Backwards compatibility
349
- @config[:app_path] = @config[:armapath] if @config[:armapath]
350
- @config[:app_exe] = @config[:armaexe] if @config[:armaexe]
351
- @config[:app_params] = @config[:armaparams] if @config[:armaparams]
352
- @config[:git_path] = @config[:gitpath] if @config[:gitpath]
353
- @config[:server_path] = @config[:serverpath] if @config[:serverpath]
354
-
355
- # Determine arma distribution and location
356
- unless @config[:app_path]
357
- begin
358
- @config[:app_path] = Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, ARMA2_STEAM[0])[ARMA2_STEAM[1]]
359
- log.info "ArmA 2 Steam Distribution detected"
360
- rescue
361
- begin
362
- @config[:app_path] = Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, ARMA2_ALT[0])[ARMA2_ALT[1]]
363
- log.info "ArmA 2 Alt Distribution detected"
364
- rescue
365
- begin
366
- @config[:app_path] = Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, ARMA2[0])[ARMA2[1]]
367
- log.info "ArmA 2 Standard Distribution detected"
368
- rescue
369
- log.warn "No (known) ArmA 2 Distribution detected"
370
- end
371
- end
372
- end
373
- end
374
-
375
- # Verify installation folder
376
- if @config[:app_path]
377
- log.info "Installation Path: #{@config[:app_path]}"
378
- if FileTest.exists?(@config[:app_path])
379
- @config[:app_path].gsub!('\\', '/')
380
- else
381
- log.error "No valid installation folder found, please abort!"
382
- wait
383
- exit
384
- end
385
- else
386
- log.error "No valid installation folder found, please abort!"
387
- wait
388
- exit
389
- end
390
-
391
- # Nasty workaround for cygwin on Vista vs XP, vs acl's
392
- =begin
393
- @config[:app_path][/\A(\w\:)/]
394
- str = "#{$1}/ /six-app-root ntfs noacl 0 0"
395
- etc = File.join(TOOL_PATH, 'etc')
396
- FileUtils.mkdir_p etc
397
- File.open(File.join(etc, 'fstab'), 'w') { |file| file.puts str }
398
- ENV['six-app-root'] = '/six-app-root'
399
- =end
400
- puts
401
- if @config[:server][:repository]
402
- log.info "Checking for latest updates of #{@config[:server][:name]} server info"
403
- path = File.join(@config[:server_path], @config[:server][:name])
404
-
405
- opts = {}
406
- opts.merge!({:log => log}) if @config[:verbose]
407
-
408
- case @config[:server][:repository][0]
409
- when /\Agit:\/\//
410
- repo = GitRepo.new(@config[:server][:repository], path)
411
- when /\Arsync:\/\//
412
- repo = RsyncRepo.new(@config[:server][:repository], path)
413
- end
414
-
415
- if FileTest.exist?(File.join(path, '.git')) || FileTest.exist?(File.join(path, '.rsync'))
416
- repo.reset(:hard => true)
417
- repo.update
418
- else
419
- #FileUtils::mkdir_p path
420
- repo.clone
421
- end
422
-
423
- begin
424
- srv = File.join(path, 'server.yml')
425
- File.open(srv) do |f|
426
- cfg = YAML::load(f)
427
- @config[:folders].each do |f|
428
- cfg[:folders].each do |f2|
429
- @config[:folders] -= [f] if f2[:folder] == f[:folder]
430
- end
431
- end
432
- @config[:folders] = cfg[:folders] + @config[:folders]
433
- @config[:server] = cfg.merge @config[:server]
434
- end
435
- rescue
436
- log.warn "WARNING: Server configured but unable to get data from repository"
437
- log.debug "#{$!}"
438
- end
439
- end
440
-
441
- @config[:folders].uniq!
442
- log.debug "@config #{@config}"
443
-
444
- # PreProcess the config data
445
- @mods = []
446
- @mods << @config[:mods] if @config[:mods]
447
-
448
- @config[:folders].each do |folder|
449
- folder[:folder].gsub!('\\', '/')
450
- if folder[:mods]
451
- @mods << folder[:mods]
452
- else
453
- @mods << folder[:folder]
454
- end
455
- end
456
- @mods = @mods.join(';')
457
-
458
- # Output processed config data
459
- log.info "Manager for: #{@mods}"
460
-
461
-
462
- # Prepare stats
463
- @stats = []
464
- @config[:folders].each do |folder|
465
- stat = Hash.new
466
- @stats << stat
467
- path = File.join(@config[:app_path], folder[:folder])
468
- stat[:changelog] = []
469
- end
470
- end
471
473
  end
472
474
  end
473
475
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: six-updater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.6
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sickboy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-13 00:00:00 +01:00
12
+ date: 2009-12-15 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency