six-updater 0.19.3-x86-mingw32 → 0.19.4-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ require 'rake/testtask'
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.platform = "x86-mingw32"
15
15
  s.name = 'six-updater'
16
- s.version = '0.19.3'
16
+ s.version = '0.19.4'
17
17
  s.has_rdoc = true
18
18
  s.extra_rdoc_files = ['README', 'LICENSE']
19
19
  s.summary = 'Your summary here'
@@ -35,7 +35,7 @@ end
35
35
  spec3 = Gem::Specification.new do |s|
36
36
  s.platform = "x86-mswin32"
37
37
  s.name = 'six-updater'
38
- s.version = '0.19.3'
38
+ s.version = '0.19.4'
39
39
  s.has_rdoc = true
40
40
  s.extra_rdoc_files = ['README', 'LICENSE']
41
41
  s.summary = 'Your summary here'
@@ -56,7 +56,7 @@ end
56
56
 
57
57
  spec2 = Gem::Specification.new do |s|
58
58
  s.name = 'six-updater'
59
- s.version = '0.19.3'
59
+ s.version = '0.19.4'
60
60
  s.has_rdoc = true
61
61
  s.extra_rdoc_files = ['README', 'LICENSE']
62
62
  s.summary = 'Your summary here'
data/lib/six/cleanup.rb CHANGED
@@ -8,13 +8,13 @@ require 'yaml'
8
8
  module Six
9
9
  class Cleanup
10
10
  def self.md5sum(target)
11
- target[/(.*)\/(.*)/]
12
- folder, file = $1, $2
11
+ folder, file = File.dirname(target), File.basename(target)
13
12
  r = Dir.chdir(folder) do
14
13
  %x[md5sum "#{file}"]
15
14
  end
16
15
  r[/\A\w*/]
17
16
  end
17
+
18
18
  def self.check_dir(dir, repack = false)
19
19
  if File.directory?(dir)
20
20
  entry = File.join(dir, ".repository.yml")
@@ -31,10 +31,10 @@ module Six
31
31
  f = e[0].clone
32
32
  f.sub!(/\.gz$/, "")
33
33
 
34
- target = if f[/(.*)\/(.*)/]
35
- "#{$1}/#{$2.downcase}"
36
- else
34
+ target = if File.dirname(f) == "."
37
35
  f.downcase
36
+ else
37
+ "#{File.dirname(f)}/#{File.basename(f).downcase}"
38
38
  end
39
39
  rename(f, target)
40
40
  system "gzip --rsyncable --best \"#{target}\""
data/lib/six/updater.rb CHANGED
@@ -39,10 +39,9 @@ end
39
39
  module Six
40
40
  # TODO: Evaluate if this module should be a class instead?
41
41
  module Updater
42
- VERSION = '0.19.3'
42
+ VERSION = '0.19.4'
43
43
  COMPONENT = 'six-updater'
44
44
  LOG_LIMIT = 9999
45
- FOLDER = /(.*)\/(.*)/
46
45
 
47
46
  # Configuration
48
47
  case RUBY_PLATFORM
@@ -223,7 +222,14 @@ module Six
223
222
  exit
224
223
  end
225
224
 
226
- File.open(config) { |file| @config.merge!(YAML::load(file)) }
225
+ cfg = YAML::load_file(config)
226
+ unless cfg
227
+ log.error "ERROR: #{config} seems to be invalid!"
228
+ wait if @config[:wait]
229
+ exit
230
+ end
231
+
232
+ @config.merge!(cfg)
227
233
  @config[:folders] = [] unless @config[:folders]
228
234
  @config[:server][:folders] = [] unless @config[:server][:folders]
229
235
 
@@ -392,11 +398,7 @@ module Six
392
398
  end
393
399
 
394
400
  def process_name
395
- if @config[:app_exe][FOLDER]
396
- $2
397
- else
398
- @config[:app_exe]
399
- end
401
+ @process_name ||= File.basename(@config[:app_exe])
400
402
  end
401
403
 
402
404
  def sure?
@@ -420,7 +422,6 @@ module Six
420
422
 
421
423
  def startgame(cmd = nil)
422
424
  log.info "Starting the game with #{@config[:app_params]} -mod=#{@mods}#{cmd}"
423
- #system "\"#{@config[:app_exe]}\" #{@config[:app_params]} -mod=#{@mods}"
424
425
  case RUBY_PLATFORM
425
426
  when /-mingw32$/, /-mswin32$/
426
427
  begin
@@ -467,7 +468,7 @@ module Six
467
468
  log.info "Created shortcut (in #{path}): #{name}"
