six-updater 0.17.1-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +674 -0
- data/README +3 -0
- data/Rakefile +80 -0
- data/bin/six-updater +17 -0
- data/lib/six/updater-app.rb +91 -0
- data/lib/six/updater.rb +440 -0
- data/lib/six/updater/gitrepo.rb +112 -0
- data/lib/six/updater/mod.rb +348 -0
- data/lib/six/updater/options.rb +126 -0
- data/lib/six/updater/rsyncrepo.rb +73 -0
- metadata +155 -0
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
#
|
2
|
+
# To change this template, choose Tools | Templates
|
3
|
+
# and open the template in the editor.
|
4
|
+
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'rake'
|
8
|
+
require 'rake/clean'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
require 'rake/testtask'
|
12
|
+
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
s.platform = "i386-mingw32"
|
15
|
+
s.name = 'six-updater'
|
16
|
+
s.version = '0.17.1'
|
17
|
+
s.has_rdoc = true
|
18
|
+
s.extra_rdoc_files = ['README', 'LICENSE']
|
19
|
+
s.summary = 'Your summary here'
|
20
|
+
s.description = s.summary
|
21
|
+
s.author = 'Sickboy'
|
22
|
+
s.email = 'sb@dev-heaven.net'
|
23
|
+
s.add_dependency('win32-api', '= 1.4.6')
|
24
|
+
s.add_dependency('win32-process', '>= 0.6.0')
|
25
|
+
s.add_dependency('win32-shortcut', '>= 0.2.3')
|
26
|
+
s.add_dependency('log4r', '>= 1.1.2')
|
27
|
+
s.add_dependency('six-uac', '>= 0.1.0')
|
28
|
+
s.add_dependency('six-rsync', '>= 0.3.4')
|
29
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,spec}/**/*") + Dir.glob("lib/*/**/*.rb")
|
30
|
+
s.require_path = "lib"
|
31
|
+
s.bindir = "bin"
|
32
|
+
s.executables = ['six-updater']
|
33
|
+
end
|
34
|
+
|
35
|
+
spec2 = Gem::Specification.new do |s|
|
36
|
+
s.name = 'six-updater'
|
37
|
+
s.version = '0.17.1'
|
38
|
+
s.has_rdoc = true
|
39
|
+
s.extra_rdoc_files = ['README', 'LICENSE']
|
40
|
+
s.summary = 'Your summary here'
|
41
|
+
s.description = s.summary
|
42
|
+
s.author = 'Sickboy'
|
43
|
+
s.email = 'sb@dev-heaven.net'
|
44
|
+
#s.add_dependency('win32-api', '= 1.4.6')
|
45
|
+
#s.add_dependency('win32-process', '>= 0.6.0')
|
46
|
+
#s.add_dependency('win32-shortcut', '>= 0.2.3')
|
47
|
+
s.add_dependency('log4r', '>= 1.1.2')
|
48
|
+
#s.add_dependency('six-uac', '>= 0.1.0')
|
49
|
+
s.add_dependency('six-rsync', '>= 0.3.4')
|
50
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,spec}/**/*") + Dir.glob("lib/*/**/*.rb")
|
51
|
+
s.require_path = "lib"
|
52
|
+
s.bindir = "bin"
|
53
|
+
s.executables = ['six-updater']
|
54
|
+
end
|
55
|
+
|
56
|
+
Rake::GemPackageTask.new(spec) do |p|
|
57
|
+
p.gem_spec = spec
|
58
|
+
p.need_tar = true
|
59
|
+
p.need_zip = true
|
60
|
+
end
|
61
|
+
|
62
|
+
Rake::GemPackageTask.new(spec2) do |p|
|
63
|
+
p.gem_spec = spec2
|
64
|
+
p.need_tar = true
|
65
|
+
p.need_zip = true
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
Rake::RDocTask.new do |rdoc|
|
70
|
+
files =['README', 'LICENSE', 'lib/**/*.rb']
|
71
|
+
rdoc.rdoc_files.add(files)
|
72
|
+
rdoc.main = "README" # page to start on
|
73
|
+
rdoc.title = "six-arma-updater Docs"
|
74
|
+
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
|
75
|
+
rdoc.options << '--line-numbers'
|
76
|
+
end
|
77
|
+
|
78
|
+
Rake::TestTask.new do |t|
|
79
|
+
t.test_files = FileList['test/**/*.rb']
|
80
|
+
end
|
data/bin/six-updater
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
begin
|
5
|
+
load 'six/updater-app.rb'
|
6
|
+
rescue => e
|
7
|
+
puts e.class, e.message, e.backtrace.join("\n")
|
8
|
+
begin
|
9
|
+
require 'fileutils'
|
10
|
+
path = File.join(Six::Updater::DATA_PATH, 'logs')
|
11
|
+
FileUtils.mkdir_p path unless File.exists?(path)
|
12
|
+
File.open(File.join(path, "six-updater-error.log"), 'w') {|f| f.puts e.class, e.message, e.backtrace.join("\n")}
|
13
|
+
rescue
|
14
|
+
puts "ERROR: #{$!}"
|
15
|
+
end
|
16
|
+
sleep 10
|
17
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'six/updater/options'
|
2
|
+
require 'six/updater'
|
3
|
+
|
4
|
+
# TODO: Should exec outside the module
|
5
|
+
module Six
|
6
|
+
module Updater
|
7
|
+
PID_FILE = File.join(DATA_PATH, "#{COMPONENT}.pid")
|
8
|
+
if not defined?(Ocra)
|
9
|
+
#Signal.trap("EXIT") { exit_app }
|
10
|
+
#Signal.trap("INT") { exit_app }
|
11
|
+
#Signal.trap("TERM") { exit_app }
|
12
|
+
#Signal.trap("KILL") { exit_app }
|
13
|
+
|
14
|
+
if File.exist?(PID_FILE)
|
15
|
+
pid = File.open(PID_FILE) {|file| file.read}
|
16
|
+
pid = pid.to_i
|
17
|
+
found = false
|
18
|
+
begin
|
19
|
+
out = %x[tasklist]
|
20
|
+
out.split("\n").each do |line|
|
21
|
+
line[/\Aruby\.exe[\t| ]*([0-9]*)/]
|
22
|
+
p = $1
|
23
|
+
if p
|
24
|
+
if p.size > 0
|
25
|
+
found = true if pid == p.to_i
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
rescue
|
30
|
+
log.warn "Failed checking tasklist for #{pid}"
|
31
|
+
log.debug "#{$!}"
|
32
|
+
end
|
33
|
+
if found
|
34
|
+
log.error "The program seems to be already running (PID: #{pid}). Please wait/close the other application first."
|
35
|
+
log.info "If you believe this is in error, please delete #{PID_FILE}"
|
36
|
+
log.info "If the file doesn't exist, you are probably NOT running this software 'As Administrator'"
|
37
|
+
sleep 15
|
38
|
+
Process.exit
|
39
|
+
else
|
40
|
+
FileUtils.rm_f PID_FILE
|
41
|
+
end
|
42
|
+
end
|
43
|
+
File.open(PID_FILE, 'w') {|f| f.puts Process.pid}
|
44
|
+
|
45
|
+
initialize
|
46
|
+
mods = []
|
47
|
+
puts
|
48
|
+
log.info "Processing:"
|
49
|
+
@config[:folders].each_with_index do |config, index|
|
50
|
+
#unless config[:skip] || config[:disabled]
|
51
|
+
# TODO: Only display message when there are actually todo's
|
52
|
+
puts
|
53
|
+
log.info "= #{config[:folder]}"
|
54
|
+
mod = Mod.new(config, @config)
|
55
|
+
mods[index] = mod
|
56
|
+
@todo.each { |t| mod.send t }
|
57
|
+
# end
|
58
|
+
end
|
59
|
+
|
60
|
+
puts
|
61
|
+
log.info "Postprocessing:"
|
62
|
+
@config[:folders].each_with_index do |config, index|
|
63
|
+
# unless config[:skip] || config[:disabled]
|
64
|
+
mod = mods[index]
|
65
|
+
if mod.changed || @config[:force]
|
66
|
+
# TODO: Only display message when there are actually todo's
|
67
|
+
puts
|
68
|
+
log.info "= #{config[:folder]}"
|
69
|
+
@second_todo.each { |t| mod.send t }
|
70
|
+
end
|
71
|
+
# end
|
72
|
+
end
|
73
|
+
|
74
|
+
puts
|
75
|
+
log.info "Processing general tasks:"
|
76
|
+
@general_todo.each { |t| Six::Updater.send t }
|
77
|
+
|
78
|
+
puts
|
79
|
+
log.info "Ready!"
|
80
|
+
beta_msg
|
81
|
+
|
82
|
+
FileUtils.rm_f PID_FILE if File.exist?(PID_FILE)
|
83
|
+
|
84
|
+
if @config[:wait]
|
85
|
+
puts
|
86
|
+
log.info "Please press ENTER to exit"
|
87
|
+
STDIN.gets
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/lib/six/updater.rb
ADDED
@@ -0,0 +1,440 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
gem 'log4r', '>= 1.1.2'
|
7
|
+
require 'log4r'
|
8
|
+
require 'digest/md5'
|
9
|
+
|
10
|
+
case RUBY_PLATFORM
|
11
|
+
when /-mingw32$/, /-mswin32$/
|
12
|
+
gem 'win32-api', '= 1.4.6'
|
13
|
+
gem 'win32-shortcut'
|
14
|
+
require 'win32/shortcut'
|
15
|
+
gem 'win32-process'
|
16
|
+
require 'win32/process'
|
17
|
+
require 'win32/registry'
|
18
|
+
end
|
19
|
+
|
20
|
+
gem 'six-rsync'
|
21
|
+
require 'six/rsync'
|
22
|
+
|
23
|
+
require 'six/updater/mod'
|
24
|
+
#require 'sixupdater/gitrepo'
|
25
|
+
require 'six/updater/rsyncrepo'
|
26
|
+
|
27
|
+
include Six::Repositories
|
28
|
+
|
29
|
+
case RUBY_VERSION
|
30
|
+
when /1\.8\.[0-9]/
|
31
|
+
class Array
|
32
|
+
def sample
|
33
|
+
self[rand self.size]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Six
|
39
|
+
# TODO: Evaluate if this module should be a class instead?
|
40
|
+
module Updater
|
41
|
+
VERSION = '0.17.1'
|
42
|
+
COMPONENT = 'six-updater'
|
43
|
+
LOG_LIMIT = 9999
|
44
|
+
|
45
|
+
# Configuration
|
46
|
+
case RUBY_PLATFORM
|
47
|
+
when /-mingw32$/, /-mswin32$/
|
48
|
+
ARMA2 = ['SOFTWARE\\Bohemia Interactive Studio\\ArmA 2', 'MAIN']
|
49
|
+
ARMA2_ALT = ['SOFTWARE\\Bohemia Interactive\\ArmA 2', 'InstallPath']
|
50
|
+
ARMA2_STEAM = ['SOFTWARE\\Valve\\Steam\\Common\\ARMA 2', 'InstallPath']
|
51
|
+
DESKTOP = ['Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders', 'Desktop']
|
52
|
+
end
|
53
|
+
|
54
|
+
# Fix for WinXP
|
55
|
+
BASE_PATH = if defined?(TAR2RUBYSCRIPT)
|
56
|
+
if oldlocation
|
57
|
+
oldlocation
|
58
|
+
else
|
59
|
+
Dir.pwd
|
60
|
+
end
|
61
|
+
else
|
62
|
+
p = Dir.pwd
|
63
|
+
p.gsub!('\\', '/')
|
64
|
+
p
|
65
|
+
end
|
66
|
+
TOOL_PATH = File.join(BASE_PATH, 'tools')
|
67
|
+
|
68
|
+
case RUBY_PLATFORM
|
69
|
+
when /-mingw32$/, /-mswin32$/
|
70
|
+
TEMP_PATH = if ENV['TEMP']
|
71
|
+
if ENV['TEMP'].size > 0
|
72
|
+
File.directory?(ENV['TEMP']) ? ENV['TEMP'] : BASE_PATH
|
73
|
+
else
|
74
|
+
BASE_PATH
|
75
|
+
end
|
76
|
+
else
|
77
|
+
BASE_PATH
|
78
|
+
end
|
79
|
+
HOME_PATH = File.exists?(File.join(ENV['APPDATA'])) ? File.join(ENV['APPDATA']) : TEMP_PATH
|
80
|
+
bpath = BASE_PATH.clone
|
81
|
+
bpath.gsub!('/', '\\')
|
82
|
+
tpath = "#{File.join(bpath, 'tools')};#{File.join(bpath, 'tools', 'bin')}"
|
83
|
+
tpath.gsub!('/', '\\')
|
84
|
+
ENV['PATH'] = "#{bpath};#{tpath};#{ENV['PATH']}"
|
85
|
+
else
|
86
|
+
HOME_PATH = '~/'
|
87
|
+
TEMP_PATH = '/tmp'
|
88
|
+
end
|
89
|
+
DATA_PATH = File.join(HOME_PATH, COMPONENT)
|
90
|
+
|
91
|
+
=begin
|
92
|
+
dpath = BASE_PATH
|
93
|
+
unless File.exists?(File.join(BASE_PATH, "legacy.txt"))
|
94
|
+
reg_path = nil
|
95
|
+
#case RUBY_VERSION
|
96
|
+
#when /1\.8\.[0-9]/
|
97
|
+
# begin
|
98
|
+
# reg_path = Win32::Registry::HKEY_CURRENT_USER.open("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders")['AppData']
|
99
|
+
# rescue
|
100
|
+
# end
|
101
|
+
#end
|
102
|
+
if reg_path
|
103
|
+
if reg_path.size > 0
|
104
|
+
dpath = File.join(reg_path, 'Six-Updater') if File.directory?(reg_path)
|
105
|
+
end
|
106
|
+
elsif ENV['APPDATA']
|
107
|
+
if ENV['APPDATA'].size > 0
|
108
|
+
dpath = File.join(ENV['APPDATA'], 'Six-Updater') if File.directory?(ENV['APPDATA'])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
DATA_PATH = dpath
|
113
|
+
=end
|
114
|
+
|
115
|
+
lf = File.join(DATA_PATH, "logs")
|
116
|
+
FileUtils.mkdir_p(lf) unless File.directory?(lf)
|
117
|
+
|
118
|
+
cf = File.join(DATA_PATH, "#{COMPONENT}.yml")
|
119
|
+
unless File.exists?(cf)
|
120
|
+
cfo = File.join(BASE_PATH, "#{COMPONENT}.yml")
|
121
|
+
FileUtils.cp(cfo, cf) if File.exists?(cfo)
|
122
|
+
begin
|
123
|
+
FileUtils.rm_f(cfo) if File.exists?(cfo)
|
124
|
+
rescue
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
@general_todo, @second_todo = [], []
|
129
|
+
|
130
|
+
# Create config hash with default settings
|
131
|
+
@config = Hash.new
|
132
|
+
@config[:app_params] = '-noSplash -noFilePatching -showScriptErrors'
|
133
|
+
@config[:app_exe] = 'arma2.exe'
|
134
|
+
@config[:depth] = 1
|
135
|
+
@config[:folders] = []
|
136
|
+
@config[:server] = Hash.new
|
137
|
+
@config[:verbose] = false
|
138
|
+
|
139
|
+
# FIXME: Solve this properly!
|
140
|
+
@config[:defaultactions] = [:install]
|
141
|
+
@config[:defaultgeneralactions] = [:createshortcut]
|
142
|
+
@config[:defaultsecondactions] = [:changelog, :cleanup]
|
143
|
+
|
144
|
+
# Create loggers
|
145
|
+
@@log = Log4r::Logger.new(COMPONENT)
|
146
|
+
format1 = if defined?(DEBUG)
|
147
|
+
Log4r::PatternFormatter.new(:pattern => "[%l] %d: %m", :date_pattern => '%H:%M:%S')
|
148
|
+
else
|
149
|
+
Log4r::PatternFormatter.new(:pattern => "%m")
|
150
|
+
end
|
151
|
+
format2 = Log4r::PatternFormatter.new(:pattern => "[%l] %c %d: %m", :date_pattern => '%H:%M:%S')
|
152
|
+
|
153
|
+
|
154
|
+
if not defined?(Ocra)
|
155
|
+
# Create Outputters
|
156
|
+
path = File.join(DATA_PATH, 'logs')
|
157
|
+
FileUtils::mkdir_p path
|
158
|
+
o_file = Log4r::FileOutputter.new "#{COMPONENT}-file",
|
159
|
+
'level' => 0, # All
|
160
|
+
:filename => File.join(path, "#{COMPONENT}.log"),
|
161
|
+
'formatter' => format2
|
162
|
+
#:maxsize => 1024
|
163
|
+
|
164
|
+
@@log.outputters << o_file
|
165
|
+
|
166
|
+
o_out = Log4r::StdoutOutputter.new "#{COMPONENT}-stdout",
|
167
|
+
'level' => 2, # no DEBUG
|
168
|
+
'formatter' => format1
|
169
|
+
|
170
|
+
o_err = Log4r::StderrOutputter.new "#{COMPONENT}-stderr",
|
171
|
+
'level' => 4, # Error and Up
|
172
|
+
'formatter' => format1
|
173
|
+
|
174
|
+
@@log.outputters << o_out << o_err
|
175
|
+
end
|
176
|
+
|
177
|
+
module_function
|
178
|
+
def initialize
|
179
|
+
# Banner
|
180
|
+
log.info "Updater (v#{VERSION}) by Sickboy <sb_at_dev-heaven.net>"
|
181
|
+
log.info 'Run with --help for help'
|
182
|
+
log.warn "WARNING: Please make sure anything ArmA related has been closed / shutdown, incl explorer windows, etc"
|
183
|
+
log.debug "BASE_PATH: #{BASE_PATH}"
|
184
|
+
log.debug "TOOL_PATH: #{TOOL_PATH}"
|
185
|
+
log.debug "@config #{@config}"
|
186
|
+
|
187
|
+
# Process the config file
|
188
|
+
config = "#{COMPONENT}.yml"
|
189
|
+
config = File.join(DATA_PATH, config)
|
190
|
+
if ARGV[0]
|
191
|
+
# FIXME: This is not a very good catch..
|
192
|
+
if ARGV[0][/.*\..*/]
|
193
|
+
if File.exists?(ARGV[0])
|
194
|
+
config = ARGV[0]
|
195
|
+
else
|
196
|
+
log.warn "#{ARGV[0]} not found, trying #{config}"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
unless File.exists?(config)
|
202
|
+
log.error "ERROR: #{config} config missing!"
|
203
|
+
wait
|
204
|
+
exit
|
205
|
+
end
|
206
|
+
|
207
|
+
File.open(config) { |file| @config.merge!(YAML::load(file)) }
|
208
|
+
@config[:folders] = [] unless @config[:folders]
|
209
|
+
@config[:server][:folders] = [] unless @config[:server][:folders]
|
210
|
+
|
211
|
+
# Parses CLI Parameters, merges configuration and gets todo list
|
212
|
+
parse_options
|
213
|
+
|
214
|
+
# Backwards compatibility
|
215
|
+
@config[:app_path] = @config[:armapath] if @config[:armapath]
|
216
|
+
@config[:app_exe] = @config[:armaexe] if @config[:armaexe]
|
217
|
+
@config[:app_params] = @config[:armaparams] if @config[:armaparams]
|
218
|
+
#@config[:git_path] = @config[:gitpath] if @config[:gitpath]
|
219
|
+
|
220
|
+
# Determine arma distribution and location
|
221
|
+
case RUBY_PLATFORM
|
222
|
+
when /-mingw32$/, /-mswin32$/
|
223
|
+
|
224
|
+
unless @config[:app_path]
|
225
|
+
begin
|
226
|
+
@config[:app_path] = Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, ARMA2_STEAM[0])[ARMA2_STEAM[1]]
|
227
|
+
log.info "ArmA 2 Steam Distribution detected"
|
228
|
+
rescue
|
229
|
+
begin
|
230
|
+
@config[:app_path] = Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, ARMA2_ALT[0])[ARMA2_ALT[1]]
|
231
|
+
log.info "ArmA 2 Alt Distribution detected"
|
232
|
+
rescue
|
233
|
+
begin
|
234
|
+
@config[:app_path] = Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, ARMA2[0])[ARMA2[1]]
|
235
|
+
log.info "ArmA 2 Standard Distribution detected"
|
236
|
+
rescue
|
237
|
+
log.warn "No (known) ArmA 2 Distribution detected"
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
# Verify installation folder
|
245
|
+
if @config[:app_path]
|
246
|
+
log.info "ArmA Path: #{@config[:app_path]}"
|
247
|
+
if File.exists?(@config[:app_path])
|
248
|
+
@config[:app_path].gsub!('\\', '/')
|
249
|
+
else
|
250
|
+
log.error "No valid ArmA installation folder found, please abort!"
|
251
|
+
wait
|
252
|
+
exit
|
253
|
+
end
|
254
|
+
else
|
255
|
+
log.error "No valid ArmA installation folder found, please abort!"
|
256
|
+
wait
|
257
|
+
exit
|
258
|
+
end
|
259
|
+
|
260
|
+
if @config[:app_modpath]
|
261
|
+
log.info "Installation Path: #{@config[:app_modpath]}"
|
262
|
+
if File.exists?(@config[:app_modpath])
|
263
|
+
@config[:app_modpath].gsub!('\\', '/')
|
264
|
+
else
|
265
|
+
log.error "No valid Mod installation folder found, please abort!"
|
266
|
+
wait
|
267
|
+
exit
|
268
|
+
end
|
269
|
+
else
|
270
|
+
@config[:app_modpath] = @config[:app_path]
|
271
|
+
end
|
272
|
+
|
273
|
+
@config[:folders].uniq!
|
274
|
+
@config[:folders].sort! do |a, b|
|
275
|
+
a_prio = a[:priority] ? a[:priority] : 9999
|
276
|
+
b_prio = b[:priority] ? b[:priority] : 9999
|
277
|
+
a_prio <=> b_prio
|
278
|
+
end
|
279
|
+
log.debug "@config #{@config}"
|
280
|
+
|
281
|
+
# PreProcess the config data
|
282
|
+
@mods = []
|
283
|
+
@mods << @config[:mods] if @config[:mods]
|
284
|
+
|
285
|
+
@beta = false
|
286
|
+
@beta_exe = false
|
287
|
+
@beta_exe = true if @config[:app_exe][/beta[\/|\\]arma2.*/]
|
288
|
+
|
289
|
+
@config[:folders].each do |folder|
|
290
|
+
@beta = true if folder[:folder] == 'beta'
|
291
|
+
unless folder[:disabled]
|
292
|
+
folder[:folder].gsub!('\\', '/')
|
293
|
+
if folder[:mods]
|
294
|
+
@mods << folder[:mods]
|
295
|
+
else
|
296
|
+
@mods << folder[:folder]
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
@mods = @mods.join(';')
|
301
|
+
|
302
|
+
# Output processed config data
|
303
|
+
log.info "Manager for: #{@mods}"
|
304
|
+
beta_msg
|
305
|
+
|
306
|
+
# Prepare stats
|
307
|
+
@stats = []
|
308
|
+
@config[:folders].each do |folder|
|
309
|
+
stat = Hash.new
|
310
|
+
@stats << stat
|
311
|
+
path = File.join(@config[:app_modpath], folder[:folder])
|
312
|
+
stat[:changelog] = []
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
def beta_msg
|
317
|
+
if @beta_exe && !@beta
|
318
|
+
log.warn "WARNING: You do not seem to be running the 'beta' modfolder, but have selected 'beta/arma2.exe'"
|
319
|
+
elsif !@beta_exe && @beta
|
320
|
+
log.warn "WARNING: You seem to be running the 'beta' modfolder, but have not selected 'beta/arma2.exe'"
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
def log
|
325
|
+
@@log
|
326
|
+
end
|
327
|
+
|
328
|
+
def exit_app
|
329
|
+
FileUtils.rm_f PID_FILE
|
330
|
+
exit
|
331
|
+
end
|
332
|
+
|
333
|
+
def wait
|
334
|
+
STDIN.gets
|
335
|
+
end
|
336
|
+
|
337
|
+
def sure?
|
338
|
+
log.info "Are you really sure? Please press Enter to continue, or close the application to abort."
|
339
|
+
wait
|
340
|
+
end
|
341
|
+
|
342
|
+
def exit
|
343
|
+
FileUtils.rm_f PID_FILE if File.exist?(PID_FILE)
|
344
|
+
Process.exit
|
345
|
+
end
|
346
|
+
|
347
|
+
# General Tasks
|
348
|
+
def joingame
|
349
|
+
cmd = ""
|
350
|
+
cmd << " -connect=#{@config[:server][:address]}" if @config[:server][:address]
|
351
|
+
cmd << " -port=#{@config[:server][:port]}" if @config[:server][:port]
|
352
|
+
cmd << " -password=#{@config[:server][:password]}" if @config[:server][:password]
|
353
|
+
startgame(cmd)
|
354
|
+
end
|
355
|
+
|
356
|
+
def startgame(cmd = nil)
|
357
|
+
log.info "Starting the game with #{@config[:app_params]} -mod=#{@mods}#{cmd}"
|
358
|
+
#system "\"#{@config[:app_exe]}\" #{@config[:app_params]} -mod=#{@mods}"
|
359
|
+
case RUBY_PLATFORM
|
360
|
+
when /-mingw32$/, /-mswin32$/
|
361
|
+
begin
|
362
|
+
struct = Process.create(
|
363
|
+
:app_name => File.join(@config[:app_path], @config[:app_exe]),
|
364
|
+
:command_line => " #{@config[:app_params]} -mod=#{@mods}#{cmd}",
|
365
|
+
:creation_flags => Process::DETACHED_PROCESS,
|
366
|
+
:process_inherit => false,
|
367
|
+
:thread_inherit => false,
|
368
|
+
:cwd => @config[:app_path],
|
369
|
+
:inherit => false
|
370
|
+
#:environment => ""
|
371
|
+
)
|
372
|
+
rescue
|
373
|
+
log.warn "WARNING: Something went wrong starting the app: #{@config[:app_exe]}"
|
374
|
+
log.debug "#{$!}"
|
375
|
+
end
|
376
|
+
else
|
377
|
+
Dir.chdir(@config[:app_path]) do
|
378
|
+
system "#{@config[:app_exe]} #{@config[:app_params]} -mod=#{@mods}#{cmd}"
|
379
|
+
end
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
def shortcut(path)
|
384
|
+
case RUBY_PLATFORM
|
385
|
+
when /-mingw32$/, /-mswin32$/
|
386
|
+
cwd = Dir.pwd
|
387
|
+
Dir.chdir path
|
388
|
+
mods = @mods.clone
|
389
|
+
mods.gsub!(/\//, '-')
|
390
|
+
mods2 = @mods.clone
|
391
|
+
mods2.gsub!('/', '\\')
|
392
|
+
name = "Play ArmA2 with #{mods}.lnk"
|
393
|
+
Win32::Shortcut.new(name) do |shortcut|
|
394
|
+
shortcut.description = "Start Arma2 with #{mods2}"
|
395
|
+
shortcut.path = File.join(@config[:app_path], @config[:app_exe])
|
396
|
+
shortcut.working_directory = @config[:app_path]
|
397
|
+
shortcut.arguments = "#{@config[:app_params]} -mod=#{mods2}"
|
398
|
+
end
|
399
|
+
str = path.clone
|
400
|
+
str.gsub!('/', '\\')
|
401
|
+
log.info "Created shortcut (in #{str}): #{name}"
|
402
|
+
Dir.chdir cwd
|
403
|
+
else
|
404
|
+
log.warn "Unsupported on current Platform: #{RUBY_PLATFORM}"
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
def createshortcut
|
409
|
+
shortcut @config[:app_path]
|
410
|
+
end
|
411
|
+
|
412
|
+
def createdesktopshortcut
|
413
|
+
case RUBY_PLATFORM
|
414
|
+
when /-mingw32$/, /-mswin32$/
|
415
|
+
begin
|
416
|
+
desktop = Win32::Registry.open(Win32::Registry::HKEY_CURRENT_USER, DESKTOP[0])[DESKTOP[1]]
|
417
|
+
while desktop =~ /\%(\w*)\%/ do
|
418
|
+
desktop.sub!("%#{$1}%", ENV[$1])
|
419
|
+
end
|
420
|
+
shortcut desktop if File.directory? desktop
|
421
|
+
rescue
|
422
|
+
log.warn "WARNING: Problem while creating shortcut! #{$!}"
|
423
|
+
end
|
424
|
+
else
|
425
|
+
log.warn "Unsupported on current Platform: #{RUBY_PLATFORM}"
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
def uninstall
|
430
|
+
log.warn "Uninstall feature temporary disabled. Please delete the modfolder manually for uninstall"
|
431
|
+
=begin
|
432
|
+
@config[:folders].each do |config|
|
433
|
+
log.info "= #{config[:folder]}"
|
434
|
+
mod = Mod.new(config, @config)
|
435
|
+
mod.uninstall
|
436
|
+
end
|
437
|
+
=end
|
438
|
+
end
|
439
|
+
end
|
440
|
+
end
|