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 = "Use chmod as root to fix it (\"man chmod\")";
50 my $advice_fs = "The Filesystem option indicates the filesystem behaviour Wine is supposed to *emulate*, not the filesystem which is there";
56 select(STDERR); $| = 1; # make unbuffered
57 select(STDOUT); $| = 1; # make unbuffered
59 #--------------------------------- main program --------------------------------
65 &Check_WindowsFiles();
68 #------------------------------- support functions -----------------------------
71 my $len = length($str);
72 my $num = int((80 - $len - 2)/2);
76 for ($i = 0; $i < $num; $i++) {
80 for ($i = 0; $i < $num; $i++) {
96 $test_no = sprintf("%03d", $count_tests);
97 for (my $i = 0; $i < $indent; $i++)
99 $indent_str = $indent_str." ";
101 print sprintf("%.60s", $test_no.".".$indent_str." Checking ".$text."... ");
105 my($level, $str, $advice, $skip_score) = @_;
109 if ($level == $is_notchecked)
111 $err = "NOT CHECKED";
115 elsif ($level == $is_ok)
122 elsif ($level == $is_suspect)
128 $correctness *= $factor_suspect;
131 elsif ($level == $is_bad)
137 $correctness *= $factor_bad;
140 elsif ($level == $is_critical)
146 $correctness *= $factor_critical;
149 elsif ($level == $is_failed)
155 $correctness *= $factor_failed;
166 print " Press Enter.";
175 print "- ADVICE: ".$advice.".\n";
179 #-------------------------------- main functions ------------------------------
181 print "This script verifies the configuration of the whole Wine environment.\n";
182 print "Note that this is an ALPHA version, and thus it doesn't catch all problems !\n";
183 print "The results of the checks are printed on the right side:\n";
184 print "OK - test passed without problems.\n";
185 print "SUSPICIOUS - potentially problematic. You might want to look into that.\n";
186 print "BAD - This is a problem, and it leads to configuration score penalty.\n";
187 print "CRITICAL - A critical problem which can easily lead to malfunction.\n";
188 print "FAILED - This problem leads to Wine failure almost certainly.\n";
189 print "\nThe result will be printed as a percentage score indicating config completeness.\n";
194 print "Press Enter to continue or Ctrl-C to exit.";
199 sub Check_BaseFiles {
202 Do_PrintHeader("checking Wine base files");
205 Do_Check("for file \"wine\"");
206 $line = `which wine`;
210 $reason = "file not found";
211 $advice = "Make sure the \"wine\" command is in your PATH (echo \$PATH; export PATH=xxx)";
213 Do_PrintResult($level, $reason, $advice);
215 # check for config mess
218 Do_Check("for correct .so lib config (please wait)");
219 push (@output, `find / -name libwine.so 2>/dev/null`);
222 $level = $is_suspect;
224 foreach $line (@output) {
226 $dirs = $dirs." ".$line;
228 $reason = "libwine.so found ".@output." times:".$dirs;
229 $advice = "check whether this is really ok";
231 Do_PrintResult($level, $reason, $advice);
234 sub Do_Config_Drive {
235 my ($drive, $entries, $values) = @_;
246 my $my_advice_fat = "If that doesn't help, change mount options in case of VFAT (\"umask\" option)";
248 print "\n>>> Checking drive ".$drive." settings:\n";
250 while (@$entries[$index])
252 $arg = @$values[$index];
253 SWITCH: for (@$entries[$index]) {
254 /^path$/i && do { $path = $arg; last; };
255 /^type$/i && do { $type = $arg; last; };
256 /^label$/i && do { $label = $arg; last; };
257 /^serial$/i && do { $serial = $arg; last; };
258 /^device$/i && do { $device = $arg; last; };
259 /^filesystem$/i && do { $fs = $arg; last; };
260 $unknown = @$entries[$index];
267 my $serious = ($drive =~ /^C$/i) || ($type =~ /^cdrom$/i);
269 ##### check Path #####
270 Do_Check("Path option");
272 $advice = "The syntax of the Path option has to be something like /my/mount/point";
275 $level = $serious ? $is_failed : $is_bad;
276 $reason = "no Path option given in config file";
278 elsif ($path =~ /\\/)
280 $level = $serious ? $is_failed : $is_bad;
281 $reason = "wrong Path format ".$path;
283 elsif ($path =~ /\$\{(.*)\}$/)
285 # get path assigned to environment variable
286 my $envpath = $ENV{$1};
289 $level = $serious ? $is_failed : $is_critical;
290 $reason = "Path \"".$path."\" references environment variable \"".$1."\" which is undefined";
291 $advice = "set environment variable before starting Wine or give a \"real\" directory instead";
296 goto PERMCHECK; # hmpf
304 $level = $serious ? $is_failed : $is_suspect;
305 $reason = $path." does not exist !";
306 $advice = "create this directory or point Path to a real directory";
310 $level = $serious ? $is_failed : $is_bad;
311 $reason = $path." is not readable for you";
312 $advice = $advice_chmod.". ".$my_advice_fat;
314 elsif ((! ($type =~ /^cdrom$/i)) && (!-w $path))
316 $level = ($drive =~ /^C$/i) ? $is_failed : $is_suspect;
317 $reason = $path." is not writable for you";
318 $advice = $advice_chmod.". ".$my_advice_fat;
320 else # check permissions of the drive's directories
323 push (@output, `find $path 2>&1 1>/dev/null`);
324 foreach my $line (@output) {
325 if ($line =~ /find:\ (.*):\ Permission denied$/)
327 $level = ($drive =~ /^C$/i) ? $is_critical : $is_suspect;
328 $reason = "directory $1 is not accessible for you";
329 $advice = $advice_chmod.". ".$my_advice_fat;
335 Do_PrintResult($level, $reason, $advice);
337 ##### check Type #####
340 Do_Check("Type option");
342 SWITCH: for ($type) {
343 /^floppy$/i && do { last; };
344 /^hd$/i && do { last; };
345 /^network$/i && do { last; };
349 $level = $is_critical;
350 $reason = "no Device option found -> CD-ROM labels can''t be read";
351 $advice = "add Device option and make sure the device given is accessible by you";
355 /^ramdisk$/i && do { last; };
359 $reason = "invalid Type setting ".$type;
360 $advice = "use one of \"floppy\", \"hd\", \"network\" or \"cdrom\"";
363 Do_PrintResult($level, $reason, $advice);
366 ##### FIXME: check Label and Serial here #####
368 ##### check Device #####
371 my $mode = ($type =~ /^cdrom$/i) ? $dev_read : $dev_read|$dev_write;
372 &Do_CheckDevice("device", $device, 1, $mode);
375 ##### check Filesystem #####
378 Do_Check("Filesystem option");
381 /^(dos|fat|msdos|unix)$/i && do {
383 $reason = "You probably don't want to use \"".$fs."\". ".$advice_fs;
384 if ($fs =~ /^unix$/i)
386 $advice = "This should almost never be used";
390 $advice = "only use ".$fs." if you only have a crappy 8.3 filename (i.e.: non-LFN) DOS FAT kernel filesystem driver";
394 /^vfat$/i && do { last; };
395 /^win95$/i && do { last; };
399 $reason = "invalid Filesystem setting ".$type;
400 $advice = "use one of \"win95\", \"msdos\" or \"unix\"";
403 Do_PrintResult($level, $reason, $advice);
407 print "--> PROBLEM.\n";
419 my (@entries, @values);
420 LINE: while (<$file>)
423 next LINE if ($line =~ /[\ ]*[;#]/); # skip comments
425 #print "line: ".$line."\n";
426 if ($line =~ /\[(.*)\]/) # end of section/next section ?
428 my $nextsection = $1;
430 SWITCH: for ($section) {
431 /Drive\ (.)/i && do { &Do_Config_Drive($1, \@entries, \@values); last; };
437 $section = $found ? $nextsection : "";
438 @entries = (); @values = ();
441 if ($line =~ /^[\ \t]*\"(.*)\"[\ \t]*\=[\ \t]*\"(.*)\"/)
449 sub Check_ConfigFile {
450 my $config = "$ENV{'HOME'}/.wine/config";
453 Do_PrintHeader("checking config file");
455 Do_Check("config file access");
456 open(CFGFILE, $config);
460 $reason = $config." does not exist";
461 $advice = "it is ok in case you have ~/.winerc. If you don''t, then you''re in trouble !";
463 elsif (!-r $config) {
464 $reason = $config." not readable";
465 $advice = $advice_chmod;
467 Do_PrintResult($is_failed, $reason, $advice);
472 Do_PrintResult($is_failed, $config." not writable", "wineserver needs to be able to write to config file. ".$advice_chmod);
476 Do_PrintResult($is_ok);
478 Do_Config_Main(\*CFGFILE);
483 my($descr, $dev, $output, $mode) = @_;
489 $mode = $dev_read|$dev_write|$dev_open;
491 ($output != -1) && Do_Check($descr." ".$dev);
493 my $err_level = ($output == 1) ? $is_critical : $is_bad;
498 $reason = $dev." does not exist";
499 $advice = "use MAKEDEV script to create it";
502 if (($mode & $dev_read) && (!-r $dev))
505 $reason = $dev." is not readable for you";
506 $advice = $advice_chmod;
509 if (($mode & $dev_write) && (!-w $dev))
512 $reason = $dev." is not writable for you";
513 $advice = $advice_chmod;
516 if (($mode & $dev_open) && (!open(DEVICE, ">$dev")))
519 $reason = "no kernel driver for ".$dev."?";
520 $advice = "module loading problems ? Read /usr/src/linux/Documentation/modules.txt";
526 ($output != -1) && Do_PrintResult($level, $reason, $advice);
530 # FIXME: check joystick and scsi devices !
531 my $dev_sound = "/dev/dsp";
532 my $dev_mixer = "/dev/mixer";
533 my $dev_sequencer = "/dev/sequencer";
534 my $dev_mem = "/dev/mem";
536 Do_PrintHeader("checking system devices used by Wine");
537 &Do_CheckDevice("sound device", $dev_sound, 1);
538 &Do_CheckDevice("audio mixer device", $dev_mixer, 1);
539 &Do_CheckDevice("MIDI sequencer device", $dev_sequencer, 0);
544 my $regfile = $ENV{'HOME'}."/.wine/system.reg";
546 Do_PrintHeader("checking registry configuration");
548 Do_Check("availability of winedefault.reg entries");
549 push (@entries, `grep "SHAREDMEMLOCATION" $regfile`);
552 Do_PrintResult($is_ok);
556 Do_PrintResult($is_critical, "entry \"SHAREDMEMLOCATION\" not found", "file winedefault.reg doesn't seem to have been applied using regapi");
560 Do_Check("availability of windows registry entries");
561 # FIXME: use a different key for check if Wine adds this one to its
563 push (@entries, `grep "Default Taskbar" $regfile`);
566 Do_PrintResult($is_ok);
570 Do_PrintResult($is_critical, "entry \"Default Taskbar\" not found", "Windows registry does not seem to be added to Wine. 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.");
575 sub Check_WindowsFiles {
579 # my ($score_total, $score_reached, $score_percent);
581 # $score_total = $count_tests * 20;
582 # $score_reached = $count_ok * 20 +
584 # $count_critical * 5 +
586 # $score_percent = $score_reached * 100 / $score_total;
589 print $count_tests." tests. ".$count_suspect." suspicious, ".$count_bad." bad, ".$count_critical." critical, ".$count_failed." failed.\n";
590 print sprintf "Wine configuration correctness score: %2.2f%%\n", $correctness;