wwine 0.2.1 → 0.2.2
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.
- data/wwine +138 -65
- metadata +3 -3
data/wwine
CHANGED
@@ -20,13 +20,11 @@ require 'getoptlong'
|
|
20
20
|
# To read info for --debuginfo
|
21
21
|
require 'open3'
|
22
22
|
# Application version
|
23
|
-
$version = '0.2.
|
23
|
+
$version = '0.2.2'
|
24
24
|
# The wine flavour to use
|
25
25
|
$wine = nil
|
26
26
|
# The bottle to use
|
27
27
|
$bottle = nil
|
28
|
-
# Verbose mode (true/false)
|
29
|
-
$verbose = false
|
30
28
|
# CX path
|
31
29
|
$cxPath = nil
|
32
30
|
# Path to write wrapper to
|
@@ -39,6 +37,10 @@ $wwineDataFrom = nil
|
|
39
37
|
$envMode = false
|
40
38
|
# true if we're in --tricks mode
|
41
39
|
$tricksMode = false
|
40
|
+
# Verbosity level
|
41
|
+
$verbosity = 0
|
42
|
+
V_INFO=1
|
43
|
+
V_DBG=2
|
42
44
|
|
43
45
|
# Purpose: Attempt to kill all running wine processes
|
44
46
|
def killWine (dryRun = false, signal = 15)
|
@@ -288,7 +290,7 @@ def generateWwineCmd (wine,bottle,wineCommand,type = nil)
|
|
288
290
|
wwineInfo = ['nil','nil','nil','nil']
|
289
291
|
|
290
292
|
# Generate a wwine command-line
|
291
|
-
if $
|
293
|
+
if $verbosity > 0
|
292
294
|
wwineCmd.push('--verbose')
|
293
295
|
end
|
294
296
|
if $cxPath
|
@@ -335,7 +337,7 @@ def generateWrapper (wine,bottle,targetFile,wineCommand,args,type = nil)
|
|
335
337
|
# For wine there is no --bottle definition in the wine command itself,
|
336
338
|
# so we need to export a wineprefix in the launch script
|
337
339
|
if type == 'wine'
|
338
|
-
wineprefix = ENV['WINEPREFIX']
|
340
|
+
wineprefix = ENV['WINEPREFIX'].dup
|
339
341
|
end
|
340
342
|
|
341
343
|
writeWrapper(targetFile ,wwineCmd, wineCommand, $wrapperCwd, wwineInfo, args, wineprefix)
|
@@ -344,28 +346,51 @@ end
|
|
344
346
|
# Purpose: Sets WINE and WINEPREFIX, and then either outputs them to STDOUT, or
|
345
347
|
# executes whatever native command was supplied (the logic that handles --env)
|
346
348
|
def setEnvAndExec (wine,bottle,cmd,args,type)
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
349
|
+
if wine == nil
|
350
|
+
type,cmd = getAutoWithParams(bottle)
|
351
|
+
end
|
352
|
+
ENV['__WWINE_INT_WINE'] = wine
|
353
|
+
vputs(V_DBG,'Set __WWINE_INT_WINE='+wine)
|
354
|
+
|
355
|
+
if wine == 'cxoffice' || wine == 'cxgames' || wine == 'crossover'
|
356
|
+
cxdir = getCXwithParams(wine,bottle,true,false,true)
|
357
|
+
if File.executable?(cxdir+'/bin/wineserver')
|
358
|
+
vputs(V_DBG,'Set WINESERVER='+cxdir+'/bin/wineserver')
|
359
|
+
ENV['WINESERVER'] = cxdir+'/bin/wineserver'
|
360
|
+
end
|
361
|
+
end
|
352
362
|
|
353
363
|
if !bottle
|
354
364
|
puts("--env requires a --bottle")
|
355
365
|
exit(1)
|
356
366
|
end
|
367
|
+
vputs(V_DBG,'Set __WWINE_INT_BOTTLE='+bottle)
|
368
|
+
ENV['__WWINE_INT_BOTTLE'] = bottle
|
369
|
+
vputs(V_DBG,'Set __WWINE_INT_ENVMODE='+$version)
|
370
|
+
ENV['__WWINE_INT_ENVMODE'] = $version
|
371
|
+
if $verbosity > 0
|
372
|
+
vputs(V_DBG,'Set __WWINE_INT_VERBOSITY='+$verbosity.to_s)
|
373
|
+
ENV['__WWINE_INT_VERBOSITY'] = $verbosity.to_s
|
374
|
+
end
|
375
|
+
if $cxPath
|
376
|
+
vputs(V_DBG,'Set __WWINE_INT_CXPATH='+$cxpath)
|
377
|
+
ENV['__WWINE_INT_CXPATH'] = $cxPath
|
378
|
+
end
|
357
379
|
|
358
380
|
if wine == 'wine' || File.exists?(wine)
|
359
381
|
bottlePath = ENV['WINEPREFIX']
|
360
382
|
elsif wine == 'cedega'
|
361
383
|
bottlePath = ENV['HOME']+'/.cedega/'+bottle
|
362
384
|
else
|
363
|
-
bottlePath =
|
385
|
+
bottlePath = getCXwithParams(wine,bottle,true,true)
|
364
386
|
end
|
365
387
|
|
388
|
+
vputs(V_INFO,"Set WINEPREFIX="+bottlePath)
|
389
|
+
vputs(V_INFO,"Set WINE="+File.expand_path($0))
|
366
390
|
ENV['WINEPREFIX'] = bottlePath
|
367
|
-
ENV['WINE'] =
|
391
|
+
ENV['WINE'] = File.expand_path($0)
|
368
392
|
if args.length > 0
|
393
|
+
puts("Executing "+args.join(' '))
|
369
394
|
exec *args
|
370
395
|
else
|
371
396
|
puts("WINE="+shellQuote(ENV['WINE']))
|
@@ -524,10 +549,10 @@ end
|
|
524
549
|
# Purpose: Run a command, outputting info of it in verbose mode
|
525
550
|
def runcmd(cmd, type = 'exec')
|
526
551
|
if(type == 'exec')
|
527
|
-
vputs
|
552
|
+
vputs(V_INFO,'Executing: '+cmd.join(' '))
|
528
553
|
exec *cmd
|
529
554
|
else
|
530
|
-
vputs
|
555
|
+
vputs(V_INFO,'Running: '+cmd.join(' '))
|
531
556
|
return system(*cmd)
|
532
557
|
end
|
533
558
|
end
|
@@ -543,8 +568,11 @@ def inPath(exec)
|
|
543
568
|
end
|
544
569
|
|
545
570
|
# Purpose: Output a string if in verbose mode
|
546
|
-
def vputs (str)
|
547
|
-
if
|
571
|
+
def vputs (level,str)
|
572
|
+
if(level == V_DBG)
|
573
|
+
str = 'Debug: '+str
|
574
|
+
end
|
575
|
+
if $verbosity >= level
|
548
576
|
puts(str)
|
549
577
|
end
|
550
578
|
end
|
@@ -565,7 +593,7 @@ def Help ()
|
|
565
593
|
printHelp('','--wrap','Write a wrapper script of your current wwine command to the path supplied')
|
566
594
|
printHelp('','--wrapdir','Use the supplied directory as the working directory for the script created by --wrap (default: current directory)')
|
567
595
|
printHelp('-s','--from','Load parameters and program from the wrapper script supplied. Command-line arguments overrides settings from wrapper script.')
|
568
|
-
printHelp('-v','--verbose','Enable verbose mode')
|
596
|
+
printHelp('-v','--verbose','Enable verbose mode. Supply multiple times to further increase verbosity.')
|
569
597
|
printHelp('','--man','Show the wwine manpage')
|
570
598
|
end
|
571
599
|
|
@@ -849,7 +877,8 @@ def getWineWithParams (wine,bottle, missingIsFatal = true)
|
|
849
877
|
if ! (bottle =~ /^\.?\//)
|
850
878
|
bottle = ENV['HOME']+'/.wwinebottles/'+bottle
|
851
879
|
if !File.exists?(ENV['HOME']+'/.wwinebottles/')
|
852
|
-
vputs(ENV['HOME']+'/.wwinebottles/: does not exist, creating')
|
880
|
+
vputs(V_INFO,ENV['HOME']+'/.wwinebottles/: does not exist, creating')
|
881
|
+
vputs(V_DBG,ENV['HOME']+'/'+bottleDir+'/'+bottle+' did not exist')
|
853
882
|
begin
|
854
883
|
Dir.mkdir(ENV['HOME']+'/.wwinebottles/')
|
855
884
|
rescue SystemCallError
|
@@ -860,29 +889,30 @@ def getWineWithParams (wine,bottle, missingIsFatal = true)
|
|
860
889
|
end
|
861
890
|
end
|
862
891
|
ENV['WINEPREFIX'] = bottle
|
863
|
-
vputs('Set WINEPREFIX='+bottle)
|
892
|
+
vputs(V_INFO,'Set WINEPREFIX='+bottle)
|
864
893
|
end
|
865
894
|
|
866
895
|
# Default to no debugging output if WINEDEBUG is not set yet
|
867
896
|
if ! ENV.has_key?('WINEDEBUG')
|
868
|
-
vputs
|
897
|
+
vputs(V_INFO,'Set WINEDEBUG=-all')
|
869
898
|
ENV['WINEDEBUG'] = '-all'
|
870
899
|
end
|
871
900
|
|
901
|
+
vputs(V_DBG,'Detected wine: '+final.join(' '))
|
872
902
|
return final
|
873
903
|
end
|
874
904
|
|
875
905
|
# Purpose: Get parameters for crossover
|
876
|
-
def getCXwithParams (wine,bottle, missingIsFatal = true)
|
906
|
+
def getCXwithParams (wine,bottle, missingIsFatal = true, getBottleDir = false, getCXpath = false)
|
877
907
|
final = []
|
878
908
|
cxdir = nil
|
879
909
|
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
910
|
+
installName = wine
|
911
|
+
if wine == 'crossover'
|
912
|
+
installName = 'cxoffice'
|
913
|
+
end
|
884
914
|
mode = wine
|
885
|
-
bottleDir = '.'+
|
915
|
+
bottleDir = '.'+installName
|
886
916
|
|
887
917
|
# Various crossover install paths
|
888
918
|
wines = ['/opt/'+installName, ENV['HOME']+'/'+installName, ENV['HOME']+'/.local/'+installName, ENV['HOME']+'/games/'+installName]
|
@@ -895,14 +925,14 @@ def getCXwithParams (wine,bottle, missingIsFatal = true)
|
|
895
925
|
wines.each do |path|
|
896
926
|
if File.exists?(path)
|
897
927
|
if ( File.executable?(path+'/bin/cximportbottles') || File.executable?(path+'/bin/crossover') ) and wine != 'cxgames'
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
928
|
+
# Perform additional detection of dotDir, as that one tends to change
|
929
|
+
dotDir = Dir.glob(path+'/etc/cxoffice*.conf').shift
|
930
|
+
if( dotDir != nil && dotDir.sub!(/^.*(cxoffice\d*)\.conf$/,'\1') )
|
931
|
+
mode = 'crossover'
|
932
|
+
cxdir = path
|
933
|
+
bottleDir = '.'+dotDir
|
934
|
+
break
|
935
|
+
end
|
906
936
|
elsif File.executable?(path+'/bin/cxstart')
|
907
937
|
cxdir = path
|
908
938
|
break
|
@@ -922,12 +952,13 @@ def getCXwithParams (wine,bottle, missingIsFatal = true)
|
|
922
952
|
# If the dir does not exist, give up
|
923
953
|
if not cxdir
|
924
954
|
if !missingIsFatal
|
955
|
+
vputs(V_DBG,'Failed to detect cxdir')
|
925
956
|
return nil
|
926
957
|
end
|
927
958
|
if $cxPath != nil
|
928
|
-
puts('Could not find a directory named "'+
|
929
|
-
puts('and '+$cxPath+' does not appear to be a '+
|
930
|
-
if
|
959
|
+
puts('Could not find a directory named "'+installName+'" in '+$cxPath)
|
960
|
+
puts('and '+$cxPath+' does not appear to be a '+installName+' install directory')
|
961
|
+
if installName == 'cxgames'
|
931
962
|
reverse = 'cxoffice'
|
932
963
|
else
|
933
964
|
reverse = 'cxgames'
|
@@ -942,6 +973,8 @@ def getCXwithParams (wine,bottle, missingIsFatal = true)
|
|
942
973
|
puts('by supplying --cxinstalldir')
|
943
974
|
end
|
944
975
|
exit(1)
|
976
|
+
elsif getCXpath
|
977
|
+
return cxdir
|
945
978
|
end
|
946
979
|
|
947
980
|
final.push(cxdir+'/bin/cxstart')
|
@@ -952,6 +985,7 @@ def getCXwithParams (wine,bottle, missingIsFatal = true)
|
|
952
985
|
|
953
986
|
# Create the bottle if it does not exist
|
954
987
|
if bottle != nil and ! File.exists?(ENV['HOME']+'/'+bottleDir+'/'+bottle)
|
988
|
+
vputs(V_DBG,ENV['HOME']+'/'+bottleDir+'/'+bottle+' did not exist')
|
955
989
|
puts 'The bottle '+bottle+' did not exist, creating...'
|
956
990
|
runcmd([ cxdir+'/bin/cxbottle', '--bottle',bottle,'--create','--template','winxp'],'system')
|
957
991
|
if ! File.exists?(ENV['HOME']+'/'+bottleDir+'/'+bottle)
|
@@ -960,7 +994,12 @@ def getCXwithParams (wine,bottle, missingIsFatal = true)
|
|
960
994
|
end
|
961
995
|
end
|
962
996
|
|
963
|
-
|
997
|
+
if getBottleDir
|
998
|
+
return ENV['HOME']+'/'+bottleDir+'/'+bottle
|
999
|
+
else
|
1000
|
+
vputs(V_DBG,'Detected cx: '+final.join(' '))
|
1001
|
+
return final
|
1002
|
+
end
|
964
1003
|
end
|
965
1004
|
|
966
1005
|
# Purpose: Get parameters for cedega
|
@@ -984,6 +1023,7 @@ def getCedegaWithParams (wine,bottle, missingIsFatal = true)
|
|
984
1023
|
end
|
985
1024
|
final.push(bottle)
|
986
1025
|
|
1026
|
+
vputs(V_DBG,'Detected cedega: '+final.join(' '))
|
987
1027
|
return final
|
988
1028
|
end
|
989
1029
|
|
@@ -1012,6 +1052,7 @@ def getAutoWithParams (bottle, missingIsFatal = true, returnFlavour = false)
|
|
1012
1052
|
return nil
|
1013
1053
|
end
|
1014
1054
|
else
|
1055
|
+
vputs(V_DBG,'Autodetected wine command: '+cmd.join(' '))
|
1015
1056
|
return type,cmd
|
1016
1057
|
end
|
1017
1058
|
end
|
@@ -1035,13 +1076,17 @@ def runWine (wine,bottle,args)
|
|
1035
1076
|
type = wine
|
1036
1077
|
|
1037
1078
|
if wine == 'cxgames' || wine == 'cxoffice' || wine == 'crossover'
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1079
|
+
missingIsFatal = true
|
1080
|
+
if wine == 'cxgames'
|
1081
|
+
missingIsFatal = false
|
1082
|
+
end
|
1083
|
+
cmd = getCXwithParams(wine,bottle,missingIsFatal)
|
1084
|
+
if wine == 'cxgames' && cmd == nil
|
1085
|
+
cmd = getCXwithParams('crossover',bottle)
|
1086
|
+
if cmd != nil
|
1087
|
+
puts('Converting --wine cxgames to --wine crossover since cxgames is not installed')
|
1088
|
+
end
|
1089
|
+
end
|
1045
1090
|
elsif wine == 'wine' || File.executable?(wine)
|
1046
1091
|
type = 'wine'
|
1047
1092
|
cmd = getWineWithParams(wine,bottle)
|
@@ -1053,6 +1098,10 @@ def runWine (wine,bottle,args)
|
|
1053
1098
|
exit(1)
|
1054
1099
|
end
|
1055
1100
|
end
|
1101
|
+
if cmd == nil
|
1102
|
+
puts('Command detection failed. This is a bug')
|
1103
|
+
exit(1)
|
1104
|
+
end
|
1056
1105
|
cmd.concat(args)
|
1057
1106
|
|
1058
1107
|
# If args is a single parameter, that parameter is --version, and we're not using
|
@@ -1089,24 +1138,41 @@ def runWine (wine,bottle,args)
|
|
1089
1138
|
end
|
1090
1139
|
end
|
1091
1140
|
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
[
|
1098
|
-
|
1099
|
-
|
1100
|
-
[ '
|
1101
|
-
|
1102
|
-
|
1103
|
-
[
|
1104
|
-
|
1105
|
-
|
1106
|
-
[
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1141
|
+
# Note: These environment variables are not considered a stable interface to wwine
|
1142
|
+
# (hence the version specific ENVMODE), they should never ever be used by any
|
1143
|
+
# outside program.
|
1144
|
+
if ENV['__WWINE_INT_ENVMODE'] == $version
|
1145
|
+
opts = Hash.new
|
1146
|
+
if ENV['__WWINE_INT_WINE']
|
1147
|
+
opts['--wine'] = ENV['__WWINE_INT_WINE']
|
1148
|
+
end
|
1149
|
+
if ENV['__WWINE_INT_VERBOSITY'] && ENV['__WWINE_INT_VERBOSITY'].to_i > 0
|
1150
|
+
$verbosity = ENV['__WWINE_INT_VERBOSITY'].to_i
|
1151
|
+
end
|
1152
|
+
if ENV['__WWINE_INT_CXPATH']
|
1153
|
+
opts['--cxinstalldir'] = ENV['__WWINE_INT_CXPATH']
|
1154
|
+
end
|
1155
|
+
opts['--bottle'] = ENV['__WWINE_INT_BOTTLE']
|
1156
|
+
else
|
1157
|
+
opts = GetoptLong.new(
|
1158
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
1159
|
+
[ '--wine', '-w', GetoptLong::REQUIRED_ARGUMENT ],
|
1160
|
+
[ '--bottle', '-b', GetoptLong::REQUIRED_ARGUMENT ],
|
1161
|
+
[ '--kill', '-k', GetoptLong::OPTIONAL_ARGUMENT ],
|
1162
|
+
[ '--drykill', GetoptLong::NO_ARGUMENT ],
|
1163
|
+
[ '--cxinstalldir','-c',GetoptLong::REQUIRED_ARGUMENT ],
|
1164
|
+
[ '--version',GetoptLong::NO_ARGUMENT ],
|
1165
|
+
[ '--wrap', GetoptLong::REQUIRED_ARGUMENT ],
|
1166
|
+
[ '--wrapdir', GetoptLong::REQUIRED_ARGUMENT ],
|
1167
|
+
[ '--debuginfo', GetoptLong::NO_ARGUMENT ],
|
1168
|
+
[ '--man', GetoptLong::NO_ARGUMENT ],
|
1169
|
+
[ '--env', GetoptLong::NO_ARGUMENT ],
|
1170
|
+
[ '--tricks', GetoptLong::NO_ARGUMENT ],
|
1171
|
+
[ '--env-bottle', GetoptLong::NO_ARGUMENT ],
|
1172
|
+
[ '--from', '-s', GetoptLong::REQUIRED_ARGUMENT ],
|
1173
|
+
[ '--verbose', '-v', GetoptLong::NO_ARGUMENT ]
|
1174
|
+
)
|
1175
|
+
end
|
1110
1176
|
|
1111
1177
|
# Handle command-line arguments
|
1112
1178
|
begin
|
@@ -1120,6 +1186,8 @@ begin
|
|
1120
1186
|
when '--bottle'
|
1121
1187
|
$bottle = arg
|
1122
1188
|
when '--env-bottle'
|
1189
|
+
puts 'DEPRECATED: --env-bottle is deprecated as of wwine 0.2.2'
|
1190
|
+
puts ' pending removal in 0.3'
|
1123
1191
|
if ENV['WINEPREFIX'] && ENV['WINEPREFIX'].length > 0
|
1124
1192
|
$bottle = File.basename(ENV['WINEPREFIX'])
|
1125
1193
|
else
|
@@ -1127,7 +1195,7 @@ begin
|
|
1127
1195
|
exit(1)
|
1128
1196
|
end
|
1129
1197
|
when '--verbose'
|
1130
|
-
$
|
1198
|
+
$verbosity = $verbosity+1
|
1131
1199
|
when '--drykill'
|
1132
1200
|
killWine(true)
|
1133
1201
|
exit(0)
|
@@ -1142,6 +1210,10 @@ begin
|
|
1142
1210
|
exit(0)
|
1143
1211
|
when '--cxinstalldir'
|
1144
1212
|
$cxPath = arg
|
1213
|
+
if ! File.exists?($cxPath)
|
1214
|
+
puts('The supplied --cxinstalldir "'+$cxPath+'" does not exist')
|
1215
|
+
exit(1)
|
1216
|
+
end
|
1145
1217
|
when '--version'
|
1146
1218
|
puts('wwine version '+$version+' (for wine version info, run wwine --debuginfo)')
|
1147
1219
|
exit(0)
|
@@ -1164,7 +1236,7 @@ begin
|
|
1164
1236
|
|
1165
1237
|
if ENV['WWINE_VERBOSE'] != nil && ENV['WWINE_VERBOSE'] == '1'
|
1166
1238
|
puts('--verbose assumed because the environment variable WWINE_VERBOSE is set to 1')
|
1167
|
-
$
|
1239
|
+
$verbosity = 1
|
1168
1240
|
end
|
1169
1241
|
rescue
|
1170
1242
|
puts('See --help for more inforation')
|
@@ -1189,3 +1261,4 @@ begin
|
|
1189
1261
|
rescue => ex
|
1190
1262
|
handleException(ex)
|
1191
1263
|
end
|
1264
|
+
# vim: noexpandtab
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wwine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: .
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: wwine is a simple wine wrapper.
|
15
15
|
email: code at zerodogg dot org
|
@@ -43,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
45
|
rubyforge_project:
|
46
|
-
rubygems_version: 1.8.
|
46
|
+
rubygems_version: 1.8.23
|
47
47
|
signing_key:
|
48
48
|
specification_version: 3
|
49
49
|
summary: wwine is a simple wine wrapper.
|