468
469
  Dir.chdir cwd
469
470
  else
470
- log.warn "Unsupported on current Platform: #{RUBY_PLATFORM}"
471
+ log.warn "Unsupported on current Platform: #{RUBY_PLATFORM}"
471
472
  end
472
473
  end
473
474
 
@@ -488,7 +489,7 @@ module Six
488
489
  log.warn "WARNING: Problem while creating shortcut! ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
489
490
  end
490
491
  else
491
- log.warn "Unsupported on current Platform: #{RUBY_PLATFORM}"
492
+ log.warn "Unsupported on current Platform: #{RUBY_PLATFORM}"
492
493
  end
493
494
  end
494
495
 
@@ -66,20 +66,12 @@ module Six
66
66
  end
67
67
 
68
68
  def get_repositories
69
- cfg = File.join(@path, '.repositories.yml')
70
- @repositories = if FileTest.exist?(cfg)
71
- File.open(cfg) { |file| YAML::load(file) }
72
- elsif @modconfig[:repository].class == Array
73
- @modconfig[:repository]
74
- else
75
- [@modconfig[:repository]]
76
- end
69
+ @repositories ||= @modconfig[:repository].is_a?(Array) ? @modconfig[:repository] : [@modconfig[:repository]]
77
70
  end
78
71
 
79
72
  def write_version
80
- @modconfig[:versionfile][/(.*)\/(.*)/]
81
- folder = $1
82
- FileUtils.mkdir_p folder unless FileTest.exists? folder
73
+ folder = File.dirname(@modconfig[:versionfile])
74
+ FileUtils.mkdir_p folder unless File.exists? folder
83
75
  begin
84
76
  File.open(@modconfig[:versionfile], 'w') { |file| file.puts @stat[:current] }
85
77
  true
@@ -120,7 +112,7 @@ module Six
120
112
 
121
113
  # UPDATE Process
122
114
  def update
123
- if self.skip?
115
+ if self.skip?
124
116
  begin
125
117
  userconfig(false)
126
118
  rescue => e
@@ -132,7 +124,7 @@ module Six
132
124
  return if self.disabled?
133
125
  end
134
126
 
135
- return unless self.installed?
127
+ return unless self.installed?
136
128
 
137
129
  @stat[:previous] = @repository.version
138
130
  log.info "Current Version: #{@stat[:previous]}, checking for updates..."
@@ -148,7 +140,7 @@ module Six
148
140
  end
149
141
 
150
142
  if @stat[:previous] == @stat[:current]
151
- log.info "No updates found"
143
+ log.info "No updates found (Current version: #{@stat[:current]})"
152
144
  write_version # DO this always incase previous version.txt failed for whatever reason!
153
145
  else
154
146
  log.info "Applied version: #{@stat[:current]}"
@@ -184,76 +176,79 @@ module Six
184
176
  if self.installed?
185
177
  log.info "Already installed, trying to update..."
186
178
  update
187
- else
188
- if FileTest.exist?(@path)
189
- log.warn "WARNING: Folder already exists but seems incompatible. Not installing."
190
- log.info "If you want the software to install this mod, please delete the modfolder"
191
- else
192
- log.info "Installing... This might take a while, please wait."
193
- folder = ''
194
- if @modconfig[:folder][/(.*)\/(.*)/]
195
- basepath, subfolder = $1, $2
196
- basepath = File.join(@config[:app_modpath], basepath)
197
- FileUtils.mkdir_p basepath unless FileTest.exist?(basepath)
198
- end
179
+ return
180
+ end
181
+ if File.exists?(@path)
182
+ log.warn "WARNING: Folder already exists but seems incompatible. Not installing."
183
+ log.info "If you want the software to install this mod, please delete the modfolder"
184
+ return
185
+ end
186
+ log.info "Installing... This might take a while, please wait."
187
+ unless File.dirname(@modconfig[:folder]) == "."
188
+ basepath, subfolder = File.dirname(@modconfig[:folder]), File.basename(@modconfig[:folder])
189
+ basepath = File.join(@config[:app_modpath], basepath)
190
+ FileUtils.mkdir_p basepath unless File.exists?(basepath)
191
+ end
199
192
 
