1 proc TkW
:autoconf
{outfile
} {
3 # This files scans the fstab, then creates a wine.conf file
4 # parsed to wineconf for further editings....
6 # MS DOS drives are sorted following the rules explained in tools/wineconf
9 global TMPLetter WINLetter SYSLetter
12 set OUTF
[open $outfile w
]
15 set err
[TkW
:readFStab
]
20 set TMP
[TkW
:SearchTmp
]
24 set Windows
[TkW
:FindWindows
]
25 set System
"$Windows/system"
26 set Windows
[TkW
:Unix2Dos
$Windows]
27 set System
[TkW
:Unix2Dos
$System]
29 puts $OUTF "\[Wine\]\nwindows=$Windows"
30 puts $OUTF "system=$System"
31 puts $OUTF "Temp=[TkW:Unix2Dos $TMP]"
32 puts $OUTF "Path= $Windows\;$System\;$PATH"
34 #Quick and dirty... I'm tired now!
35 #puts $OUTF "SymbolTableFile=[exec find / -name wine.sym -print]"
36 puts $OUTF "printer=on"
39 puts $OUTF "\[DllDefaults\]"
40 puts $OUTF "\;EXTRA_LD_LIBRARY_PATH=\$\{HOME\}/wine/cvs/lib"
42 puts $OUTF "\[DllPairs\]"
43 puts $OUTF "kernel = kernel32"
44 puts $OUTF "gdi = gdi32"
45 puts $OUTF "user = user32"
46 puts $OUTF "commdlg = comdlg32"
47 puts $OUTF "commctrl= comctl32"
48 puts $OUTF "ver = version"
49 puts $OUTF "shell = shell32"
50 puts $OUTF "lzexpand= lz32"
51 puts $OUTF "mmsystem= winmm"
52 puts $OUTF "msvideo = msvfw32"
53 puts $OUTF "winsock = wsock32"
56 puts $OUTF "\[DllOverrides\]"
57 puts $OUTF "kernel32, gdi32, user32 = builtin"
58 puts $OUTF "kernel, gdi, user = builtin"
59 puts $OUTF "toolhelp = builtin"
60 puts $OUTF "comdlg32, commdlg = elfdll, builtin, native"
61 puts $OUTF "version, ver = elfdll, builtin, native"
62 puts $OUTF "shell32, shell = builtin, native"
63 puts $OUTF "lz32, lzexpand = builtin, native"
64 puts $OUTF "commctrl, comctl32 = builtin, native"
65 puts $OUTF "sock32, winsock = builtin"
66 puts $OUTF "advapi32, crtdll, ntdll = builtin, native"
67 puts $OUTF "mpr, winspool = builtin, native"
68 puts $OUTF "ddraw, dinput, dsound = builtin, native"
69 puts $OUTF "winmm, mmsystem = builtin"
70 puts $OUTF "msvideo, msvfw32 = builtin, native"
71 puts $OUTF "w32skrnl = builtin"
72 puts $OUTF "wnaspi32, wow32 = builtin"
73 puts $OUTF "system, display, wprocs = builtin"
74 puts $OUTF "wineps = builtin"
77 puts $OUTF "\[options\]"
78 puts $OUTF "AllocSystemColors=100"
81 puts $OUTF "\[fonts\]"
82 puts $OUTF "Resolution = 96 "
83 puts $OUTF "Default = -adobe-times-"
86 puts $OUTF "\[serialports\]"
87 puts $OUTF "Com1=/dev/ttyS0"
88 puts $OUTF "Com2=/dev/ttyS1"
89 puts $OUTF "Com3=/dev/modem,38400"
90 puts $OUTF "Com4=/dev/modem"
93 puts $OUTF "\[parallelports\]"
94 puts $OUTF "Lpt1=/dev/lp0"
97 puts $OUTF "\[spooler\]"
98 puts $OUTF "LPT1:=|lpr"
99 puts $OUTF "LPT2:=|gs -sDEVICE=bj200 -sOutputFile=/tmp/fred -q -"
100 puts $OUTF "LPT3:=/dev/lp3"
103 puts $OUTF "\[ports\]"
104 puts $OUTF "\;read=0x779,0x379,0x280-0x2a0"
105 puts $OUTF "\;write=0x779,0x379,0x280-0x2a0"
109 puts $OUTF "Exclude=WM_SIZE"
110 puts $OUTF ";WM_TIMER"
113 puts $OUTF "\[Tweak.Layout\]"
114 puts $OUTF ";WineLook=xxx (supported styles are \'Win31\'(default),"
115 puts $OUTF ";\'Win95\', \'Win98\')"
116 puts $OUTF "WineLook=Win31"
119 puts $OUTF "\[programs\]"
120 puts $OUTF "Default=]"
121 puts $OUTF "Startup="
126 proc TkW
:readFStab
{} {
128 global AlternateFstab OK CANCEL
130 if {![file exist
/etc
/fstab
]} {
131 TkW
:GetFileName
$AlternateFstab $OK $CANCEL File
135 set FSTAB
"/etc/fstab"
137 if {![file readable
$FSTAB]} {TkW
:FStabError
2;return 1}
139 set FStab
[open /etc
/fstab
]
140 while {![eof $FStab]} {
143 set line
[string trim
$line]
144 if {[string range
$line 0 0] != "#" && $line != ""} {
146 switch [lindex $line 2] {
150 minix
{TkW
:addUnixDrive
$line}
151 ext2
{TkW
:addUnixDrive
$line}
152 xiafs
{TkW
:addUnixDrive
$line}
153 vfat
{TkW
:addDosDrive
$line}
154 msdos
{TkW
:addDosDrive msdos
}
155 hpfs
{TkW
:addDosDrive
$line}
156 iso9660
{TkW
:addCdRomDrive
$line}
157 nfs
{TkW
:addNetDrive
$line}
158 auto
{TkW
:addAutoDrive
$line}
159 default {TkW
:unknownDeviceType
$line}
166 proc TkW
:addRootDrives
{} {
168 global RootDrives1 RootDrives2 OK CANCEL WAIT lineroot ADD REMOVE
169 global NunixDrives UnixPath UnixDevice UnixLabel UnixType UnixSerial UnixFS
173 set drivelist
"$drivelist [glob -nocomplain /*]"
175 set excludes
"$exclude /boot /lost+found /lib /etc /var /sbin /initrd\
176 /cdrom /floppy /include /man /dev /proc /bin /mnt /tmp"
178 foreach i
$drivelist {
179 if {[file isdir
$i]} {
182 foreach k
$excludes {
187 if {$skip == 0} {set List
"$List$i "}
190 set List
[lsort $List]
193 set All
($n) $i;set n
[expr $n + 1]
195 set dev
[lindex $lineroot 0]
196 toplevel .rootDr
-background #ffffff
197 wm title .rootDr
"Wine Autoconfigurator"
198 label .rootDr.banner
-backgr #0000ff -foregr #ffffff \
199 -text "$RootDrives1$dev $RootDrives2" \
201 pack .rootDr.banner
-fill x
202 frame .rootDr.lists
-backgr #ffffff
203 pack .rootDr.lists
-padx 10 -pady 10
204 listbox .rootDr.lists.left
-width 20 -height 10
205 pack .rootDr.lists.left
-padx 10 -pady 0 -side left
207 frame .rootDr.lists.buttons
-backgr #ffffff
208 pack .rootDr.lists.buttons
-padx 10 -pady 0 -side left
210 button .rootDr.lists.buttons.add
-text "$ADD >>" -width 8\
211 -command {TkW
:AddRootDrInList
[.rootDr.lists.left cursel
]}
212 pack .rootDr.lists.buttons.add
-padx 10 -pady 0 -side top
214 button .rootDr.lists.buttons.space
-text "" -backgr #ffffff \
215 -border 0 -highlightb #ffffff -relief flat -width 8 -state disabled
216 pack .rootDr.lists.buttons.space
-padx 10 -pady 0 -side top
218 button .rootDr.lists.buttons.rem
-text "<< $REMOVE" -width 8\
219 -command {TkW
:RemRootDrInList
[.rootDr.lists.right cursel
]}
220 pack .rootDr.lists.buttons.rem
-padx 10 -pady 0 -side top
222 listbox .rootDr.lists.right
-width 20 -height 10
223 pack .rootDr.lists.right
-padx 10 -pady 0
225 frame .rootDr.cmd
-background #ffffff
226 pack .rootDr.cmd
-side bottom
-anchor c
-pady 5
228 button .rootDr.cmd.ok
-text OK
-width 8 \
229 -command {destroy .rootDr
;set WAIT
0}
230 pack .rootDr.cmd.ok
-side left
233 .rootDr.lists.left insert end
$i
236 global ToAddList
;set ToAddList
""
238 bind .rootDr.lists.left
<Double-ButtonPress-1
> {
239 TkW
:AddRootDrInList
[.rootDr.lists.left nearest
%y
]}
240 bind .rootDr.lists.right
<Double-ButtonPress-1
> {
241 TkW
:RemRootDrInList
[.rootDr.lists.right nearest
%y
]}
243 while {$WAIT == "wait" } {update}
244 foreach i
$ToAddList {
245 set NunixDrives
[expr $NunixDrives + 1]
246 set UnixPath
($NunixDrives) $i
247 set exclude
"$exclude$UnixPath($NunixDrives) "
248 set UnixLabel
($NunixDrives) $i
249 set UnixType
($NunixDrives) hd
250 set UnixFS
($NunixDrives) win95
254 proc TkW
:AddRootDrInList
{N
} {
256 global All ToAddList Nadd Add
257 if {![info exists All
($N)]} {return}
258 foreach i
$ToAddList {
259 if {$i == $All($N)} {return}
261 set ToAddList
[lsort "$ToAddList $All($N)"]
262 .rootDr.lists.right delete
0 end
264 foreach i
$ToAddList {
265 .rootDr.lists.right insert end
$i
267 set Nadd
[expr $Nadd + 1]
270 proc TkW
:RemRootDrInList
{N
} {
271 global All ToAddList Nadd Add
272 if {![info exists Add
($N)]} {return}
274 foreach i
$ToAddList {
275 if {$i != $Add($N)} {set NewList
"$NewList$i "}
277 set ToAddList
$NewList
279 .rootDr.lists.right delete
0 end
280 foreach i
$ToAddList {
281 .rootDr.lists.right insert end
$i
283 set Nadd
[expr $Nadd + 1]
286 proc TkW
:addUnixDrive
{line
} {
288 #pre-processing for the case of the root:
289 if {![file exists
[lindex $line 1]]} {return}
290 if {[lindex $line 1] != "/"} { TkW
:addUnixDriveOK
$line} {set lineroot
$line}
292 proc TkW
:addUnixDriveOK
{line
} {
294 # for now, I'll consider any unix file as ext2...
295 # may be this should improve a bit!
297 global NunixDrives UnixPath UnixDevice UnixLabel UnixType UnixSerial UnixFS
299 global TMPDRIVE HOMEDRIVE exclude
301 set NunixDrives
[expr $NunixDrives +1]
303 set UnixDevice
($NunixDrives) [lindex $line 0]
304 set UnixType
($NunixDrives) "hd"
305 set UnixPath
($NunixDrives) [lindex $line 1]
306 set exclude
"$exclude$UnixPath($NunixDrives) "
307 set UnixLabel
($NunixDrives) "UNIX $NunixDrives"
308 if {[string first
"/tmp" $UnixPath($NunixDrives)] > 0 && $TMPDRIVE == 0} {
309 set UnixLabel
($NunixDrives) "TEMP"
311 if {[string first
"/home" $UnixDevice($NunixDrives)] > 0 && $HOMEDRIVE == 0} {
312 set UnixLabel
($NunixDrives) "HOME"
314 set UnixDevice
($NunixDrives) ""
315 set UnixSerial
($NunixDrives) ""
316 set UnixFS
($NunixDrives) "win95"
317 set UnixType
($NunixDrives) "hd"
319 proc TkW
:addDosDrive
{line
} {
321 # for now, I'll consider any dos file as ext2...
322 # may be this should improve a bit!
324 global NdosDrives DosPath DosDevice DosLabel DosType DosSerial DosFS
326 global TMPDRIVE HOMEDRIVE exclude
328 if {![file exists
[lindex $line 1]]} {return}
330 if { [string first
"/dev/fd" [lindex $line 0]] == 0 } {
335 set NdosDrives
[expr $NdosDrives +1]
337 set DosDevice
($NdosDrives) [lindex $line 0]
338 set DosPath
($NdosDrives) [lindex $line 1]
339 set exclude
"$exclude$DosPath($NdosDrives) "
340 set DosLabel
($NdosDrives) ""
341 set DosType
($NdosDrives) "win95"
342 if {[lindex $line 2] == "msods"} {
343 set DosFS
($NdosDrives)
345 set DosFS
($NdosDrives) "win95"
347 set DosSerial
($NdosDrives) ""
350 proc TkW
:unknownDeviceType
{line
} {
352 TkW
:message "Error\n\
353 [lindex $line 0] (mounted on [lindex $line 1]) : Unknown device type. Please, mail thirot@univ-brest.fr for me to add this filesystem to the list of detected FS.\n\
355 \n Jean-Louis Thirot"
358 while {$WAIT == "wait"} {update}
362 proc TkW
:InitNewConfig
{} {
364 global NunixDrives UnixPath UnixDevice UnixLabel UnixType UnixSerial UnixFS
365 global NdosDrives DosPath DosDevice DosLabel DosType DosSerial DosFS
366 global Ncdroms CDPath CDDevice CDLabel CDType CDSerial CDFS
367 global Nfloppys FLOPPYPath FLOPPYDevice FLOPPYLabel FLOPPYType FLOPPYSerial FLOPPYFS
369 global TMPDRIVE HOMEDRIVE
370 global exclude
; set exclude
""
382 proc TkW
:ShowDrives
{} {
384 global NunixDrives UnixPath UnixDevice UnixLabel UnixType UnixSerial UnixFS
385 global NdosDrives DosPath DosDevice DosLabel DosType DosSerial DosFS
386 global Ncdroms CDPath CDDevice CDLabel CDType CDSerial CDFS
387 global NnetDrives NetPath NetLabel
388 global Nfloppys FLOPPYPath
389 global DriveRank DRIVEUNIXPATH DRIVEDOSPATH NDRIVES
393 set letters
{let
: C D E F G H I J K L M N O P Q R S T U V W X Y Z
}
394 set lettersF
{let
: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
}
395 for {set i
1} {$i <= $NdosDrives} {set i
[expr $i + 1]} {
396 set NDRIVES
[expr $NDRIVES + 1]
397 set rank
$DriveRank($i)
398 puts $OUTF "\[Drive [lindex $letters $i]\]"
399 set Letter
($NDRIVES) [lindex $letters $i]
400 set DRIVEUNIXPATH
($NDRIVES) $DosPath($rank)
401 set DRIVEDOSPATH
($NDRIVES) "[lindex $letters $i]:\\"
402 puts $OUTF "Path=$DosPath($rank)"
404 puts $OUTF "Label=MS-DOS $rank"
405 puts $OUTF "Filesystem=$DosFS($rank)"
408 for {set i
1} {$i <= $Nfloppys} {set i
[expr $i + 1]} {
410 set NDRIVES
[expr $NDRIVES + 1]
412 set DRIVEDOSPATH
($NDRIVES) "[lindex $lettersF $NLet]:\\"
413 set DRIVEUNIXPATH
($NDRIVES) $FLOPPYPath($i)
416 #set DRIVEDOSPATH($i) "[lindex $lettersF $NLet]:\\"
417 #set DRIVEUNIXPATH($i) $FLOPPYPath($i)
419 puts $OUTF "\[Drive [lindex $lettersF $NLet]\]"
420 puts $OUTF "Path=$FLOPPYPath($i)"
421 puts $OUTF "Type=floppy"
422 puts $OUTF "Label=Floppy $i"
423 puts $OUTF "Serial=87654321"
426 for {set i
1} {$i <= $Ncdroms} {set i
[expr $i + 1]} {
427 set NDRIVES
[expr $NDRIVES + 1]
428 puts $OUTF "\[Drive [lindex $letters $NDRIVES]\]"
429 puts $OUTF "Path=$CDPath($i)"
430 set DRIVEDOSPATH
($NDRIVES) "[lindex $letters $NDRIVES]:\\"
431 set DRIVEUNIXPATH
($NDRIVES) $CDPath($i)
432 puts $OUTF "Type=cdrom"
433 puts $OUTF "Label=CDROM $i"
434 puts $OUTF "Filesystem=$UnixFS($i)"
435 if {$CDDevice($i) != ""} {puts $OUTF "Device=$CDDevice($i)"}
438 for {set i
1} {$i <= $NunixDrives} {set i
[expr $i + 1]} {
439 set NDRIVES
[expr $NDRIVES + 1]
440 puts $OUTF "\[Drive [lindex $letters $NDRIVES]\]"
441 set DRIVEDOSPATH
($NDRIVES) "[lindex $letters $NDRIVES]:\\"
442 set DRIVEUNIXPATH
($NDRIVES) $UnixPath($i)
443 puts $OUTF "Path=$UnixPath($i)"
445 puts $OUTF "Label=$UnixLabel($i)"
446 puts $OUTF "Filesystem=$UnixFS($i)"
449 for {set i
1} {$i <= $NnetDrives} {set i
[expr $i + 1]} {
450 set NDRIVES
[expr $NDRIVES + 1]
451 puts $OUTF "\[Drive [lindex $letters $NDRIVES]\]"
452 set DRIVEDOSPATH
($NDRIVES) "[lindex $letters $NDRIVES]:\\"
453 set DRIVEUNIXPATH
($NDRIVES) $NetPath($i)
454 puts $OUTF "Path=$NetPath($i)"
455 puts $OUTF "Type=network"
456 puts $OUTF "Label=$NetLabel($i)"
457 puts $OUTF "Filesystem=win95"
462 proc TkW
:MiscEndConf
{temp
} {
464 #Create an acceptable PATH variable, and
465 # gets the TMP WINDOWS and SYSTEM drive letters:
466 global PATH NDRIVES Letter DRIVEPATH
469 for {set i
1} {$i<= $NDRIVES} {set i
[expr $i + 1]} {
470 if {[info exists Letter
($i)]} {
471 if {[info exists DRIVEPATH
($i)]} {
472 if {$DRIVEPATH($i) == $temp} {
473 set TMPLetter
$Letter($i)
475 set PATH
"$PATH\;$Letter($i):\\"
482 proc TkW
:Unix2Dos
{unixpath
} {
484 global NDRIVES DRIVEDOSPATH DRIVEUNIXPATH
488 # First, search the corresponding drive:
490 for {set i
1} {$i<=$NDRIVES} {set i
[expr $i + 1]} {
491 set n
[string first
$DRIVEUNIXPATH($i) $unixpath]
493 set dospath
$DRIVEDOSPATH($i)
494 set N
[expr [string length
$DRIVEUNIXPATH($i)] + 1]
499 # Now, add the remaining part of the path
501 for {set i
$N} {$i <= [string length
$unixpath]} {set i
[expr $i + 1]} {
503 set newchar
[string range
$unixpath $i $i]
504 if {$newchar != "/"} {
505 set dospath
"$dospath$newchar"
507 set dospath
"$dospath\\"
513 proc TkW
:addCdRomDrive
{line
} {
514 global Ncdroms CDPath CDDevice CDLabel CDType CDSerial CDFS
516 global IsCDwrite YES NO WAIT
518 if {![file exists
[lindex $line 1]]} {return}
519 set Ncdroms
[expr $Ncdroms + 1]
520 set CDFS
($Ncdroms) "iso9660"
521 set CDPath
($Ncdroms) [lindex $line 1]
522 set dev
[lindex $line 0]
523 TkW
:message2
"Device $dev $IsCDwrite" $YES $NO
525 while {$WAIT == "wait"} {update}
526 if {$WAIT == "opt1"} {set CDDevice
($Ncdroms) $dev} {set CDDevice
($Ncdroms) ""}
527 set CDLabel
($Ncdroms) "CDrom"
529 proc TkW
:addNetDrive
{line
} {
530 global NnetDrives NetPath NetLabel
531 set NnetDrives
[expr $NnetDrives + 1]
532 set NetPath
($NnetDrives) [lindex $line 1]
533 set NetLabel
($NnetDrives) [file tail
$NetPath($NnetDrives)]
535 proc TkW
:addFloppy
{line
} {
536 global Nfloppys FLOPPYPath FLOPPYDevice FLOPPYLabel FLOPPYType FLOPPYSerial FLOPPYFS
537 if {![file exists
[lindex $line 1]]} {return}
538 set Nfloppys
[expr $Nfloppys + 1]
539 set FLOPPYPath
($Nfloppys) [lindex $line 1]
540 set FLOPPYDevice
($Nfloppys) [lindex $line 0]
543 proc TkW
:SortDosDrives
{} {
544 global NdosDrives DosDevice DriveRank
547 for {set i
1} {$i <= $NdosDrives} {set i
[expr $i + 1]} {
548 set devlist
"$devlist $DosDevice($i):TKW:$i"
550 set devlist
[lsort $devlist]
553 foreach dev
$devlist {
554 set n1
[expr [string first
":TKW:" $dev] + 5]
555 set n2
[string length
$dev]
556 set DriveRank
([string range
$dev $n1 $n2]) $i
561 proc TkW
:SearchTmp
{} {
563 global NunixDrives UnixPath UnixLabel UnixType UnixFS
564 global NdosDrives DosPath DosLabel DosType DosFS
565 global WAITfilename GetFileName NDRIVES DRIVEUNIXPATH DRIVEDOSPATH
566 global WhereTmp OK CANCEL
568 # Check if it /tmp is alreaddy mounted (when it has it's own partition)
570 if {$i == "/tmp"} {return /tmp
}
572 # check that we have a /tmp:
573 if {[file exists
/tmp
] } {
574 set NunixDrives
[expr $NunixDrives + 1]
575 set UnixPath
($NunixDrives) /tmp
576 set exclude
"$exclude$UnixPath($NunixDrives) "
577 set UnixLabel
($NunixDrives) "TEMP"
578 set UnixType
($NunixDrives) hd
579 set UnixFS
($NunixDrives) win95
582 #Could add here a search for c:\TEMP or c:|windows\temp
583 set WAITfilename wait
584 TkW
:GetFileName
$WhereTmp $OK $CANCEL Folder
586 # check if this folder is on a drive that has an entry in
587 # wineconf (Must be a unix or dos drive)
588 for {set i
1} {$i<=$NdosDrives} {set i
[expr $i +1]} {
589 if {[string first
$DosPath($i) $GetFileName] == 0} {
593 for {set i
1} {$i<=$NunixDrives} {set i
[expr $i +1]} {
594 if {[string first
$UnixPath($i) $GetFileName] == 0} {
598 # I'll consider this new one as unix, althought if it's win fs that's ok
599 set NunixDrives
[expr $NunixDrives + 1]
600 set UnixPath
($NunixDrives) $GetFileName
601 set exclude
"$exclude$UnixPath($NunixDrives) "
602 set UnixLabel
($NunixDrives) "TEMP"
603 set UnixType
($NunixDrives) hd
604 set UnixFS
($NunixDrives) win95
609 proc TkW
:FindWindows
{} {
611 global NdosDrives DosPath WINLetter SYSLetter Letter
613 #first attempt: C:\windows (would avoid to search)
615 if {[file exist
$DosPath(1)/windows
]} {
616 return "$DosPath(1)/windows"
619 for {set i
1} {$i<=$NdosDrives} {set i
[expr $i + 1]} {
620 set searchWin
[open "| find $DosPath($i) -name win.ini -print" r
+]
621 while {![eof $searchWin]} {
622 gets $searchWin Found
624 set Found
[file dirname
$Found]