3 # This program checks the whole Wine environment configuration.
4 # (or that's at least what it's supposed to do once it's finished)
5 # (C) 2001 Andreas Mohr
6 # Redistributable under Wine License
9 # - implement cmdline arguments e.g. for confirmation keypress
10 # in case of a problem
13 # - implement it in a much more systematic way. This is a quick hack for now
14 # (like every Perl program ;-)
15 # And much more so since I'm NOT a Perl hacker
16 # - test/tweak on non-Linux systems
26 my $count_suspect = 0;
28 my $count_critical = 0;
31 my $is_notchecked = 0;
38 my $factor_suspect = 0.995;
39 my $factor_bad = 0.95;
40 my $factor_critical = 0.85;
41 my $factor_failed = 0.15;
43 my $correctness = 100.0;
47 my ($level, $reason, $advice);
49 my $advice_chmod = "If your user account is supposed to be able to access
50 it properly, use chmod as root to fix it (\"man chmod\")";
51 my $advice_fs = "The Filesystem option indicates the filesystem behaviour Wine is supposed to *emulate*, not the filesystem which is there";
57 select(STDERR
); $| = 1; # make unbuffered
58 select(STDOUT
); $| = 1; # make unbuffered
60 #--------------------------------- main program --------------------------------
66 &Check_WindowsFiles
();
69 #------------------------------- support functions -----------------------------
72 my $len = length($str);
73 my $num = int((80 - $len - 2)/2);
77 for ($i = 0; $i < $num; $i++) {
81 for ($i = 0; $i < $num; $i++) {
97 $test_no = sprintf("%03d", $count_tests);
98 for (my $i = 0; $i < $indent; $i++)
100 $indent_str = $indent_str." ";
102 print sprintf("%.60s", $test_no.".".$indent_str." Checking ".$text."... ");
106 my($level, $str, $advice, $skip_score) = @_;
110 if ($level == $is_notchecked)
112 $err = "NOT CHECKED";
116 elsif ($level == $is_ok)
123 elsif ($level == $is_suspect)
129 $correctness *= $factor_suspect;
132 elsif ($level == $is_bad)
138 $correctness *= $factor_bad;
141 elsif ($level == $is_critical)
147 $correctness *= $factor_critical;
150 elsif ($level == $is_failed)
156 $correctness *= $factor_failed;
167 print " Press Enter.";
176 print "- ADVICE: ".$advice.".\n";
180 #-------------------------------- main functions ------------------------------
182 print "This script verifies the configuration of the whole Wine environment.\n";
183 print "Note that this is an ALPHA version, and thus it doesn't catch all problems !\n";
184 print "The results of the checks are printed on the right side:\n";
185 print "OK - test passed without problems.\n";
186 print "SUSPICIOUS - potentially problematic. You might want to look into that.\n";
187 print "BAD - This is a problem, and it leads to configuration score penalty.\n";
188 print "CRITICAL - A critical problem which can easily lead to malfunction.\n";
189 print "FAILED - This problem leads to Wine failure almost certainly.\n";
190 print "\nThe result will be printed as a percentage score indicating config completeness.\n";
195 print "Press Enter to continue or Ctrl-C to exit.";
200 sub Check_BaseFiles
{
203 Do_PrintHeader
("checking Wine base files");
206 Do_Check
("for file \"wine\"");
207 $line = `which wine`;
211 $reason = "file not found";
212 $advice = "Make sure the \"wine\" command is in your PATH (echo \$PATH; export PATH=xxx)";
214 Do_PrintResult
($level, $reason, $advice);
216 # check for config mess
219 Do_Check
("for correct .so lib config (please wait)");
221 # Build list of library directories.
222 # First parse ld.so.conf to find system-wide lib directories.
224 open (LDCONF
, "</etc/ld.so.conf");
226 s/\#.*//; # eliminate comments
228 if (-d
$_) { push @dirlist, $_; }
231 # Next parse LD_LIBRARY_PATH to find user-specific lib dirs.
232 my (@ld_dirs) = split (/:/, $ENV{'LD_LIBRARY_PATH'});
234 foreach $dir (@ld_dirs) {
235 if (-d
$dir) { push @dirlist, $dir; }
238 # Now check for a libwine.so in each directory
239 foreach $dir (@dirlist) {
240 my ($target) = $dir . "/libwine.so";
241 if (-f
$target) { push @output, $target; }
243 print "DEBUG: found libwine: @output\n";
247 $level = $is_suspect;
249 foreach $line (@output) {
251 $dirs = $dirs." ".$line;
253 $reason = "libwine.so found ".@output." times:".$dirs;
254 $advice = "check whether this is really ok";
256 Do_PrintResult
($level, $reason, $advice);
259 sub Do_Config_Drive
{
260 my ($drive, $entries, $values) = @_;
271 my $my_advice_fat = "If that doesn't help, change mount options in case of VFAT (\"umask\" option)";
273 print "\n>>> Checking drive ".$drive." settings:\n";
275 while (@
$entries[$index])
277 $arg = @
$values[$index];
278 SWITCH
: for (@
$entries[$index]) {
279 /^path$/i && do { $path = $arg; last; };
280 /^type$/i && do { $type = $arg; last; };
281 /^label$/i && do { $label = $arg; last; };
282 /^serial$/i && do { $serial = $arg; last; };
283 /^device$/i && do { $device = $arg; last; };
284 /^filesystem$/i && do { $fs = $arg; last; };
285 $unknown = @
$entries[$index];
292 my $serious = ($drive =~ /^C$/i) || ($type =~ /^cdrom$/i);
294 ##### check Path #####
295 Do_Check
("Path option");
297 $advice = "The syntax of the Path option has to be something like /my/mount/point";
300 $level = $serious ?
$is_failed : $is_bad;
301 $reason = "no Path option given in config file";
303 elsif ($path =~ /\\/)
305 $level = $serious ?
$is_failed : $is_bad;
306 $reason = "wrong Path format ".$path;
308 elsif ($path =~ /\$\{(.*)\}$/)
310 # get path assigned to environment variable
311 my $envpath = $ENV{$1};
314 $level = $serious ?
$is_failed : $is_critical;
315 $reason = "Path \"".$path."\" references environment variable \"".$1."\" which is undefined";
316 $advice = "set environment variable before starting Wine or give a \"real\" directory instead";
321 goto PERMCHECK
; # hmpf
329 $level = $serious ?
$is_failed : $is_suspect;
330 $reason = $path." does not exist !";
331 $advice = "create this directory or point Path to a real directory";
335 $level = $serious ?
$is_failed : $is_bad;
336 $reason = $path." is not readable for you";
337 $advice = $advice_chmod.". ".$my_advice_fat;
339 elsif ((! ($type =~ /^cdrom$/i)) && (!-w
$path))
341 $level = ($drive =~ /^C$/i) ?
$is_failed : $is_suspect;
342 $reason = $path." is not writable for you";
343 $advice = $advice_chmod.". ".$my_advice_fat;
345 else # check permissions of the drive's directories
348 push (@output, `find $path 2>&1 1>/dev/null`);
349 foreach my $line (@output) {
350 if ($line =~ /find:\ (.*):\ Permission denied$/)
352 $level = ($drive =~ /^C$/i) ?
$is_critical : $is_suspect;
353 $reason = "directory $1 is not accessible for you";
354 $advice = $advice_chmod.". ".$my_advice_fat;
360 Do_PrintResult
($level, $reason, $advice);
362 ##### check Type #####
365 Do_Check
("Type option");
367 SWITCH
: for ($type) {
368 /^floppy$/i && do { last; };
369 /^hd$/i && do { last; };
370 /^network$/i && do { last; };
374 $level = $is_critical;
375 $reason = "no Device option found -> CD-ROM labels can''t be read";
376 $advice = "add Device option and make sure the device given is accessible by you";
380 /^ramdisk$/i && do { last; };
384 $reason = "invalid Type setting ".$type;
385 $advice = "use one of \"floppy\", \"hd\", \"network\" or \"cdrom\"";
388 Do_PrintResult
($level, $reason, $advice);
391 ##### FIXME: check Label and Serial here #####
393 ##### check Device #####
396 my $mode = ($type =~ /^cdrom$/i) ?
$dev_read : $dev_read|$dev_write;
397 &Do_CheckDevice
("device", $device, 1, $mode);
400 ##### check Filesystem #####
403 Do_Check
("Filesystem option");
406 /^(dos|fat|msdos|unix)$/i && do {
408 $reason = "You probably don't want to use \"".$fs."\". ".$advice_fs;
409 if ($fs =~ /^unix$/i)
411 $advice = "This should almost never be used";
415 $advice = "only use ".$fs." if you only have a crappy 8.3 filename (i.e.: non-LFN) DOS FAT kernel filesystem driver";
419 /^vfat$/i && do { last; };
420 /^win95$/i && do { last; };
424 $reason = "invalid Filesystem setting ".$type;
425 $advice = "use one of \"win95\", \"msdos\" or \"unix\"";
428 Do_PrintResult
($level, $reason, $advice);
432 print "--> PROBLEM.\n";
444 my (@entries, @values);
445 LINE
: while (<$file>)
448 next LINE
if ($line =~ /[\ ]*[;#]/); # skip comments
450 #print "line: ".$line."\n";
451 if ($line =~ /\[(.*)\]/) # end of section/next section ?
453 my $nextsection = $1;
455 SWITCH
: for ($section) {
456 /Drive\ (.)/i && do { &Do_Config_Drive
($1, \
@entries, \
@values); last; };
462 $section = $found ?
$nextsection : "";
463 @entries = (); @values = ();
466 if ($line =~ /^[\ \t]*\"(.*)\"[\ \t]*\=[\ \t]*\"(.*)\"/)
474 sub Check_ConfigFile
{
475 my $config = "$ENV{'HOME'}/.wine/config";
478 Do_PrintHeader
("checking config file");
480 Do_Check
("config file access");
481 open(CFGFILE
, $config);
485 $reason = $config." does not exist";
486 $advice = "it is ok in case you have ~/.winerc. If you don''t, then you''re in trouble !";
488 elsif (!-r
$config) {
489 $reason = $config." not readable";
490 $advice = $advice_chmod;
492 Do_PrintResult
($is_failed, $reason, $advice);
497 Do_PrintResult
($is_failed, $config." not writable", "wineserver needs to be able to write to config file. ".$advice_chmod);
501 Do_PrintResult
($is_ok);
503 Do_Config_Main
(\
*CFGFILE
);
508 my($descr, $dev, $output, $mode) = @_;
514 $mode = $dev_read|$dev_write|$dev_open;
516 ($output != -1) && Do_Check
($descr." ".$dev);
518 my $err_level = ($output == 1) ?
$is_critical : $is_bad;
523 $reason = $dev." does not exist";
524 $advice = "use MAKEDEV script to create it";
527 if (($mode & $dev_read) && (!-r
$dev))
530 $reason = $dev." is not readable for you";
531 $advice = $advice_chmod;
534 if (($mode & $dev_write) && (!-w
$dev))
537 $reason = $dev." is not writable for you";
538 $advice = $advice_chmod;
541 if (($mode & $dev_open) && (!open(DEVICE
, ">$dev")))
544 $reason = "no kernel driver for ".$dev."?";
545 $advice = "module loading problems ? Read /usr/src/linux/Documentation/modules.txt";
551 ($output != -1) && Do_PrintResult
($level, $reason, $advice);
555 # FIXME: check joystick and scsi devices !
556 my $dev_sound = "/dev/dsp";
557 my $dev_mixer = "/dev/mixer";
558 my $dev_sequencer = "/dev/sequencer";
559 my $dev_mem = "/dev/mem";
561 Do_PrintHeader
("checking system devices used by Wine");
562 &Do_CheckDevice
("sound device", $dev_sound, 1);
563 &Do_CheckDevice
("audio mixer device", $dev_mixer, 1);
564 &Do_CheckDevice
("MIDI sequencer device", $dev_sequencer, 0);
569 my $regfile = $ENV{'HOME'}."/.wine/system.reg";
571 Do_PrintHeader
("checking registry configuration");
573 Do_Check
("availability of winedefault.reg entries");
574 push (@entries, `grep "SHAREDMEMLOCATION" $regfile`);
577 Do_PrintResult
($is_ok);
581 Do_PrintResult
($is_critical, "entry \"SHAREDMEMLOCATION\" not found in system.reg registry file", "file winedefault.reg doesn't seem to have been applied using regapi");
585 Do_Check
("availability of windows registry entries");
586 # FIXME: use a different key for check if Wine adds this one to its
588 push (@entries, `grep "Default Taskbar" $regfile`);
591 Do_PrintResult
($is_ok);
595 Do_PrintResult
($is_critical, "entry \"Default Taskbar\" not found", "Windows registry does not seem to be added to Wine, as this typical Windows registry entry does not exist in Wine's registry. This can affect many newer programs. Original registry entries won't be available with a no-windows install, of course, so you'll have to live with that.");
600 sub Check_WindowsFiles
{
604 # my ($score_total, $score_reached, $score_percent);
606 # $score_total = $count_tests * 20;
607 # $score_reached = $count_ok * 20 +
609 # $count_critical * 5 +
611 # $score_percent = $score_reached * 100 / $score_total;
614 print $count_tests." tests. ".$count_suspect." suspicious, ".$count_bad." bad, ".$count_critical." critical, ".$count_failed." failed.\n";
615 print sprintf "Wine configuration correctness score: %2.2f%%\n", $correctness;