200
- file = File.join(DATA_PATH, "#{@folder_str}.7z")
201
- file = File.join(BASE_PATH, "#{@folder_str}.7z") unless File.exists?(file)
202
- if File.exists?(file)
203
- log.info "Found #{@folder_str}.7z, using it"
204
- #Six::Updater.zipcheck
205
- FileUtils.mkdir_p @path
206
- log.debug unpack(file, @path)
207
-
208
- if File.exists?(File.join(@path, ".rsync", "config.yml"))
209
- begin
210
- @repository = RsyncRepo.new(@modconfig[:repository], @path, :log => log)
211
- @installed = true
212
- get_repositories
213
- update
214
- rescue => e
215
- @installed = false
216
- FileUtils::rm_rf(@path) if FileTest.exist?(@path)
217
- end
218
- else
219
- log.warn "WARNING: Failed to open the repository, the #{@folder_str}.7z does not seem to be correct"
220
- log.warn "Installing from rsync network instead"
221
- log.debug "#{$!}"
222
- FileUtils::rm_rf(@path) if FileTest.exist?(@path)
223
- end
193
+ file = File.join(DATA_PATH, "#{@folder_str}.7z")
194
+ file = File.join(BASE_PATH, "#{@folder_str}.7z") unless File.exists?(file)
195
+ if File.exists?(file)
196
+ log.info "Found #{@folder_str}.7z, using it"
197
+ #Six::Updater.zipcheck
198
+ FileUtils.mkdir_p @path
199
+ log.debug unpack(file, @path)
200
+
201
+ if File.exists?(File.join(@path, ".rsync", "config.yml"))
202
+ begin
203
+ @repository = RsyncRepo.new(@modconfig[:repository], @path, :log => log)
204
+ @installed = true
205
+ get_repositories
206
+ update
207
+ rescue => e
208
+ @installed = false
209
+ #FileUtils::rm_rf(@path) if File.exists?(@path)
224
210
  end
211
+ else
212
+ log.warn "WARNING: Failed to open the repository, the #{@folder_str}.7z does not seem to be correct"
213
+ log.warn "Installing from rsync network instead"
214
+ log.debug "#{$!}"
215
+ FileUtils::rm_rf(@path) if File.exists?(@path)
216
+ end
217
+ end
225
218
 
226
- unless @installed
227
- @repository = RsyncRepo.new(@repositories, @path)
228
- opts = {}
229
- opts.merge!({:log => log}) if @config[:verbose]
230
- @installed = @repository.clone(opts)
231
- unless @installed
232
- log.warn "WARNING: Failed to download the repository! This could be due to a server / connection problem. Please try again later"
233
- end
234
- end
219
+ unless @installed
220
+ @repository = RsyncRepo.new(@repositories, @path)
221
+ opts = {}
222
+ opts.merge!({:log => log}) if @config[:verbose]
223
+ begin
224
+ @repository.clone(opts)
225
+ @installed = true
226
+ rescue => e
227
+ log.warn "WARNING: Failed to download the repository! This could be due to a server / connection problem. Please try again later"
228
+ log.debug "#{e.class}: #{e.message} #{e.backtrace.join("\n")}"
229
+ end
230
+ end
235
231
 
236
- if @installed
237
- @changed = true
238
- @stat[:previous] = nil
239
- begin
240
- @stat[:current] = @repository.version
241
- write_version
242
- rescue => e
243
- log.warn 'WARNING: Post installation was unable to complete. This could be due to a server / connection problem. Please try again later'
244
- log.debug "ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
245
- FileUtils::rm_rf(@path) if FileTest.exist?(@path)
246
- end
247
- begin
248
- userconfig
249
- rescue => e
250
- log.warn 'WARNING: Userconfig processing is unable to complete.'
251
- log.debug "ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
252
- end
253
- else
254
- FileUtils::rm_rf(@path) if FileTest.exist?(@path)
255
- end
232
+ if @installed
233
+ @changed = true
234
+ @stat[:previous] = nil
235
+ begin
236
+ @stat[:current] = @repository.version
237
+ log.info "Current version: #{@stat[:current]}"
238
+ write_version
239
+ rescue => e
240
+ log.warn 'WARNING: Post installation was unable to complete. This could be due to a server / connection problem. Please try again later'
241
+ log.debug "ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
242
+ #FileUtils::rm_rf(@path) if File.exists?(@path)
256
243
  end
244
+ begin
245
+ userconfig
246
+ rescue => e
247
+ log.warn 'WARNING: Userconfig processing is unable to complete.'
248
+ log.debug "ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
249
+ end
250
+ else
251
+ # FileUtils::rm_rf(@path) if File.exists?(@path)
257
252
  end
258
253
  end
259
254
 
@@ -281,7 +276,7 @@ module Six
281
276
  def uninstall
282
277
  return if self.disabled?
283
278
 
