1 # Copyright 1999 Jean-Louis Thirot
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 proc TkW
:autoconf
{outfile
} {
20 # This files scans the fstab, then creates a wine.conf file
21 # parsed to wineconf for further editings....
23 # MS DOS drives are sorted following the rules explained in tools/wineconf
26 global TMPLetter WINLetter SYSLetter
29 set OUTF
[open $outfile w
]
32 set err
[TkW
:readFStab
]
37 set TMP
[TkW
:SearchTmp
]
41 set Windows
[TkW
:FindWindows
]
42 set System
"$Windows/system"
43 set Windows
[TkW
:Unix2Dos
$Windows]
44 set System
[TkW
:Unix2Dos
$System]
46 puts $OUTF "\[Wine\]\nwindows=$Windows"
47 puts $OUTF "system=$System"
48 puts $OUTF "Temp=[TkW:Unix2Dos $TMP]"
49 puts $OUTF "Path= $Windows\;$System\;$PATH"
51 #Quick and dirty... I'm tired now!
52 #puts $OUTF "SymbolTableFile=[exec find / -name wine.sym -print]"
53 puts $OUTF "printer=on"
56 puts $OUTF "\[DllDefaults\]"
57 puts $OUTF "\;EXTRA_LD_LIBRARY_PATH=\$\{HOME\}/wine/cvs/lib"
59 puts $OUTF "\[DllPairs\]"
60 puts $OUTF "kernel = kernel32"
61 puts $OUTF "gdi = gdi32"
62 puts $OUTF "user = user32"
63 puts $OUTF "commdlg = comdlg32"
64 puts $OUTF "commctrl= comctl32"
65 puts $OUTF "ver = version"
66 puts $OUTF "shell = shell32"
67 puts $OUTF "lzexpand= lz32"
68 puts $OUTF "mmsystem= winmm"
69 puts $OUTF "msvideo = msvfw32"
70 puts $OUTF "winsock = wsock32"
73 puts $OUTF "\[DllOverrides\]"
74 puts $OUTF "kernel32, gdi32, user32 = builtin"
75 puts $OUTF "kernel, gdi, user = builtin"
76 puts $OUTF "toolhelp = builtin"
77 puts $OUTF "comdlg32, commdlg = elfdll, builtin, native"
78 puts $OUTF "version, ver = elfdll, builtin, native"
79 puts $OUTF "shell32, shell = builtin, native"
80 puts $OUTF "lz32, lzexpand = builtin, native"
81 puts $OUTF "commctrl, comctl32 = builtin, native"
82 puts $OUTF "sock32, winsock = builtin"
83 puts $OUTF "advapi32, crtdll, ntdll = builtin, native"
84 puts $OUTF "mpr, winspool = builtin, native"
85 puts $OUTF "ddraw, dinput, dsound = builtin, native"
86 puts $OUTF "winmm, mmsystem = builtin"
87 puts $OUTF "msvideo, msvfw32 = builtin, native"
88 puts $OUTF "w32skrnl = builtin"
89 puts $OUTF "wnaspi32, wow32 = builtin"
90 puts $OUTF "system, display, wprocs = builtin"
91 puts $OUTF "wineps = builtin"
94 puts $OUTF "\[options\]"
95 puts $OUTF "AllocSystemColors=100"
98 puts $OUTF "\[fonts\]"
99 puts $OUTF "Resolution = 96 "
100 puts $OUTF "Default = -adobe-times-"
103 puts $OUTF "\[serialports\]"
104 puts $OUTF "Com1=/dev/ttyS0"
105 puts $OUTF "Com2=/dev/ttyS1"
106 puts $OUTF "Com3=/dev/modem,38400"
107 puts $OUTF "Com4=/dev/modem"
110 puts $OUTF "\[parallelports\]"
111 puts $OUTF "Lpt1=/dev/lp0"
114 puts $OUTF "\[spooler\]"
115 puts $OUTF "LPT1:=|lpr"
116 puts $OUTF "LPT2:=|gs -sDEVICE=bj200 -sOutputFile=/tmp/fred -q -"
117 puts $OUTF "LPT3:=/dev/lp3"
120 puts $OUTF "\[ports\]"
121 puts $OUTF "\;read=0x779,0x379,0x280-0x2a0"
122 puts $OUTF "\;write=0x779,0x379,0x280-0x2a0"
126 puts $OUTF "Exclude=WM_SIZE"
127 puts $OUTF ";WM_TIMER"
130 puts $OUTF "\[Tweak.Layout\]"
131 puts $OUTF ";WineLook=xxx (supported styles are \'Win31\'(default),"
132 puts $OUTF ";\'Win95\', \'Win98\')"
133 puts $OUTF "WineLook=Win31"
136 puts $OUTF "\[programs\]"
137 puts $OUTF "Default=]"
138 puts $OUTF "Startup="
143 proc TkW
:readFStab
{} {
145 global AlternateFstab OK CANCEL
147 if {![file exist
/etc
/fstab
]} {
148 TkW
:GetFileName
$AlternateFstab $OK $CANCEL File
152 set FSTAB
"/etc/fstab"
154 if {![file readable
$FSTAB]} {TkW
:FStabError
2;return 1}
156 set FStab
[open /etc
/fstab
]
157 while {![eof $FStab]} {
160 set line
[string trim
$line]
161 if {[string range
$line 0 0] != "#" && $line != ""} {
163 switch [lindex $line 2] {
167 minix
{TkW
:addUnixDrive
$line}
168 ext2
{TkW
:addUnixDrive
$line}
169 xiafs
{TkW
:addUnixDrive
$line}
170 vfat
{TkW
:addDosDrive
$line}
171 msdos
{TkW
:addDosDrive msdos
}
172 hpfs
{TkW
:addDosDrive
$line}
173 iso9660
{TkW
:addCdRomDrive
$line}
174 nfs
{TkW
:addNetDrive
$line}
175 auto
{TkW
:addAutoDrive
$line}
176 default {TkW
:unknownDeviceType
$line}
183 proc TkW
:addRootDrives
{} {
185 global RootDrives1 RootDrives2 OK CANCEL WAIT lineroot ADD REMOVE
186 global NunixDrives UnixPath UnixDevice UnixLabel UnixType UnixSerial UnixFS
190 set drivelist
"$drivelist [glob -nocomplain /*]"
192 set excludes
"$exclude /boot /lost+found /lib /etc /var /sbin /initrd\
193 /cdrom /floppy /include /man /dev /proc /bin /mnt /tmp"
195 foreach i
$drivelist {
196 if {[file isdir
$i]} {
199 foreach k
$excludes {
204 if {$skip == 0} {set List
"$List$i "}
207 set List
[lsort $List]
210 set All
($n) $i;set n
[expr $n + 1]
212 set dev
[lindex $lineroot 0]
213 toplevel .rootDr
-background #ffffff
214 wm title .rootDr
"Wine Autoconfigurator"
215 label .rootDr.banner
-backgr #0000ff -foregr #ffffff \
216 -text "$RootDrives1$dev $RootDrives2" \
218 pack .rootDr.banner
-fill x
219 frame .rootDr.lists
-backgr #ffffff
220 pack .rootDr.lists
-padx 10 -pady 10
221 listbox .rootDr.lists.left
-width 20 -height 10
222 pack .rootDr.lists.left
-padx 10 -pady 0 -side left
224 frame .rootDr.lists.buttons
-backgr #ffffff
225 pack .rootDr.lists.buttons
-padx 10 -pady 0 -side left
227 button .rootDr.lists.buttons.add
-text "$ADD >>" -width 8\
228 -command {TkW
:AddRootDrInList
[.rootDr.lists.left cursel
]}
229 pack .rootDr.lists.buttons.add
-padx 10 -pady 0 -side top
231 button .rootDr.lists.buttons.space
-text "" -backgr #ffffff \
232 -border 0 -highlightb #ffffff -relief flat -width 8 -state disabled
233 pack .rootDr.lists.buttons.space
-padx 10 -pady 0 -side top
235 button .rootDr.lists.buttons.rem
-text "<< $REMOVE" -width 8\
236 -command {TkW
:RemRootDrInList
[.rootDr.lists.right cursel
]}
237 pack .rootDr.lists.buttons.rem
-padx 10 -pady 0 -side top
239 listbox .rootDr.lists.right
-width 20 -height 10
240 pack .rootDr.lists.right
-padx 10 -pady 0
242 frame .rootDr.cmd
-background #ffffff
243 pack .rootDr.cmd
-side bottom
-anchor c
-pady 5
245 button .rootDr.cmd.ok
-text OK
-width 8 \
246 -command {destroy .rootDr
;set WAIT
0}
247 pack .rootDr.cmd.ok
-side left
250 .rootDr.lists.left insert end
$i
253 global ToAddList
;set ToAddList
""
255 bind .rootDr.lists.left
<Double-ButtonPress-1
> {
256 TkW
:AddRootDrInList
[.rootDr.lists.left nearest
%y
]}
257 bind .rootDr.lists.right
<Double-ButtonPress-1
> {
258 TkW
:RemRootDrInList
[.rootDr.lists.right nearest
%y
]}
260 while {$WAIT == "wait" } {update}
261 foreach i
$ToAddList {
262 set NunixDrives
[expr $NunixDrives + 1]
263 set UnixPath
($NunixDrives) $i
264 set exclude
"$exclude$UnixPath($NunixDrives) "
265 set UnixLabel
($NunixDrives) $i
266 set UnixType
($NunixDrives) hd
267 set UnixFS
($NunixDrives) win95
271 proc TkW
:AddRootDrInList
{N
} {
273 global All ToAddList Nadd Add
274 if {![info exists All
($N)]} {return}
275 foreach i
$ToAddList {
276 if {$i == $All($N)} {return}
278 set ToAddList
[lsort "$ToAddList $All($N)"]
279 .rootDr.lists.right delete
0 end
281 foreach i
$ToAddList {
282 .rootDr.lists.right insert end
$i
284 set Nadd
[expr $Nadd + 1]
287 proc TkW
:RemRootDrInList
{N
} {
288 global All ToAddList Nadd Add
289 if {![info exists Add
($N)]} {return}
291 foreach i
$ToAddList {
292 if {$i != $Add($N)} {set NewList
"$NewList$i "}
294 set ToAddList
$NewList
296 .rootDr.lists.right delete
0 end
297 foreach i
$ToAddList {
298 .rootDr.lists.right insert end
$i
300 set Nadd
[expr $Nadd + 1]
303 proc TkW
:addUnixDrive
{line
} {
305 #pre-processing for the case of the root:
306 if {![file exists
[lindex $line 1]]} {return}
307 if {[lindex $line 1] != "/"} { TkW
:addUnixDriveOK
$line} {set lineroot
$line}
309 proc TkW
:addUnixDriveOK
{line
} {
311 # for now, I'll consider any unix file as ext2...
312 # may be this should improve a bit!
314 global NunixDrives UnixPath UnixDevice UnixLabel UnixType UnixSerial UnixFS
316 global TMPDRIVE HOMEDRIVE exclude
318 set NunixDrives
[expr $NunixDrives +1]
320 set UnixDevice
($NunixDrives) [lindex $line 0]
321 set UnixType
($NunixDrives) "hd"
322 set UnixPath
($NunixDrives) [lindex $line 1]
323 set exclude
"$exclude$UnixPath($NunixDrives) "
324 set UnixLabel
($NunixDrives) "UNIX $NunixDrives"
325 if {[string first
"/tmp" $UnixPath($NunixDrives)] > 0 && $TMPDRIVE == 0} {
326 set UnixLabel
($NunixDrives) "TEMP"
328 if {[string first
"/home" $UnixDevice($NunixDrives)] > 0 && $HOMEDRIVE == 0} {
329 set UnixLabel
($NunixDrives) "HOME"
331 set UnixDevice
($NunixDrives) ""
332 set UnixSerial
($NunixDrives) ""
333 set UnixFS
($NunixDrives) "win95"
334 set UnixType
($NunixDrives) "hd"
336 proc TkW
:addDosDrive
{line
} {
338 # for now, I'll consider any dos file as ext2...
339 # may be this should improve a bit!
341 global NdosDrives DosPath DosDevice DosLabel DosType DosSerial DosFS
343 global TMPDRIVE HOMEDRIVE exclude
345 if {![file exists
[lindex $line 1]]} {return}
347 if { [string first
"/dev/fd" [lindex $line 0]] == 0 } {
352 set NdosDrives
[expr $NdosDrives +1]
354 set DosDevice
($NdosDrives) [lindex $line 0]
355 set DosPath
($NdosDrives) [lindex $line 1]
356 set exclude
"$exclude$DosPath($NdosDrives) "
357 set DosLabel
($NdosDrives) ""
358 set DosType
($NdosDrives) "win95"
359 if {[lindex $line 2] == "msods"} {
360 set DosFS
($NdosDrives)
362 set DosFS
($NdosDrives) "win95"
364 set DosSerial
($NdosDrives) ""
367 proc TkW
:unknownDeviceType
{line
} {
369 TkW
:message "Error\n\
370 [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\
372 \n Jean-Louis Thirot"
375 while {$WAIT == "wait"} {update}
379 proc TkW
:InitNewConfig
{} {
381 global NunixDrives UnixPath UnixDevice UnixLabel UnixType UnixSerial UnixFS
382 global NdosDrives DosPath DosDevice DosLabel DosType DosSerial DosFS
383 global Ncdroms CDPath CDDevice CDLabel CDType CDSerial CDFS
384 global Nfloppys FLOPPYPath FLOPPYDevice FLOPPYLabel FLOPPYType FLOPPYSerial FLOPPYFS
386 global TMPDRIVE HOMEDRIVE
387 global exclude
; set exclude
""
399 proc TkW
:ShowDrives
{} {
401 global NunixDrives UnixPath UnixDevice UnixLabel UnixType UnixSerial UnixFS
402 global NdosDrives DosPath DosDevice DosLabel DosType DosSerial DosFS
403 global Ncdroms CDPath CDDevice CDLabel CDType CDSerial CDFS
404 global NnetDrives NetPath NetLabel
405 global Nfloppys FLOPPYPath
406 global DriveRank DRIVEUNIXPATH DRIVEDOSPATH NDRIVES
410 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
}
411 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
}
412 for {set i
1} {$i <= $NdosDrives} {set i
[expr $i + 1]} {
413 set NDRIVES
[expr $NDRIVES + 1]
414 set rank
$DriveRank($i)
415 puts $OUTF "\[Drive [lindex $letters $i]\]"
416 set Letter
($NDRIVES) [lindex $letters $i]
417 set DRIVEUNIXPATH
($NDRIVES) $DosPath($rank)
418 set DRIVEDOSPATH
($NDRIVES) "[lindex $letters $i]:\\"
419 puts $OUTF "Path=$DosPath($rank)"
421 puts $OUTF "Label=MS-DOS $rank"
422 puts $OUTF "Filesystem=$DosFS($rank)"
425 for {set i
1} {$i <= $Nfloppys} {set i
[expr $i + 1]} {
427 set NDRIVES
[expr $NDRIVES + 1]
429 set DRIVEDOSPATH
($NDRIVES) "[lindex $lettersF $NLet]:\\"
430 set DRIVEUNIXPATH
($NDRIVES) $FLOPPYPath($i)
433 #set DRIVEDOSPATH($i) "[lindex $lettersF $NLet]:\\"
434 #set DRIVEUNIXPATH($i) $FLOPPYPath($i)
436 puts $OUTF "\[Drive [lindex $lettersF $NLet]\]"
437 puts $OUTF "Path=$FLOPPYPath($i)"
438 puts $OUTF "Type=floppy"
439 puts $OUTF "Label=Floppy $i"
440 puts $OUTF "Serial=87654321"
443 for {set i
1} {$i <= $Ncdroms} {set i
[expr $i + 1]} {
444 set NDRIVES
[expr $NDRIVES + 1]
445 puts $OUTF "\[Drive [lindex $letters $NDRIVES]\]"
446 puts $OUTF "Path=$CDPath($i)"
447 set DRIVEDOSPATH
($NDRIVES) "[lindex $letters $NDRIVES]:\\"
448 set DRIVEUNIXPATH
($NDRIVES) $CDPath($i)
449 puts $OUTF "Type=cdrom"
450 puts $OUTF "Label=CDROM $i"
451 puts $OUTF "Filesystem=$UnixFS($i)"
452 if {$CDDevice($i) != ""} {puts $OUTF "Device=$CDDevice($i)"}
455 for {set i
1} {$i <= $NunixDrives} {set i
[expr $i + 1]} {
456 set NDRIVES
[expr $NDRIVES + 1]
457 puts $OUTF "\[Drive [lindex $letters $NDRIVES]\]"
458 set DRIVEDOSPATH
($NDRIVES) "[lindex $letters $NDRIVES]:\\"
459 set DRIVEUNIXPATH
($NDRIVES) $UnixPath($i)
460 puts $OUTF "Path=$UnixPath($i)"
462 puts $OUTF "Label=$UnixLabel($i)"
463 puts $OUTF "Filesystem=$UnixFS($i)"
466 for {set i
1} {$i <= $NnetDrives} {set i
[expr $i + 1]} {
467 set NDRIVES
[expr $NDRIVES + 1]
468 puts $OUTF "\[Drive [lindex $letters $NDRIVES]\]"
469 set DRIVEDOSPATH
($NDRIVES) "[lindex $letters $NDRIVES]:\\"
470 set DRIVEUNIXPATH
($NDRIVES) $NetPath($i)
471 puts $OUTF "Path=$NetPath($i)"
472 puts $OUTF "Type=network"
473 puts $OUTF "Label=$NetLabel($i)"
474 puts $OUTF "Filesystem=win95"
479 proc TkW
:MiscEndConf
{temp
} {
481 #Create an acceptable PATH variable, and
482 # gets the TMP WINDOWS and SYSTEM drive letters:
483 global PATH NDRIVES Letter DRIVEPATH
486 for {set i
1} {$i<= $NDRIVES} {set i
[expr $i + 1]} {
487 if {[info exists Letter
($i)]} {
488 if {[info exists DRIVEPATH
($i)]} {
489 if {$DRIVEPATH($i) == $temp} {
490 set TMPLetter
$Letter($i)
492 set PATH
"$PATH\;$Letter($i):\\"
499 proc TkW
:Unix2Dos
{unixpath
} {
501 global NDRIVES DRIVEDOSPATH DRIVEUNIXPATH
505 # First, search the corresponding drive:
507 for {set i
1} {$i<=$NDRIVES} {set i
[expr $i + 1]} {
508 set n
[string first
$DRIVEUNIXPATH($i) $unixpath]
510 set dospath
$DRIVEDOSPATH($i)
511 set N
[expr [string length
$DRIVEUNIXPATH($i)] + 1]
516 # Now, add the remaining part of the path
518 for {set i
$N} {$i <= [string length
$unixpath]} {set i
[expr $i + 1]} {
520 set newchar
[string range
$unixpath $i $i]
521 if {$newchar != "/"} {
522 set dospath
"$dospath$newchar"
524 set dospath
"$dospath\\"
530 proc TkW
:addCdRomDrive
{line
} {
531 global Ncdroms CDPath CDDevice CDLabel CDType CDSerial CDFS
533 global IsCDwrite YES NO WAIT
535 if {![file exists
[lindex $line 1]]} {return}
536 set Ncdroms
[expr $Ncdroms + 1]
537 set CDFS
($Ncdroms) "iso9660"
538 set CDPath
($Ncdroms) [lindex $line 1]
539 set dev
[lindex $line 0]
540 TkW
:message2
"Device $dev $IsCDwrite" $YES $NO
542 while {$WAIT == "wait"} {update}
543 if {$WAIT == "opt1"} {set CDDevice
($Ncdroms) $dev} {set CDDevice
($Ncdroms) ""}
544 set CDLabel
($Ncdroms) "CDrom"
546 proc TkW
:addNetDrive
{line
} {
547 global NnetDrives NetPath NetLabel
548 set NnetDrives
[expr $NnetDrives + 1]
549 set NetPath
($NnetDrives) [lindex $line 1]
550 set NetLabel
($NnetDrives) [file tail
$NetPath($NnetDrives)]
552 proc TkW
:addFloppy
{line
} {
553 global Nfloppys FLOPPYPath FLOPPYDevice FLOPPYLabel FLOPPYType FLOPPYSerial FLOPPYFS
554 if {![file exists
[lindex $line 1]]} {return}
555 set Nfloppys
[expr $Nfloppys + 1]
556 set FLOPPYPath
($Nfloppys) [lindex $line 1]
557 set FLOPPYDevice
($Nfloppys) [lindex $line 0]
560 proc TkW
:SortDosDrives
{} {
561 global NdosDrives DosDevice DriveRank
564 for {set i
1} {$i <= $NdosDrives} {set i
[expr $i + 1]} {
565 set devlist
"$devlist $DosDevice($i):TKW:$i"
567 set devlist
[lsort $devlist]
570 foreach dev
$devlist {
571 set n1
[expr [string first
":TKW:" $dev] + 5]
572 set n2
[string length
$dev]
573 set DriveRank
([string range
$dev $n1 $n2]) $i
578 proc TkW
:SearchTmp
{} {
580 global NunixDrives UnixPath UnixLabel UnixType UnixFS
581 global NdosDrives DosPath DosLabel DosType DosFS
582 global WAITfilename GetFileName NDRIVES DRIVEUNIXPATH DRIVEDOSPATH
583 global WhereTmp OK CANCEL
585 # Check if it /tmp is alreaddy mounted (when it has it's own partition)
587 if {$i == "/tmp"} {return /tmp
}
589 # check that we have a /tmp:
590 if {[file exists
/tmp
] } {
591 set NunixDrives
[expr $NunixDrives + 1]
592 set UnixPath
($NunixDrives) /tmp
593 set exclude
"$exclude$UnixPath($NunixDrives) "
594 set UnixLabel
($NunixDrives) "TEMP"
595 set UnixType
($NunixDrives) hd
596 set UnixFS
($NunixDrives) win95
599 #Could add here a search for c:\TEMP or c:|windows\temp
600 set WAITfilename wait
601 TkW
:GetFileName
$WhereTmp $OK $CANCEL Folder
603 # check if this folder is on a drive that has an entry in
604 # wineconf (Must be a unix or dos drive)
605 for {set i
1} {$i<=$NdosDrives} {set i
[expr $i +1]} {
606 if {[string first
$DosPath($i) $GetFileName] == 0} {
610 for {set i
1} {$i<=$NunixDrives} {set i
[expr $i +1]} {
611 if {[string first
$UnixPath($i) $GetFileName] == 0} {
615 # I'll consider this new one as unix, althought if it's win fs that's ok
616 set NunixDrives
[expr $NunixDrives + 1]
617 set UnixPath
($NunixDrives) $GetFileName
618 set exclude
"$exclude$UnixPath($NunixDrives) "
619 set UnixLabel
($NunixDrives) "TEMP"
620 set UnixType
($NunixDrives) hd
621 set UnixFS
($NunixDrives) win95
626 proc TkW
:FindWindows
{} {
628 global NdosDrives DosPath WINLetter SYSLetter Letter
630 #first attempt: C:\windows (would avoid to search)
632 if {[file exist
$DosPath(1)/windows
]} {
633 return "$DosPath(1)/windows"
636 for {set i
1} {$i<=$NdosDrives} {set i
[expr $i + 1]} {
637 set searchWin
[open "| find $DosPath($i) -name win.ini -print" r
+]
638 while {![eof $searchWin]} {
639 gets $searchWin Found
641 set Found
[file dirname
$Found]