-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwinetricks-alpha
9905 lines (8527 loc) · 329 KB
/
winetricks-alpha
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
# I no longer pull winetricks-alpha from winezeug, it's moved to its own repo
# LGPL
# Copyright 2010 Dan Kegel
# Experimental cleanup of winetricks
#
#--------------------------------------------------------------------
# See http://code.google.com/p/winezeug/wiki/ConvergedFrontends
#
# This script, and the verbs it invokes, should follow these Coding standards:
#
# Portability:
# - Portability matters, as this script is run on many operating systems
# - No bash, zsh, or csh extensions; only use features from
# the Posix standard shell and utilities; see
# http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
# - Prefer classic sh idioms as described in e.g.
# "Portable Shell Programming" by Bruce Blinn, ISBN: 0-13-451494-7
# - If there is no universally available program for a needed function,
# support the two most frequently available programs.
# e.g. fall back to wget if curl is not available; likewise, support
# both sha1sum and openssl.
# - When using unix commands like cp, put options before filenames so it will
# work on systems like MacOSX. e.g. "rm -f foo.dat", not "rm foo.dat -f"
#
# Formatting:
# - Your terminal and editor must be configured for utf-8
# If you do not see an o with two dots over it here [ö], stop!
# - Do not use tabs in this file or any verbs.
# - Indent 4 spaces.
# - Try to keep line length below 80 (makes printing easier)
# - Open curly braces ('{') and 'then' at beginning of line,
# close curlies ('}') and 'fi' should line up with the matching { or if,
# cases aligned with 'case' and 'esac'. For instance,
#
# if test "$FOO" = "bar"
# then
# echo "FOO is bar"
# fi
# case "$FOO" of
# bar) echo "FOO is still bar" ;;
# esac
#
# Commenting:
# - Comments should explain intent in English
# - Keep functions short and well named to reduce need for comments
#
# Naming:
# Public things defined by this script, for use by verbs:
# - Variables have uppercase names starting with W_
# - Functions have lowercase names starting with w_
#
# Private things internal to this script, not for use by verbs:
# - Local variables have lowercase names starting with uppercase _W_
# - Global variables have uppercase names starting with WINETRICKS_
# - Functions have lowercase names starting with winetricks_
# FIXME: A few verbs still use winetricks-private functions or variables.
#
# Internationalization / localization:
# - Important or frequently used message should be internationalized
# so translations can be easily added. For example:
# case $LANG in
# de*) echo "Das ist die deutsche Meldung" ;;
# *) echo "This is the English message" ;;
# esac
#
#--------------------------------------------------------------------
# Name of this version of winetricks (YYYYMMDD)
WINETRICKS_VERSION=20110117-alpha
#---- Public Functions ----
# Display warning message
w_warn()
{
echo "------------------------------------------------------"
echo "$@"
echo "------------------------------------------------------"
# For some reason, nulls were showing up in $@?!, causing truncated output
# in zenity, so use tr to replace NUL chars with spaces.
msg="`echo $@ | tr '\000' ' '`"
case $WINETRICKS_GUI in
zenity) zenity --error --title=winetricks --text="$msg" --no-wrap;;
kdialog) kdialog --title winetricks --error "$msg" ;;
none) ;;
esac
}
# Display fatal error message and terminate script
w_die()
{
w_warn "$@"
exit 1
}
# I no longer pull winetricks-alpha from winezeug, it's moved to its own repo
xdg-open http://winetricks.googlecode.com
w_die "winetricks-alpha has moved. Please use the repository http://winetricks.googlecode.com."
# Execute with error checking
# Put this in front of any command that might fail
w_try()
{
# "VAR=foo w_try cmd" fails to put VAR in the environment
# with some versions of bash if w_try is a shell function?!
# This is a problem when trying to pass environment variables to e.g. wine.
# Adding an explicit export here works around it, so add any we use.
export WINEDLLOVERRIDES
echo Executing "$@"
# On Vista, we need to jump through a few hoops to run commands in cygwin.
# First, .exe's need to have the executable bit set.
# Second, only cmd can run setup programs (presumably for security).
# If $1 ends in .exe, we know we're running on real windows, otherwise
# $1 would be 'wine'.
case "$1" in
*.exe)
chmod +x "$1" || true # don't care if it fails
cmd /c "$@"
;;
*)
"$@"
;;
esac
status=$?
if test $status -ne 0
then
w_die "Note: command '$@' returned status $status. Aborting."
fi
}
w_try_regedit()
{
# on windows, doesn't work without cmd /c
case "$OS" in
"Windows_NT") cmdc="cmd /c";;
*) unset cmdc ;;
esac
w_try winetricks_early_wine $cmdc regedit $W_UNATTENDED_SLASH_S "$@"
}
w_try_regsvr()
{
w_try $WINE regsvr32 $W_UNATTENDED_SLASH_S $@
}
w_try_cabextract()
{
# Not always installed, but shouldn't be fatal unless it's being used
if test ! -x "`which cabextract 2>/dev/null`"
then
w_die "Cannot find cabextract. Please install it (e.g. 'sudo apt-get install cabextract' or 'sudo yum install cabextract')."
fi
w_try cabextract -q "$@"
}
w_try_unzip()
{
# Not always installed, but shouldn't be fatal unless it's being used
if test ! -x "`which unzip 2>/dev/null`"
then
w_die "Cannot find unzip. Please install it (e.g. 'sudo apt-get install unzip' or 'sudo yum install unzip')."
fi
w_try unzip -o -q "$@"
}
w_read_key()
{
case "$W_OPT_UNATTENDED" in
0) W_KEY=dummy_to_make_autohotkey_happy ; return 0 ;;
esac
_W_keyfile="$W_CACHE/$W_PACKAGE/key.txt"
if ! test -f "$_W_keyfile"
then
# read key from user
case $LANG in
da*) _W_keymsg="Angiv venligst registrerings-nøglen for pakken '$_PACKAGE'"
_W_nokeymsg="Ingen nøgle angivet"
;;
de*) _W_keymsg="Bitte einen Key für Pakete '$W_PACKAGE' eingeben"
_W_nokeymsg="Keinen Key eingegeben?"
;;
*) _W_keymsg="Please enter the key for app '$W_PACKAGE'"
_W_nokeymsg="No key given"
;;
esac
case $WINETRICKS_GUI in
*zenity) W_KEY=`zenity --entry --text "$_W_keymsg"` ;;
*kdialog) W_KEY=`kdialog --inputbox "$_W_keymsg"` ;;
*xmessage) w_die "sorry, can't read key from gui with xmessage" ;;
none) echo -n "$_W_keymsg": ; read W_KEY ;;
esac
if test "$W_KEY" = ""
then
w_die "$_W_nokeymsg"
fi
echo "$W_KEY" > "$_W_keyfile"
fi
W_KEY=`cat "$_W_keyfile" | tr -d -`
unset _W_keyfile _W_keymsg _W_nokeymsg
}
# Convert a Unix path to a Windows path
# Usage is lowest common denominator of cygpath/winepath
# so -u to convert to unix, and -w to convert to windows
w_pathconv()
{
case "$OS" in
"Windows_NT")
cygpath "$@"
;;
*)
winetricks_early_wine winepath "$@"
;;
esac
}
# verify an sha1sum
w_verify_sha1sum()
{
_W_vs_wantsum=$1
_W_vs_file=$2
_W_vs_gotsum=`$WINETRICKS_SHA1SUM < $_W_vs_file | sed 's/ .*//'`
if [ "$_W_vs_gotsum"x != "$_W_vs_wantsum"x ]
then
w_die "sha1sum mismatch! Rename $_W_vs_file and try again."
fi
unset _W_vs_wantsum _W_vs_file _W_vs_gotsum
}
# Execute wget, and if in gui mode, also show a graphical progress bar
winetricks_wget_progress()
{
case $WINETRICKS_GUI in
zenity)
# Usa a subshell so if the user clicks 'Cancel',
# the --auto-kill kills the subshell, not the current shell
(
wget "$@" 2>&1 |
sed -u 's/^.* \+\([0-9]\+%\) \+\([0-9.]\+[GMKB]\) \+\([0-9hms.]\+\).*$/\1\n# Downloading... \2 (\3)/' | \
zenity --progress --width 400 --title="$_W_file" --auto-kill --auto-close
)
err=$?
if test $err -gt 128
then
# 129 is 'killed by SIGHUP'
# Sadly, --auto-kill only applies to parent process,
# which was the subshell, not all the elements of the pipeline...
# have to go find and kill the wget.
# If we ran wget in the background, we could kill it more directly, perhaps...
if pid=`ps augxw | grep ."$_W_file" | grep -v grep | awk '{print $2}'`
then
echo User aborted download, killing wget
kill $pid
fi
fi
return $err
;;
*) wget "$@" ;;
esac
}
# Download a file
# Usage: w_download packagename url [sha1sum [filename [cookie jar]]]
# Caches downloads in winetrickscache/$packagename
w_download()
{
_W_packagename="$1"
_W_url="$2"
_W_sum="$3"
_W_file="$4"
_W_cookiejar="$5"
case $_W_packagename in
.) w_die "bug: please do not download packages to top of cache" ;;
esac
if [ "$_W_file"x = ""x ]
then
_W_file=`basename "$_W_url"`
fi
_W_cache="$W_CACHE/$_W_packagename"
mkdir -p "$_W_cache"
# Try download twice
checksum_ok=""
tries=0
while test $tries -lt 2
do
tries=`expr $tries + 1`
if test -s "$_W_cache/$_W_file"
then
if test "$3"
then
if test $tries = 1
then
# The cache was full. If the file is larger than 500MB,
# don't checksum it, that just annoys the user.
if test `du -k "$_W_cache/$_W_file" | cut -f1` -gt 500000
then
checksum_ok=1
break
fi
fi
# If checksum matches, declare success and exit loop
gotsum=`$WINETRICKS_SHA1SUM < "$_W_cache/$_W_file" | sed 's/(stdin)= //;s/ .*//'`
if [ "$gotsum"x = "$3"x ]
then
checksum_ok=1
break
fi
if test ! "$WINETRICKS_CONTINUE_DOWNLOAD"
then
w_warn "Checksum for $_W_cache/$_W_file did not match, retrying download"
mv -f "$_W_cache/$_W_file" "$_W_cache/$_W_file".bak
fi
else
# file exists, no checksum known, declare success and exit loop
break
fi
elif test -f "$_W_cache/$_W_file"
then
# zero length file, just delete before retrying
rm "$_W_cache/$_W_file"
fi
_W_dl_olddir=`pwd`
cd "$_W_cache"
# Mac folks tend to have curl rather than wget
# On Mac, 'which' doesn't return good exit status
# Need to jam in --header "Accept-Encoding: gzip,deflate" else
# redhat.com decompresses liberation-fonts.tar.gz!
# Note: this causes other sites to compress downloads, hence
# the kludge further down. See http://code.google.com/p/winezeug/issues/detail?id=77
echo Downloading $_W_url
if [ -x "`which wget 2>/dev/null`" ]
then
# Use -nd to insulate ourselves from people who set -x in WGETRC
# [*] --retry-connrefused works around the broken sf.net mirroring
# system when downloading corefonts
# [*] --read-timeout is useful on the adobe server that doesn't
# close the connection unless you tell it to (control-C or closing
# the socket)
# Disable retries for gog.com (which requires higher level retries)
winetricks_wget_progress -O "$_W_file" -nd -c --read-timeout=300 --tries=1 --retry-connrefused --header "Accept-Encoding: gzip,deflate" ${_W_cookiejar:+--load-cookies "$_W_cookiejar"} "$_W_url"
else
# curl doesn't get filename from the location given by the server!
# fortunately, we know it
curl -L -o "$_W_file" -C - --header "Accept-Encoding: gzip,deflate" ${_W_cookiejar:+--cookie "$_W_cookiejar"} "$_W_url"
fi
if test $? != 0
then
test -f "$_W_file" && rm "$_W_file"
w_die "Downloading $_W_url failed"
fi
# Need to decompress .exe's that are compressed, else cygwin fails
# Only affects cygwin, so don't barf if 'file' not installed
_W_filetype=`which file 2>/dev/null`
case $_W_filetype-$_W_file in
/*-*.exe)
case `file "$_W_file"` in
*gzip*) mv "$_W_file" "$_W_file.gz"; gunzip < "$_W_file.gz" > "$_W_file";;
esac
esac
# On cygwin, .exe's must be marked +x
case "$_W_file" in
*.exe) chmod +x "$_W_file" ;;
esac
cd "$_W_dl_olddir"
unset _W_dl_olddir
done
if test "$3" -a ! "$checksum_ok"
then
w_verify_sha1sum $3 "$_W_cache/$_W_file"
fi
}
# Download one or more files via bittorrent
# Usage: w_download_torrent package [foo.torrent]
# Caches downloads in $W_CACHE/$package, torrent files are assumed to be there
# If no foo.torrent is given, will add ALL .torrent files in $W_CACHE/$W_PACKAGE
w_download_torrent()
{
# FIXME: figure out how to extract the filename from the .torrent file
# so callers don't need to check if the files are already downloaded.
w_call utorrent
UT_WINPATH="$W_CACHE_WIN\\$1"
cd "$W_CACHE/$1"
if [ "$2"x != ""x ] # foo.torrent parameter supplied
then
w_try $WINE utorrent "/DIRECTORY" "$UT_WINPATH" "$UT_WINPATH\\$2" &
else # grab all torrents
for torrent in `ls *.torrent`
do
w_try $WINE utorrent "/DIRECTORY" "$UT_WINPATH" "$UT_WINPATH\\$torrent" &
done
fi
# Start uTorrent, have it wait until all downloads are finished
w_ahk_do "
SetTitleMatchMode, 2
winwait, Torrent
Loop
{
sleep 6000
ifwinexist, Torrent, default
{
;should uTorrent be the default torrent app?
controlclick, Button1, Torrent, default ; yes
continue
}
ifwinexist, Torrent, already
{
;torrent already registered, fine
controlclick, Button1, Torrent, default ; yes
continue
}
ifwinexist, Torrent, Bandwidth
{
;Cancels bandwidth test on first run of uTorrent
controlclick, Button5, Torrent, Bandwidth
continue
}
ifwinexist, Torrent, version
{
;Decline upgrade to newer version
controlclick, Button3, Torrent, version
controlclick, Button2, Torrent, version
continue
}
break
}
;Sets parameter to close uTorrent once all downloads are complete
winactivate, Torrent 2.0
send !o
send a{Down}{Enter}
winwaitclose, Torrent 2.0
"
}
w_download_manual()
{
_W_packagename="$1"
_W_url="$2"
_W_file="$3"
_W_sha1sum="$4"
case $LANG in
da*) _W_dlmsg="Hent venligst filen $_W_file fra $_W_url og placér den i $W_CACHE/$_W_packagename, kør derefter dette skript.";;
de*) _W_dlmsg="Bitte laden Sie $_W_file von $_W_url runter, stellen Sie's in $W_CACHE/$_W_packagename, dann wiederholen Sie diesen Kommando.";;
*) _W_dlmsg="Please download $_W_file from $_W_url, place it in $W_CACHE/$_W_packagename, then re-run this script.";;
esac
if ! test -f "$W_CACHE/$_W_packagename/$_W_file"
then
mkdir -p "$W_CACHE/$_W_packagename"
case "$OS" in
"Windows_NT") cygstart "$_W_url" ;;
*) xdg-open "$_W_url" ;;
esac
sleep 3 # give some time for browser to open
w_die "$_W_dlmsg"
# FIXME: wait in loop until file is finished?
fi
# FIXME: verify $sha1sum of $file
unset _W_url _W_file _W_sha1sum _W_dlmsg
}
# Usage: w_mount "volume name"
# FIXME: should take mount option 'unhide' for poorly mastered discs
w_mount()
{
WINETRICKS_IMG="$W_CACHE/$W_PACKAGE/$1.iso"
mkdir -p "$W_CACHE/$W_PACKAGE"
if test -f "$WINETRICKS_IMG"
then
winetricks_mount_cached_iso "$1"
else
case "$WINETRICKS_OPT_KEEPISOS" in
0)
winetricks_mount_real_volume "$1"
;;
1)
winetricks_cache_iso "$1"
winetricks_mount_cached_iso "$1"
;;
esac
fi
}
w_umount()
{
if test "$WINE" = ""
then
w_die Windows not yet supported
else
echo "Running $WINETRICKS_SUDO umount $W_ISO_MOUNT_ROOT"
case "$WINETRICKS_SUDO" in
gksudo)
# -l lazy unmount in case executable still running
$WINETRICKS_SUDO "umount -l $W_ISO_MOUNT_ROOT"
w_try $WINETRICKS_SUDO "rm -rf $W_ISO_MOUNT_ROOT"
;;
*)
$WINETRICKS_SUDO umount -l $W_ISO_MOUNT_ROOT
w_try $WINETRICKS_SUDO rm -rf $W_ISO_MOUNT_ROOT
;;
esac
rm -f "$WINEPREFIX"/dosdevices/${W_ISO_MOUNT_LETTER}:
rm -f "$WINEPREFIX"/dosdevices/${W_ISO_MOUNT_LETTER}::
fi
}
w_ahk_do()
{
if ! test -f "$W_CACHE/ahk/AutoHotkey.exe"
then
w_download ahk http://www.autohotkey.com/download/AutoHotkey104805.zip b3981b13fbc45823131f69d125992d6330212f27
w_try_unzip -d "$W_CACHE/ahk" "$W_CACHE/ahk/AutoHotkey104805.zip" AutoHotkey.exe AU3_Spy.exe
chmod +x "$W_CACHE/ahk/AutoHotkey.exe"
fi
_W_CR=`printf \\\\r`
echo "$@" | sed "s/\$/$CR/" > "$W_TMP"/tmp.ahk
$WINE "$W_CACHE_WIN/ahk/AutoHotkey.exe" "$W_TMP_WIN"\\tmp.ahk
unset _W_CR
}
# Function to protect wine-specific sections of code.
# Outputs a message to console explaining what's being skipped.
# Usage:
# if w_skip_windows name-of-operation
# then
# return
# fi
# ... do something that doesn't make sense on windows ...
w_skip_windows()
{
case "$OS" in
"Windows_NT")
echo "Skipping operation '$1' on Windows"
return 0
;;
esac
return 1
}
w_override_dlls()
{
w_skip_windows w_override_dlls && return
_W_mode=$1
if [ $_W_mode = "disabled" ]
then
_W_mode=""
fi
shift
echo Using $_W_mode override for following DLLs: $@
cat > "$W_TMP"/override-dll.reg <<_EOF_
REGEDIT4
[HKEY_CURRENT_USER\Software\Wine\DllOverrides]
_EOF_
while test "$1" != ""
do
case "$1" in
comctl32)
rm -rf "$W_WINDIR_UNIX"/winsxs/manifests/x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.2600.2982_none_deadbeef.manifest
;;
esac
# Note: if you want to override even DLLs loaded with an absolute path,
# you need to add an asterisk:
echo "\"*$1\"=\"$_W_mode\"" >> "$W_TMP"/override-dll.reg
#echo "\"$1\"=\"$_W_mode\"" >> "$W_TMP"/override-dll.reg
shift
done
w_try_regedit "$W_TMP_WIN"\\override-dll.reg
unset _W_mode
}
w_override_no_dlls()
{
w_skip_windows override && return
$WINE regedit /d 'HKEY_CURRENT_USER\Software\Wine\DllOverrides'
}
w_override_all_dlls()
{
# Disable all but the commonly used DLLs Wine doesn't have a credible alternative for
# i.e. Don't disallow msvcp80 or d3dx9_* for now
# d3dx9_24.dll d3dx9_25.dll d3dx9_26.dll d3dx9_27.dll d3dx9_28.dll d3dx9_29.dll d3dx9_30.dll d3dx9_31.dll d3dx9_32.dll d3dx9_33.dll d3dx9_34.dll d3dx9_35.dll d3dx9_36.dll d3dx9_37.dll d3dx9_38.dll d3dx9_39.dll d3dx9_40.dll d3dx9_41.dll d3dx9_42.dll d3dxof.dll
w_override_dlls builtin \
acledit aclui activeds actxprxy advapi32 advpack amstream atl authz avicap32 \
avifil32 avifilebavrt bcrypt browseui cabinet capi2032 cards cfgmgr32 clusapi \
comcat comctl32 comdlg32 commdlg compobj compstui credui crtdll crypt32 cryptdlg \
cryptdll cryptnet cryptui ctapi32 ctl3d ctl3d32 ctl3dv2 d3d10 \
d3d10core d3d8 d3d9 d3dim d3drm \
d3dxof dbghelp dciman32 ddeml ddraw ddrawex \
devenum dinput dinput8 dispdib dispex dmband dmcompos dmime dmloader dmscript \
dmstyle dmsynth dmusic dmusic32 dnsapi dplay dplayx dpnaddr dpnet dpnhpast \
dpnlobby dpwsockx drmclien dsound dssenh dswave dwmapi dxdiagn dxgi faultrep \
fltlib fusion fwpuclnt gdi32 gdiplus glu32 gpkcsp hal hid hlink \
hnetcfg httpapi iccvid icmp imagehlp imm imm32 inetcomm inetmib1 infosoft \
initpki inkobj inseng iphlpapi itircl itss jscript kernel32 loadperf localspl \
localui lz32 lzexpand mapi32 mapistub mciavi32 mcicda mciqtz32 mciseq mciwave \
midimap mlang mmdevapi mmsystem mpr mprapi msacm msacm32 mscat32 mscms \
mscoree msctf msdaps msdmo msftedit mshtml msi msimg32 msimtf msisip \
msnet32 msrle32 mssign32 mssip32 mstask msvcirt msvcr70 msvcr71 msvcr80 \
msvcr90 msvcrt msvcrt20 msvcrt40 msvcrtd msvfw32 msvidc32 msvideo mswsock msxml3 \
msxml4 nddeapi netapi32 newdev ntdll ntdsapi ntprint objsel odbc32 odbccp32 \
ole2 ole2conv ole2disp ole2nls ole2prox ole2thk ole32 oleacc oleaut32 olecli \
olecli32 oledb32 oledlg olepro32 olesvr olesvr32 olethk32 openal32 opengl32 pdh \
pidgen powrprof printui propsys psapi pstorec qcap qedit qmgr qmgrprxy \
quartz query rasapi16 rasapi32 rasdlg resutils riched20 riched32 rpcrt4 rsabase \
rsaenh rtutils sccbase schannel secur32 security sensapi serialui setupapi setupx \
sfc sfc_os shdoclc shdocvw shell shell32 shfolder shlwapi slbcsp slc \
snmpapi softpub spoolss sti storage stress svrapi sxs t2embed tapi32 \
toolhelp traffic twain twain_32 typelib unicows updspapi url urlmon user32 \
userenv usp10 uxtheme vdmdbg ver version w32skrnl w32sys wbemprox wiaservc \
win32s16 win87em winaspi windebug windowscodecs wined3d winedos winemapi wing wing32 \
winhttp wininet winmm winnls winnls32 winscard winsock wintab wintab32 wintrust \
wldap32 wmi wmiutils wnaspi32 wow32 ws2_32 wsock32 wtsapi32 wuapi wuaueng \
xinput1_1 xinput1_2 xinput1_3 xinput9_1_0 xmllite
}
w_override_app_dlls()
{
w_skip_windows w_override_app_dlls && return
_W_app=$1
shift
_W_mode=$1
shift
echo Using $_W_mode override for following DLLs when running $_W_app: $@
(
echo REGEDIT4
echo ""
echo "[HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\$app\\DllOverrides]"
) > "$W_TMP"/override-dll.reg
while test "$1" != ""
do
case "$1" in
comctl32)
rm -rf "$W_WINDIR_UNIX"/winsxs/manifests/x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.2600.2982_none_deadbeef.manifest
;;
esac
echo "\"$1\"=\"$_W_mode\"" >> "$W_TMP"/override-dll.reg
shift
done
w_try_regedit "$W_TMP_WIN"\\override-dll.reg
rm "$W_TMP"/override-dll.reg
unset _W_app _W_mode
}
# Has to be set in a few places...
w_set_winver()
{
w_skip_windows w_set_winver && return
# FIXME: This should really be done with winecfg, but it has no CLI options.
# First, delete any lingering version info, otherwise it may conflict:
(
$WINE reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion" /v SubVersionNumber /f || true
$WINE reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion" /v VersionNumber /f || true
$WINE reg delete "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v CSDVersion /f || true
$WINE reg delete "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber /f || true
$WINE reg delete "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion /f || true
$WINE reg delete "HKLM\System\CurrentControlSet\Control\ProductOptions" /v ProductType /f || true
$WINE reg delete "HKLM\System\CurrentControlSet\Control\ServiceCurrent" /v OS /f || true
$WINE reg delete "HKLM\System\CurrentControlSet\Control\Windows" /v CSDVersion /f || true
$WINE reg delete "HKCU\Software\Wine" /v Version /f || true
) > /dev/null 2>&1
case $1 in
win31)
echo "Setting Windows version to $1"
cat > "$W_TMP"/set-winver.reg <<_EOF_
REGEDIT4
[HKEY_USERS\S-1-5-4\Software\Wine]
"Version"="win31"
_EOF_
w_try_regedit "$W_TMP_WIN"\\set-winver.reg
return
;;
win98)
# This key is only used for win 95/98:
echo "Setting Windows version to $1"
cat > "$W_TMP"/set-winver.reg <<_EOF_
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
"SubVersionNumber"=" A "
"VersionNumber"="4.10.2222"
_EOF_
w_try_regedit "$W_TMP_WIN"\\set-winver.reg
return
;;
nt40)
# Similar to modern version, but sets two extra keys:
echo "Setting Windows version to $1"
cat > "$W_TMP"/set-winver.reg <<_EOF_
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion]
"CSDVersion"="Service Pack 6a"
"CurrentBuildNumber"="1381"
"CurrentVersion"="4.0"
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ProductOptions]
"ProductType"="WinNT"
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ServiceCurrent]
"OS"="Windows_NT"
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Windows]
"CSDVersion"=dword:00000600
_EOF_
w_try_regedit "$W_TMP_WIN"\\set-winver.reg
return
;;
win2k)
csdversion="Service Pack 4"
currentbuildnumber="2195"
currentversion="5.0"
csdversion_hex=dword:00000400
;;
winxp)
csdversion="Service Pack 3"
currentbuildnumber="2600"
currentversion="5.1"
csdversion_hex=dword:00000300
;;
vista)
csdversion="Service Pack 2"
currentbuildnumber="6002"
currentversion="6.0"
csdversion_hex=dword:00000200
;;
win7)
csdversion="Service Pack 1"
currentbuildnumber="7601"
currentversion="6.1"
csdversion_hex=dword:00000100
;;
*)
die "Invalid Windows version given."
;;
esac
echo "Setting Windows version to $1"
cat > "$W_TMP"/set-winver.reg <<_EOF_
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion]
"CSDVersion"="$csdversion"
"CurrentBuildNumber"="$currentbuildnumber"
"CurrentVersion"="$currentversion"
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Windows]
"CSDVersion"=$csdversion_hex
_EOF_
w_try_regedit "$W_TMP_WIN"\\set-winver.reg
}
w_unset_winver()
{
w_set_winver winxp
}
# Present app $1 with the Windows personality $2
w_set_app_winver()
{
w_skip_windows w_set_app_winver && return
_W_app="$1"
_W_version="$2"
echo "Setting $_W_app to $_W_version mode"
(
echo REGEDIT4
echo ""
echo "[HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\$_W_app]"
echo "\"Version\"=\"$_W_version\""
) > "$W_TMP"/set-winver.reg
w_try_regedit "$W_TMP_WIN"\\set-winver.reg
rm "$W_TMP"/set-winver.reg
unset _W_app
}
# Usage: workaround_wine_bug bugnumber [good-wineversion-shell-pattern]
# False (nonzero status) on Windows.
# True (zero status) on Wine unless good-wineversion-shell-pattern is set
# and matches the current wine version.
# For debugging: if you want to skip a bug's workaround, put the bug number in the
# environment variable WINETRICKS_BLACKLIST to disable it.
w_workaround_wine_bug()
{
if test "$WINE" = ""
then
echo No need to work around wine bug $1 on windows
return 1
fi
# FIXME: accept wine version number as $2, only apply if before that
case $1 in
"$WINETRICKS_BLACKLIST")
echo wine bug $1 workaround blacklisted, skipping
return 1
;;
esac
case $LANG in
da*) w_warn "Arbejder uden om wine-fejl $1" ;;
de*) w_warn "Wine-Fehler $1 wird umgegangen" ;;
*) w_warn "Working around wine bug $1" ;;
esac
return 0
}
# Function for verbs to register themselves so they show up in the menu.
# Example:
# w_metadata wog games \
# title="World of Goo Demo" \
# pub="2D Boy" \
# year="2008" \
# media="download" \
# file1="WorldOfGooDemo.1.0.exe"
w_metadata()
{
if test "$installed_exe1" || test "$installed_file1" || test "$publisher" || test "$year"
then
w_die "bug: stray metadata tags set: somebody forgot a backslash in a w_metadata somewhere. Run with sh -x to see where."
fi
if winetricks_metadata_exists $1
then
w_die "bug: a verb named $1 already exists."
fi
_W_md_cmd="$1"
file="$WINETRICKS_METADATA/$2/$1.vars"
shift
shift
# Echo arguments to file, with double quotes around the values.
# Used to use perl here, but that was too slow on cygwin.
for arg
do
# Use longest match when stripping value,
# and shortest match when stripping name,
# so descriptions can have embedded equals signs
# FIXME: backslashes get interpreted here. This screws up
# installed_file1 fairly often. Fortunately, we can use forward
# slashes in that variable instead of backslashes.
echo ${arg%%=*}=\"${arg#*=}\"
done > "$file"
# If the problem described above happens, you'd see errors like this:
# /tmp/w.dank.4650/metadata/dlls/comctl32.vars: 6: Syntax error: Unterminated quoted string
# so check for lines that aren't properly quoted.
# Do sanity check unless running on cygwin, where it's way too slow.
case "$OS" in
"Windows_NT")
;;
*)
if grep '[^"]$' "$file"
then
w_die "bug: w_metadata $_W_md_cmd corrupt, might need forward slashes?"
fi
;;
esac
unset _W_md_cmd
}
# Function for verbs to register their main executable.
# Example:
# w_declare_exe "$W_PROGRAMS_X86_WIN\\WorldOfGooDemo" WorldOfGoo.exe
w_declare_exe()
{
_W_dir="$1"
_W_exe="$2"
cat > "$W_DRIVE_C/run-$W_PACKAGE.bat" <<__EOF__
${W_PROGRAMS_DRIVE}:
cd "$_W_dir"
$_W_exe
__EOF__
unset _W_dir _W_exe
}
# Call a verb, don't let it affect environment
# Hope that subshell passes through exit status
# Usage: w_do_call foo [bar] (calls load_foo bar)
# Or: w_do_call foo=bar (also calls load_foo bar)
# Or: w_do_call foo (calls load_foo)
w_do_call()
{
(
case $1 in
*=*) arg=`echo $1 | sed 's/.*=//'`; cmd=`echo $1 | sed 's/=.*//'`;;
*) cmd=$1; arg=$2 ;;
esac
W_TMP="$W_DRIVE_C/windows/_temp/_$1"
W_TMP_WIN="C:\\windows\\_temp\\_$1"
rm -rf "$W_TMP"
mkdir -p "$W_TMP"
# Unset all known used metadata values, in case this is a nested call
unset installed_dll1 installed_exe1
if winetricks_metadata_exists $1
then
. "$WINETRICKS_METADATA"/*/$1.vars
elif winetricks_metadata_exists $cmd
then
. "$WINETRICKS_METADATA"/*/$cmd.vars
else
w_die "No such verb $1"
fi
# Don't install if already installed
if winetricks_is_installed $1
then
echo "$1 already installed, skipping"
return 0
fi
# We'd like to get rid of W_PACKAGE, but for now, just set it as late as possible.
W_PACKAGE=$1
load_$cmd $arg
# User-specific postinstall hook.
# Source it so the script can call w_download() if needed.
postfile="$WINETRICKS_POST/$1/$1-postinstall.sh"
if test -f "$postfile"
then
chmod +x "$postfile"
. "$postfile"
fi
# Clean up after this verb
rm -rf "$W_TMP"
)
# Kludge: some verbs are allowed to affect the environment
case $1 in
sandbox)
W_CACHE_WIN="`w_pathconv -w $W_CACHE | tr '\012' ' ' | sed 's/ $//'`"
;;
esac
}
# If you want to check exit status yourself, use w_do_call
w_call()
{
w_try w_do_call $@
}
w_register_font()
{
file=$1
shift
font=$1
case "$file" in
*.TTF|*.ttf) font="$font (TrueType)";;
esac
# Kludge: use _r to avoid \r expansion in w_try
cat > "$W_TMP"/_register-font.reg <<_EOF_