284
- if FileTest.exist?(@path)
279
+ if File.exists?(@path)
285
280
  log.warn "###########"
286
281
  log.warn "# WARNING #"
287
282
  log.warn "###########"
@@ -295,19 +290,18 @@ module Six
295
290
 
296
291
  # Process keys
297
292
  def keys(force = true)
298
- return if self.disabled?
293
+ return if self.disabled?
299
294
  return unless self.installed?
300
295
 
301
296
  path = File.join(@path, 'store', 'keys.tar')
302
297
  path = File.join(@path, 'store', 'keys') unless File.exists?(path)
303
- path = File.join(@path, 'keys') unless File.directory?(path)
298
+ path = File.join(@path, 'keys') unless File.directory?(path)
304
299
  if File.exists?(path)
305
300
  log.info "Found keys, processing..."
306
301
  k_path = File.join(@config[:app_path], 'keys')
307
302
  if File.directory? path
308
303
  Dir[File.join(path, '*.bikey')].each do |key|
309
- key[/(.*)\/(.*)/]
310
- path, file = $1, $2
304
+ path, file = File.dirname(key), File.basename(key)
311
305
  file[/(.*)_(.*)\.bikey/]
312
306
  prefix, suffix = $1, $2
313
307
  if suffix && prefix
@@ -337,11 +331,11 @@ module Six
337
331
  f.gsub!('@', '')
338
332
  path = File.join(@path, 'store', 'userconfig.tar')
339
333
  path = File.join(@path, 'store', 'userconfig') unless File.exists?(path)
340
- path = File.join(@path, 'userconfig') unless File.exists?(path)
334
+ path = File.join(@path, 'userconfig') unless File.exists?(path)
341
335
  if File.exists?(path)
342
336
  uconfig = File.join(@config[:app_path], 'userconfig')
343
337
  uconfigpath = File.join(uconfig, f)
344
- if !force && FileTest.exist?(uconfigpath)
338
+ if !force && File.exists?(uconfigpath)
345
339
  log.debug "Userconfig folder already found, skipping"
346
340
  return
347
341
  end
@@ -16,11 +16,8 @@ module Six
16
16
 
17
17
  def version
18
18
  f = File.join(@path, '.rsync', '.repository.yml')
19
- if FileTest.exist?(f)
20
- File.open(f) {|file| YAML::load(file)[:version] }
21
- else
22
- nil
23
- end
19
+ cfg = File.exists?(f) ? YAML::load_file(f) : nil
20
+ cfg ? cfg[:version] : nil
24
21
  end
25
22
 
26
23
  def open(opts = {})
@@ -41,32 +38,21 @@ module Six
41
38
 
42
39
  def clone(opts = {})
43
40
  done = false
44
- @path[/(.*)\/(.*)/]
45
- opts = {:path => $1, :depth => @depth, :log => log}
46
- #begin
47
- @repository = Rsync.clone(@repositories, $2, opts)
48
- # FIXME: Update needs to be fixed
49
- done = true
50
- # rescue
51
- # log.warn "WARNING: Failed, was unable to clone!" unless done
52
- #log.debug "WARNING: Failed, trying other mirrors if available"
53
- # end
54
- done
41
+ opts = {:path => File.dirname(@path), :depth => @depth, :log => log}
42
+ @repository = Rsync.clone(@repositories, File.basename(@path), opts)
43
+ true
55
44
  end
56
45
 
57
46
  def update(opts = {})
58
- cfg = nil
59
- File.open(File.join(@path, '.rsync/config.yml')) { |file| cfg = YAML::load(file) }
47
+ # Update the config file with our hosts list
48
+ file = File.join(@path, '.rsync/config.yml')
49
+ cfg = YAML::load_file(file)
60
50
  cfg[:hosts] = @repositories
61
- File.open(File.join(@path, '.rsync/config.yml'), 'w') { |file| file.puts cfg.to_yaml }
51
+ File.open(file, 'w') { |file| file.puts cfg.to_yaml }
62
52
 
63
- # begin
53
+ # Update!
64
54
  repository.update
65
- done = true
66
- # rescue
67
- # log.warn "WARNING: Failed, was unable to update!" unless done
68
- # end
69
- done
55
+ true
70
56
  end
71
57
  end
72
58
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 19
8
- - 3
9
- version: 0.19.3
8
+ - 4
9
+ version: 0.19.4
10
10
  platform: x86-mingw32
11
11
  authors:
12
12
  - Sickboy
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-01 00:00:00 +02:00
17
+ date: 2010-05-08 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency