1997-03-05 09:22:35 +01:00
|
|
|
#!/usr/bin/perl -w
|
1996-08-24 20:26:35 +02:00
|
|
|
|
|
|
|
# This program generates wine.conf files on STDOUT.
|
2002-03-10 00:29:33 +01:00
|
|
|
# Copyright (C) 1996 Stephen Simmons
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# NOTES:
|
|
|
|
#
|
1996-08-24 20:26:35 +02:00
|
|
|
# This program examines the contents of the DOS filesystems and
|
|
|
|
# attempts to generate a sensible wine.conf file. This is output
|
|
|
|
# to STDOUT.
|
2001-04-20 20:36:05 +02:00
|
|
|
# It reads /etc/fstab to find mounting locations of the hard disk drives
|
1996-08-24 20:26:35 +02:00
|
|
|
# It uses the correct algorithm for ordering DOS drives, with the
|
|
|
|
# exception of the case of multiple drive controller types, where I don't
|
|
|
|
# know what DOS's algorithm is.
|
|
|
|
# It uses find to find all of the win.ini files on any DOS partition
|
|
|
|
# and sorts them by age to guess which is part of the active Windows
|
|
|
|
# installation.
|
|
|
|
# It reads the autoexec.bat file (if found) and records all variable
|
|
|
|
# settings. There are some inaccuracies in its determination.
|
|
|
|
# First, while variables are interpolated properly, no control
|
|
|
|
# structures are supported so calls and execs to other batch files are
|
|
|
|
# ignored, and all variable settings take effect regardless of whether
|
|
|
|
# they would in DOS (i,e., both if and else clauses are read).
|
|
|
|
# This is used to determine the path and temp directories. Duplicate
|
|
|
|
# path directories and path directories that don't exist are thrown
|
|
|
|
# out.
|
|
|
|
# On failing to find C:\AUTOEXEC.BAT, wineconf finds all executables
|
|
|
|
# in the windows directory and subdirectories, and generates an
|
|
|
|
# optimized path statement encompassing all the executables.
|
|
|
|
# Then it also looks for \TEMP and \TMP on all drives taking the first
|
|
|
|
# one it finds.
|
|
|
|
# wineconf doesn't support floppy drives, network drives, printers,
|
|
|
|
# and serial device configuration is hardcoded and not configured for
|
|
|
|
# the machine it runs on. Similarly, spy parameters are hard coded.
|
|
|
|
|
2001-02-12 02:19:43 +01:00
|
|
|
# It would make sense to incorporate much of the heuristic code in
|
1996-08-24 20:26:35 +02:00
|
|
|
# this program into a library to be shared with a dosemu configuration
|
|
|
|
# program, because it seems that at least some of the same stuff will
|
|
|
|
# be wanted. The program needs to be cleaned up still. A better tmp
|
|
|
|
# search algorithm could be written. A fast option is planned. Less
|
|
|
|
# Linux-dependence is desired. Should look for devices independent
|
|
|
|
# of /etc/fstab; then sanity checks on /etc/fstab can be performed.
|
|
|
|
|
|
|
|
use Getopt::Long;
|
|
|
|
use File::Basename;
|
1999-04-25 14:18:36 +02:00
|
|
|
use strict;
|
1996-08-24 20:26:35 +02:00
|
|
|
use Carp;
|
|
|
|
|
2000-10-29 19:04:09 +01:00
|
|
|
GetOptions('windir=s', 'sysdir=s', 'thorough', 'debug:s', 'inifile=s') || &Usage;
|
1996-08-24 20:26:35 +02:00
|
|
|
|
2001-02-12 02:19:43 +01:00
|
|
|
print "WINE REGISTRY Version 2\n";
|
|
|
|
print ";; All keys relative to \\\\Machine\\\\Software\\\\Wine\\\\Wine\\\\Config\n\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
&ReadFSTAB();
|
|
|
|
&FindWindowsDir();
|
|
|
|
&ReadAutoexecBat();
|
|
|
|
&StandardStuff();
|
|
|
|
|
|
|
|
sub Usage {
|
|
|
|
print "Usage: $0 <options>\n";
|
|
|
|
# print "-fstab <filename> Location of alternate fstab file\n";
|
|
|
|
print "-windir <filename> Location of windows dir in DOS space\n";
|
|
|
|
print "-thorough Do careful analysis (default)\n";
|
|
|
|
print "-sysdir <filename> Location of systems dir in DOS space\n";
|
2000-10-29 19:04:09 +01:00
|
|
|
print "-inifile <filename> Path to the wine.ini file (by default './wine.ini')\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
# print "-tmpdir <filename> Location of tmp directory\n";
|
|
|
|
print "Generates (to STDOUT) a wine configuration file based on\n";
|
|
|
|
print "/etc/fstab and searching around in DOS directories\n";
|
|
|
|
print "The options above can override certain values\n";
|
|
|
|
print "This should be considered ALPHA code\n";
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub ReadFSTAB {
|
1999-04-25 14:18:36 +02:00
|
|
|
$::opt_f = $::opt_f ? $::opt_f : '/etc/fstab';
|
|
|
|
open(FSTAB, $::opt_f) || die "Cannot read $::opt_f\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
while(<FSTAB>) {
|
|
|
|
next if /^\s*\#/;
|
|
|
|
next if /^\s*$/;
|
1999-04-25 14:18:36 +02:00
|
|
|
|
|
|
|
my ($device, $mntpoint, $type, @rest) = split(' ', $_);
|
1997-03-05 09:22:35 +01:00
|
|
|
if ($device !~ m"^/dev/fd") {
|
2002-04-23 21:34:11 +02:00
|
|
|
if ($type eq "ntfs") {
|
|
|
|
push(@::FatDrives, [$device, $mntpoint, 'win95']);
|
|
|
|
}
|
|
|
|
elsif ($type eq "msdos" || $type eq "vfat") {
|
2000-06-02 22:20:27 +02:00
|
|
|
push(@::FatDrives, [$device, $mntpoint, $type]);
|
1997-03-05 09:22:35 +01:00
|
|
|
}
|
2000-06-02 22:20:27 +02:00
|
|
|
elsif ($type eq "iso9660" ||
|
2002-04-23 21:34:11 +02:00
|
|
|
($mntpoint eq "/cdrom" && ! $type eq 'supermount') ||
|
2000-06-02 22:20:27 +02:00
|
|
|
($device eq '/dev/cdrom' && $type eq 'auto') ) {
|
|
|
|
push(@::CdromDrives, [$device, $mntpoint, 'win95']);
|
1997-03-05 09:22:35 +01:00
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
elsif ( ($mntpoint eq '/mnt/cdrom' || $mntpoint eq '/cdrom')
|
2002-04-23 21:34:11 +02:00
|
|
|
&& $type eq 'supermount') {
|
|
|
|
push(@::CdromDrives, [ '/dev/cdrom', $mntpoint, 'win95']);
|
|
|
|
}
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
if (!@::FatDrives) {
|
1996-08-24 20:26:35 +02:00
|
|
|
warn "ERROR ($0): Cannot find any MSDOS drives.\n";
|
|
|
|
warn "This does not mean you cannot run Wine, but $0\n";
|
|
|
|
warn "cannot help you (yet)\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
2000-06-02 22:20:27 +02:00
|
|
|
push(@::UnixDrives, ['', '/tmp', 'hd']);
|
|
|
|
push(@::UnixDrives, ['', '${HOME}', 'network']);
|
1999-04-25 14:18:36 +02:00
|
|
|
my $MagicDrive = 'C';
|
|
|
|
@::FatDrives = sort byDriveOrder @::FatDrives;
|
|
|
|
@::CdromDrives = sort byCdOrder @::CdromDrives;
|
|
|
|
foreach my $FatDrive (@::FatDrives) {
|
1996-08-24 20:26:35 +02:00
|
|
|
print "[Drive $MagicDrive]\n";
|
1999-04-25 14:18:36 +02:00
|
|
|
my $MntPoint = $FatDrive->[1];
|
2000-06-02 22:20:27 +02:00
|
|
|
my $FileSys = $FatDrive->[2];
|
2001-02-12 02:19:43 +01:00
|
|
|
print "\"Path\" = \"$MntPoint\"\n";
|
|
|
|
print "\"Type\" = \"hd\"\n";
|
|
|
|
print "\"Filesystem\" = \"$FileSys\"\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
print "\n";
|
|
|
|
&RegisterDrive($MagicDrive, $FatDrive);
|
|
|
|
if(!&IsMounted($FatDrive->[0])) {
|
2002-06-01 04:55:48 +02:00
|
|
|
warn "WARNING: DOS Drive $MagicDrive (" . $FatDrive->[0] .
|
1996-08-24 20:26:35 +02:00
|
|
|
") is not mounted\n";
|
|
|
|
}
|
|
|
|
$MagicDrive++;
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
foreach my $CdromDrive (@::CdromDrives) {
|
1996-08-24 20:26:35 +02:00
|
|
|
print "[Drive $MagicDrive]\n";
|
2000-06-02 22:20:27 +02:00
|
|
|
my $Device = $CdromDrive->[0];
|
1999-04-25 14:18:36 +02:00
|
|
|
my $MntPoint = $CdromDrive->[1];
|
2000-06-02 22:20:27 +02:00
|
|
|
my $FileSys = $CdromDrive->[2];
|
2001-02-12 02:19:43 +01:00
|
|
|
print "\"Path\" = \"$MntPoint\"\n";
|
|
|
|
print "\"Type\" = \"cdrom\"\n";
|
|
|
|
print "\"Device\" = \"$Device\"\n";
|
|
|
|
print "\"Filesystem\" = \"$FileSys\"\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
print "\n";
|
|
|
|
&RegisterDrive($MagicDrive, $CdromDrive);
|
|
|
|
$MagicDrive++;
|
|
|
|
}
|
2000-06-02 22:20:27 +02:00
|
|
|
foreach my $UnixDrive (@::UnixDrives) {
|
|
|
|
print "[Drive $MagicDrive]\n";
|
|
|
|
my $MntPoint = $UnixDrive->[1];
|
|
|
|
my $Type = $UnixDrive->[2];
|
2001-02-12 02:19:43 +01:00
|
|
|
print "\"Path\" = \"$MntPoint\"\n";
|
|
|
|
print "\"Type\" = \"$Type\"\n";
|
|
|
|
print "\"Filesystem\" = \"win95\"\n";
|
2000-06-02 22:20:27 +02:00
|
|
|
print "\n";
|
|
|
|
$MagicDrive++;
|
|
|
|
}
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub FindWindowsDir {
|
|
|
|
my($MagicDrive) = 'C';
|
1999-04-25 14:18:36 +02:00
|
|
|
my(@FATD)=@::FatDrives;
|
1996-08-24 20:26:35 +02:00
|
|
|
my(@wininis) = ();
|
1999-04-25 14:18:36 +02:00
|
|
|
my ($winini);
|
2001-12-04 20:38:46 +01:00
|
|
|
my ($ThisDrive);
|
1999-04-25 14:18:36 +02:00
|
|
|
|
|
|
|
if (!$::opt_windir && !$::opt_fast && !$::opt_thorough) {
|
|
|
|
$::opt_thorough++;
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
if ($::opt_windir) {
|
|
|
|
$winini = &ToUnix($::opt_windir);
|
1996-08-24 20:26:35 +02:00
|
|
|
if (!-e $winini) {
|
|
|
|
die "ERROR: Specified winini file does not exist\n";
|
|
|
|
}
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
elsif ($::opt_fast) {
|
1996-08-24 20:26:35 +02:00
|
|
|
die "-fast code can be implemented\n";
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
elsif ($::opt_thorough) {
|
|
|
|
if ($::opt_debug) { print STDERR "DEBUG: Num FATD = ", $#FATD+1, "\n"; }
|
2001-12-04 20:38:46 +01:00
|
|
|
foreach $ThisDrive (@FATD) {
|
1999-04-25 14:18:36 +02:00
|
|
|
my $MntPoint = $ThisDrive->[1];
|
2001-06-08 00:25:06 +02:00
|
|
|
push(@wininis, `find $MntPoint -iname win.ini -print`);
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
foreach $winini (@wininis) {
|
|
|
|
chomp $winini;
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
my ($winini_cnt) = $#wininis+1;
|
2002-06-01 04:55:48 +02:00
|
|
|
if ($::opt_debug) {
|
1996-08-24 20:26:35 +02:00
|
|
|
print STDERR "DEBUG: Num wininis found: $winini_cnt\n";}
|
|
|
|
if ($winini_cnt > 1) {
|
|
|
|
warn "$winini_cnt win.ini files found:\n";
|
|
|
|
@wininis = sort byFileAge @wininis;
|
|
|
|
warn join("\n", @wininis), "\n";
|
|
|
|
$winini = $wininis[0];
|
|
|
|
warn "Using most recent one: $winini\n";
|
|
|
|
}
|
|
|
|
elsif ($winini_cnt == 0) {
|
|
|
|
die "ERROR: No win.ini found in DOS partitions\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$winini = $wininis[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
die "ERROR: None of -windir, -fast, or -thorough set\n";
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
$::windir = &ToDos(dirname($winini));
|
1996-08-24 20:26:35 +02:00
|
|
|
print "[wine]\n";
|
2001-02-14 22:45:12 +01:00
|
|
|
print "\"windows\" = ", &marshall ($::windir), "\n";
|
1999-04-25 14:18:36 +02:00
|
|
|
if ($::opt_sysdir) {
|
2001-02-14 22:45:12 +01:00
|
|
|
print "\"system\" = ", &marshall ($::opt_sysdir), "\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
else {
|
2001-02-14 22:45:12 +01:00
|
|
|
print "\"system\" = ", &marshall ("$::windir\\SYSTEM"), "\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Returns 1 if the device is mounted; -1 if mount check failed; 0 if not
|
|
|
|
# mounted.
|
|
|
|
# This code is Linux specific, and needs to be broadened.
|
|
|
|
sub IsMounted {
|
|
|
|
my($Device) = @_;
|
|
|
|
if (-d "/proc") {
|
|
|
|
if (-e "/proc/mounts") {
|
2002-06-01 04:55:48 +02:00
|
|
|
open(MOUNTS, "/proc/mounts") ||
|
1996-08-24 20:26:35 +02:00
|
|
|
(warn "Cannot open /proc/mounts, although it exists\n" &&
|
|
|
|
return -1);
|
|
|
|
while(<MOUNTS>) {
|
2002-06-01 04:55:48 +02:00
|
|
|
if (/^$Device/) {
|
1996-08-24 20:26:35 +02:00
|
|
|
return 1; # Tested 1.4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0; # Tested 1.4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub RegisterDrive {
|
2000-07-23 15:43:00 +02:00
|
|
|
my($DOSdrive, $Drive) = @_;
|
1999-04-25 14:18:36 +02:00
|
|
|
$::DOS2Unix{$DOSdrive} = $Drive;
|
|
|
|
$::Device2DOS{$Drive->[0]} = $DOSdrive;
|
|
|
|
$::MntPoint2DOS{$Drive->[1]} = $DOSdrive;
|
|
|
|
$::DOS2MntPoint{$DOSdrive} = $Drive->[1];
|
|
|
|
$::DOS2Device{$DOSdrive} = $Drive->[0];
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub ReadAutoexecBat {
|
1999-04-25 14:18:36 +02:00
|
|
|
if (!%::DOS2Unix) { &ReadFSTAB; }
|
|
|
|
my($DriveC) = $::DOS2MntPoint{"C"};
|
1996-08-24 20:26:35 +02:00
|
|
|
$DriveC =~ s%/$%%;
|
|
|
|
my($path);
|
2002-06-01 04:55:48 +02:00
|
|
|
if ($::opt_debug) {
|
1996-08-24 20:26:35 +02:00
|
|
|
print STDERR "DEBUG: Looking for $DriveC/autoexec.bat\n"; }
|
|
|
|
if (-e "$DriveC/autoexec.bat") {
|
|
|
|
# Tested 1.4
|
2002-06-01 04:55:48 +02:00
|
|
|
open(AUTOEXEC, "$DriveC/autoexec.bat") ||
|
1996-08-24 20:26:35 +02:00
|
|
|
die "Cannot read autoexec.bat\n";
|
|
|
|
while(<AUTOEXEC>) {
|
|
|
|
s/\015//;
|
|
|
|
if (/^\s*(set\s+)?(\w+)\s*[\s\=]\s*(.*)$/i) {
|
|
|
|
my($varname) = $2;
|
|
|
|
my($varvalue) = $3;
|
|
|
|
chomp($varvalue);
|
|
|
|
$varname =~ tr/A-Z/a-z/;
|
|
|
|
while ($varvalue =~ /%(\w+)%/) {
|
1999-04-25 14:18:36 +02:00
|
|
|
my $matchname = $1;
|
|
|
|
my $subname = $1;
|
1996-08-24 20:26:35 +02:00
|
|
|
$subname =~ tr/A-Z/a-z/;
|
2001-02-12 02:19:43 +01:00
|
|
|
if (($::opt_debug) && ($::opt_debug =~ /path/i)) {
|
1996-08-24 20:26:35 +02:00
|
|
|
print STDERR "DEBUG: Found $matchname as $subname\n";
|
|
|
|
print STDERR "DEBUG: Old varvalue:\n$varvalue\n";
|
|
|
|
print STDERR "DEBUG: Old subname value:\n" .
|
1999-04-25 14:18:36 +02:00
|
|
|
$::DOSenv{$subname} . "\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
if ($::DOSenv{$subname}) {
|
|
|
|
$varvalue =~ s/\%$matchname\%/$::DOSenv{$subname}/;
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
else {
|
2002-06-01 04:55:48 +02:00
|
|
|
warn "DOS environment variable $subname not\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
warn "defined in autoexec.bat. (Reading config.sys\n";
|
|
|
|
warn "is not implemented.) Using null value\n";
|
|
|
|
$varvalue =~ s/%$matchname%//;
|
|
|
|
}
|
2001-02-12 02:19:43 +01:00
|
|
|
if (($::opt_debug) && ($::opt_debug =~ /path/i)) {
|
1996-08-24 20:26:35 +02:00
|
|
|
print STDERR "DEBUG: New varvalue:\n$varvalue\n";
|
|
|
|
}
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
if ($::opt_debug) {
|
1996-08-24 20:26:35 +02:00
|
|
|
print STDERR "DEBUG: $varname = $varvalue\n";
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
$::DOSenv{$varname} = $varvalue;
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
close(AUTOEXEC);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# Tested 1.4
|
1997-03-05 09:22:35 +01:00
|
|
|
warn "WARNING: C:\\AUTOEXEC.BAT was not found.\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
|
1999-04-25 14:18:36 +02:00
|
|
|
if ($::DOSenv{"path"}) {
|
|
|
|
my @pathdirs = split(/\s*;\s*/, $::DOSenv{"path"});
|
2001-02-12 02:19:43 +01:00
|
|
|
if (($::opt_debug) && ($::opt_debug =~ /path/i)) {
|
1996-08-24 20:26:35 +02:00
|
|
|
print STDERR "DEBUG (path): @pathdirs\n";
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
foreach my $pathdir (@pathdirs) {
|
1996-08-24 20:26:35 +02:00
|
|
|
if (-d &ToUnix($pathdir)) {
|
1999-04-25 14:18:36 +02:00
|
|
|
if ($::DOSpathdir{$pathdir}++) {
|
1996-08-24 20:26:35 +02:00
|
|
|
warn "Ignoring duplicate DOS path entry $pathdir\n";
|
|
|
|
}
|
|
|
|
else {
|
2001-02-12 02:19:43 +01:00
|
|
|
if (($::opt_debug) && ($::opt_debug =~ /path/i)) {
|
1996-08-24 20:26:35 +02:00
|
|
|
print STDERR "DEBUG (path): Found $pathdir\n";
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
push(@::DOSpathlist, $pathdir);
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
warn "Ignoring DOS path directory $pathdir, as it does not\n";
|
|
|
|
warn "exist\n";
|
|
|
|
}
|
|
|
|
}
|
2001-02-14 22:45:12 +01:00
|
|
|
print "\"path\" = ", &marshall (join (";", @::DOSpathlist)), "\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
# Code status: tested 1.4
|
|
|
|
warn "WARNING: Making assumptions for PATH\n";
|
|
|
|
warn "Will scan windows directory for executables and generate\n";
|
|
|
|
warn "path from that\n";
|
1999-04-25 14:18:36 +02:00
|
|
|
my $shellcmd = 'find ' . &ToUnix($::windir) . " -iregex '" .
|
1996-08-24 20:26:35 +02:00
|
|
|
'.*\.\(exe\|bat\|com\|dll\)' . "' -print";
|
2002-06-01 04:55:48 +02:00
|
|
|
if ($::opt_debug) {
|
1996-08-24 20:26:35 +02:00
|
|
|
print STDERR "DEBUG: autoexec.bat search command:\n $shellcmd\n";
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
push(@::DOScommand, `$shellcmd`);
|
2002-06-01 04:55:48 +02:00
|
|
|
if ($::opt_debug && $::opt_debug =~ /autoexec/i) {
|
1999-04-25 14:18:36 +02:00
|
|
|
print STDERR "DEBUG: autoexec.bat search results:\n\@DOS::command\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
foreach my $command (@::DOScommand) {
|
1996-08-24 20:26:35 +02:00
|
|
|
$command =~ s%[^/]+$%%;
|
2000-08-31 04:07:57 +02:00
|
|
|
$::DOSexecdir{&ToDos($command)}++;
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
2001-02-14 22:45:12 +01:00
|
|
|
print "\"path\" = " .
|
2002-06-01 04:55:48 +02:00
|
|
|
&marshall (join(";",
|
|
|
|
grep(s%\\$%%,
|
2001-02-14 22:45:12 +01:00
|
|
|
sort {$::DOSexecdir{$b} <=> $::DOSexecdir{$a}}
|
|
|
|
(keys %::DOSexecdir)))) . "\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
|
1999-04-25 14:18:36 +02:00
|
|
|
if ($::DOSenv{"temp"} && -d &ToUnix($::DOSenv{"temp"})) {
|
2001-02-14 22:45:12 +01:00
|
|
|
print "\"temp\" = ", &marshall ($::DOSenv{"temp"}), "\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
else {
|
1999-04-25 14:18:36 +02:00
|
|
|
my $TheTemp;
|
|
|
|
|
1996-08-24 20:26:35 +02:00
|
|
|
warn "WARNING: Making assumptions for TEMP\n";
|
|
|
|
warn "Looking for \\TEMP and then \\TMP on every drive\n";
|
|
|
|
# Watch out .. might pick CDROM drive :-)
|
1999-04-25 14:18:36 +02:00
|
|
|
foreach my $DOSdrive (keys %::DOS2Unix) {
|
|
|
|
my $tmp = &ToUnix("$DOSdrive:\\temp");
|
1996-08-24 20:26:35 +02:00
|
|
|
if (-d $tmp) { $TheTemp = "$DOSdrive:\\temp"; last; }
|
|
|
|
$tmp = &ToUnix("$DOSdrive:\\tmp");
|
|
|
|
if (-d $tmp) { $TheTemp = "$DOSdrive:\\tmp"; last; }
|
|
|
|
}
|
1999-04-25 14:18:36 +02:00
|
|
|
$TheTemp = '/tmp' if (!$TheTemp && -d '/tmp');
|
1996-08-24 20:26:35 +02:00
|
|
|
if ($TheTemp) {
|
|
|
|
warn "Using $TheTemp\n";
|
2001-02-14 22:45:12 +01:00
|
|
|
print "\"temp\" = ", &marshall ($TheTemp), "\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
warn "Using C:\\\n";
|
2001-02-14 22:45:12 +01:00
|
|
|
print "\"temp\" = ", &marshall ("C:\\"), "\n";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# FNunix = &ToUnix(FNdos);
|
|
|
|
# Converts DOS filenames to Unix filenames, leaving Unix filenames
|
|
|
|
# untouched.
|
|
|
|
sub ToUnix {
|
|
|
|
my($FNdos) = @_;
|
|
|
|
my($FNunix);
|
|
|
|
|
|
|
|
# Initialize tables if necessary.
|
1999-04-25 14:18:36 +02:00
|
|
|
if (!%::DOS2Unix) { &ReadFSTAB; }
|
1996-08-24 20:26:35 +02:00
|
|
|
|
|
|
|
# Determine which type of conversion is necessary
|
|
|
|
if ($FNdos =~ /^([A-Z])\:(.*)$/) { # DOS drive specified
|
1999-04-25 14:18:36 +02:00
|
|
|
$FNunix = $::DOS2MntPoint{$1} . "/$2";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
elsif ($FNdos =~ m%\\%) { # DOS drive not specified, C: is default
|
1999-04-25 14:18:36 +02:00
|
|
|
$FNunix = $::DOS2MntPoint{"C"} . "/$FNdos";
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
else { # Unix filename
|
|
|
|
$FNunix = $FNdos;
|
|
|
|
}
|
|
|
|
1 while ($FNunix =~ s%\\%/%); # Convert \ to /
|
|
|
|
$FNunix =~ tr/A-Z/a-z/; # Translate to lower case
|
|
|
|
1 while ($FNunix =~ s%//%/%); # Translate double / to /
|
|
|
|
return $FNunix;
|
|
|
|
}
|
|
|
|
|
|
|
|
# FNdos = &ToDOS(FNunix)
|
|
|
|
# Converts Unix filenames to DOS filenames
|
|
|
|
sub ToDos {
|
|
|
|
my($FNunix) = @_;
|
1999-04-25 14:18:36 +02:00
|
|
|
my(@MntList) = keys %::MntPoint2DOS;
|
|
|
|
my ($TheMntPt, $FNdos);
|
|
|
|
|
|
|
|
foreach my $MntPt (@MntList) { # Scan mount point list to see if path matches
|
1996-08-24 20:26:35 +02:00
|
|
|
if ($FNunix =~ /^$MntPt/) {
|
|
|
|
$TheMntPt = $MntPt;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$TheMntPt) {
|
|
|
|
Carp("ERROR: $FNunix not found in DOS directories\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
$FNdos = $FNunix;
|
|
|
|
$FNdos =~ s/^$TheMntPt//;
|
1999-04-25 14:18:36 +02:00
|
|
|
$FNdos = $::MntPoint2DOS{$TheMntPt} . ":" . $FNdos;
|
1996-08-24 20:26:35 +02:00
|
|
|
1 while($FNdos =~ s%/%\\%);
|
|
|
|
return $FNdos;
|
|
|
|
}
|
|
|
|
|
1999-04-25 14:18:36 +02:00
|
|
|
sub InsertDefaultFile {
|
|
|
|
my ($fileName, $tag) = @_;
|
|
|
|
my $state = 0;
|
|
|
|
|
|
|
|
if (open(DEFFILE, "$fileName")) {
|
|
|
|
while (<DEFFILE>) {
|
|
|
|
$state = 0 if ($state == 1 && $_ =~ /^[ \t]*\#/o && index($_, "</$tag>") >= 0);
|
|
|
|
print $_ if ($state == 1);
|
|
|
|
$state = 1 if ($state == 0 && $_ =~ /^[ \t]*\#/o && index($_, "<$tag>" ) >= 0);
|
|
|
|
}
|
|
|
|
close(DEFFILE);
|
|
|
|
} else {
|
|
|
|
print STDERR "Cannot read $fileName\n";
|
|
|
|
}
|
|
|
|
}
|
1996-08-24 20:26:35 +02:00
|
|
|
|
2001-02-14 22:45:12 +01:00
|
|
|
sub marshall {
|
|
|
|
my ($s) = @_;
|
|
|
|
$s =~ s/\\/\\\\/g;
|
|
|
|
return "\"$s\"";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-08-24 20:26:35 +02:00
|
|
|
sub StandardStuff {
|
2000-10-29 19:04:09 +01:00
|
|
|
if (!$::opt_inifile) {
|
|
|
|
&InsertDefaultFile("./wine.ini", "wineconf");
|
|
|
|
} else {
|
|
|
|
&InsertDefaultFile($::opt_inifile, "wineconf");
|
|
|
|
}
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub byFileAge {
|
|
|
|
-M $a <=> -M $b;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub byDriveOrder {
|
|
|
|
my($DeviceA) = $a->[0];
|
|
|
|
my($DeviceB) = $b->[0];
|
|
|
|
|
|
|
|
# Primary drives come first, logical drives last
|
|
|
|
# DOS User's Guide (version 6) p. 70, IBM version.
|
|
|
|
# If both drives are the same type, sort alphabetically
|
|
|
|
# This makes drive a come before b, etc.
|
|
|
|
# It also makes SCSI drives come before IDE drives;
|
|
|
|
# this may or may not be right :-(
|
|
|
|
my($Alogical, $Blogical);
|
|
|
|
if (substr($DeviceA, 3, 1) >= 5) { $Alogical++; }
|
|
|
|
if (substr($DeviceB, 3, 1) >= 5) { $Blogical++; }
|
|
|
|
if ($Alogical && !$Blogical) { return -1; }
|
|
|
|
elsif ($Blogical && !$Alogical) { return 1; }
|
|
|
|
else { return ($DeviceA cmp $DeviceB); }
|
|
|
|
}
|
|
|
|
|
|
|
|
sub byCdOrder {
|
|
|
|
my($DeviceA) = $a->[0];
|
|
|
|
my($DeviceB) = $b->[0];
|
|
|
|
$DeviceA cmp $DeviceB;
|
|
|
|
}
|