home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl -w
- # If your copy of perl is not in /usr/bin, please adjust the line above.
- #
- # Copyright (C) 1998, 1999 VMware, Inc. All Rights Reserved.
- #
- # Host and site-specific installation for vmware.
- #
-
- use strict;
-
- my ($bindir, $legacylibdir, $libdir, $mandir, $initdir);
- my ($default_bindir, $default_libdir, $default_mandir,
- $default_initdir, $modulesdir, $vmware_tmpdir,
- $vmware_etc, $vmware_locations, $vmnet1,
- %previousAnswer, %previousFileTime);
-
- my $defaultroot = "/usr/local";
- my $net_ifc = "eth0";
-
- $default_bindir =
- defined($ENV{BINDIR})? $ENV{BINDIR} : "$defaultroot/bin";
-
- $default_libdir =
- defined($ENV{LIBDIR})? $ENV{LIBDIR} : "$defaultroot/lib/vmware";
-
- $default_mandir =
- defined($ENV{MANDIR})? $ENV{MANDIR} : "$defaultroot/man";
-
- $default_initdir =
- defined($ENV{INITDIR})? $ENV{INITDIR} :
- -d "/etc/init.d" ? "/etc" : "/etc/rc.d";
-
- $modulesdir = "/lib/modules";
- $vmware_tmpdir = "/tmp/vmware-tmp";
- $vmware_etc = "/etc/vmware";
- $vmware_locations = "$vmware_etc/locations";
- $vmnet1 = "vmnet1"; # host-only networking interface
-
-
- my $createdBuildDir = "";
-
- my $header_dir = '';
-
- my ($umask, $version, $smp);
-
- my @programs = ("vmware", "vmware-wizard","vmnet-bridge",
- "vmnet-sniffer", "vmnet-dhcpd",
- "vmware-loop", "vmware-mount.pl");
- my @libfiles = ();
-
- # These are the files that users might change
- # and therefore should be backed up before an upgrade.
- # The name is the base name (excluding directory) of the
- # installed file.
-
- my %backupable = (
- "vmware", 1, # collision: main binary and boot file
- "config", 1, # both in /etc/vmware and in $libdir
- "vmnet0.conf", 1,
- "vmnet1.conf", 1,
- "vmnet2.conf", 1,
- "vmnet3.conf", 1,
- "vMbOgUs", 1
- );
-
- my @legacylibfiles = ("nvram");
- my $option;
-
- my $verbose = 0;
-
- # External helper programs
- my $pwd;
- my $uname;
- my $grep;
- my $rm;
- my $mknod;
- my $more;
- my $ldd;
- my $cat;
- my $lsmod;
- my $rmmod;
- my $insmod;
- my $modprobe;
- my $tar;
- my $ifconfig;
- # Build tools
- my $ksyms;
- my $make;
- my $gcc;
-
- # Emulate a simplified ls program for directories
- sub internal_ls {
- my $dir = $_[0];
- my @fn;
-
- opendir(LS, $dir);
- @fn = grep(!/^\.\.?$/, readdir(LS));
- closedir(LS);
-
- return @fn;
- }
-
- # Contrary to a popular belief, 'which' is not always a shell builtin command.
- # So we can not trust it to determine the location of other binaries.
- # Moreover, SuSE 6.1's 'which' is unable to handle program names beginning with
- # a '/'...
- #
- # Return value is the complete path if found, or "" if not found
- sub internal_which {
- my $bin = shift;
-
- if (substr($bin, 0, 1) eq '/') {
- # Absolute name
- if ((-f $bin) && (-x $bin)) {
- return $bin;
- }
- } else {
- # Relative name
- my @paths;
- my $path;
-
- if (index($bin, '/') == -1) {
- # There is no other '/' in the name
- @paths = split(':', $ENV{'PATH'});
- foreach $path (@paths) {
- my $fullbin;
-
- $fullbin = $path . '/' . $bin;
- if ((-f $fullbin) && (-x $fullbin)) {
- return $fullbin;
- }
- }
- }
- }
-
- return "";
- }
-
- # Tell if the user is the super user
- sub is_root {
- return $> == 0;
- }
-
- # Execute the command passed as an argument
- # _without_ interpolating variables (Perl does it by default)
- sub direct_command {
- return `$_[0]`;
- }
-
- # Convert a string to its equivalent shell representation
- sub shell_string {
- my $single_quoted = $_[0];
-
- $single_quoted =~ s/'/'"'"'/g;
- # This comment is a fix for emacs's broken syntax-highlighting code --hpreg
- return '\'' . $single_quoted . '\'';
- }
-
- # Build a digital Linux kernel version number
- sub Kernel_MakeVersion {
- my $version;
- my $patchLevel;
- my $subLevel;
- ($version, $patchLevel, $subLevel) = @_;
-
- return $version * 65536 + $patchLevel * 256 + $subLevel;
- }
-
- # Get a clean version number for the running Linux kernel
- # Return value is the list of:
- # Complete human readable version
- # Clean x.y.z human readable version
- # Digital version (default result)
- sub Kernel_RunningVersion {
- my $fullVersion;
- my $version;
- my $patchLevel;
- my $subLevel;
-
- $fullVersion = direct_command(shell_string($uname) . ' -r');
- chop($fullVersion);
- ($version, $patchLevel, $subLevel) = split(/\./, $fullVersion);
- # Clean the subLevel in case there is an extraversion
- ($subLevel) = split(/[^0-9]/, $subLevel);
-
- return ($fullVersion, $version . '.' . $patchLevel . '.' . $subLevel, Kernel_MakeVersion($version, $patchLevel, $subLevel));
- }
-
- # Prompts the user if a binary is not found
- # Return value is:
- # "": the binary has not been found
- # the binary name if it has been found
- sub DoesBinaryExist_Prompt {
- my $bin;
- my $ans;
-
- $bin = $_[0];
- while (internal_which($bin) eq "") {
- $ans = query("Setup is unable to find the " . $bin . " program on your machine. Do you want to specify the location of this program by hand?", "Y");
- if ($ans !~ /^[yY]/) {
- return "";
- }
-
- $bin = query("What is the location of the " . $bin . " program on your machine?", "");
- }
- return $bin;
- }
-
- # Set up the location of external helpers
- sub initialize_external_helpers {
- $pwd = DoesBinaryExist_Prompt('pwd');
- if ($pwd eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $uname = DoesBinaryExist_Prompt('uname');
- if ($uname eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $grep = DoesBinaryExist_Prompt('grep');
- if ($grep eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $rm = DoesBinaryExist_Prompt('rm');
- if ($rm eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $mknod = DoesBinaryExist_Prompt('mknod');
- if ($mknod eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $more = "";
- if (defined($ENV{PAGER})) {
- my @tokens;
-
- # The environment variable sometimes contains the pager name _followed by
- # a few command line options_.
- #
- # Isolate the program name (we are certain it does not contain a
- # whitespace) before dealing with it.
- @tokens = split(' ', $ENV{PAGER});
- $tokens[0] = DoesBinaryExist_Prompt($tokens[0]);
- if (not ($tokens[0] eq "")) {
- $more = join(' ', @tokens); # This is _already_ a shell string
- }
- }
- if ($more eq "") {
- $more = DoesBinaryExist_Prompt('more');
- if ($more eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
- $more = shell_string($more); # Save it as a shell string
- }
-
- $ldd = DoesBinaryExist_Prompt('ldd');
- if ($ldd eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $cat = DoesBinaryExist_Prompt('cat');
- if ($cat eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $lsmod = DoesBinaryExist_Prompt('lsmod');
- if ($lsmod eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $rmmod = DoesBinaryExist_Prompt('rmmod');
- if ($rmmod eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $insmod = DoesBinaryExist_Prompt('insmod');
- if ($insmod eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $modprobe = DoesBinaryExist_Prompt('modprobe');
- if ($modprobe eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $tar = DoesBinaryExist_Prompt('tar');
- if ($tar eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $ifconfig = DoesBinaryExist_Prompt('ifconfig');
- if ($ifconfig eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
- }
-
- ####
- #### Don't you just hate having to read these damn things? We do too,
- #### that's why we've put this in. And we'll even force you to read it.
- ####
- sub Show_EULA {
- print << "EOMARKETING";
-
- You must read and accept the End User License Agreement to continue.
- Press return to display it.
- EOMARKETING
-
- # The above message used to say:
- #
- # You must read and accept the End User License Agreement to continue.
- # Well, you must at least accept it. Press return to display it.
- #
- # which is very cute, but I had to change it because we don't want
- # to give the impression we're not taking ourselves seriously. Well,
- # at least not before the IPO.
-
- <STDIN>;
- # $more is already a shell string
- system($more . ' EULA');
- REPLY: while (1) {
- # Don't use standard query here, because people may
- # be using <return> to scroll through the EULA.
- my $reply;
- print "Do you accept? (yes/no) ";
- chop($reply = <STDIN>);
- last REPLY if $reply =~ /^[Yy]$|^[Yy][Ee][Ss]$/;
- die "\n### The installation is aborted.\n" .
- "### Please try again when you are ready to accept.\n\n"
- if $reply =~ /^[Nn]$|^[Nn][Oo]$/;
- print "Please reply yes or no.\n";
- }
- print "Thank you.\n\n";
- }
-
- sub message {
- my $msg = shift;
- if ($verbose) {
- print $msg;
- }
- }
-
- sub query {
-
- my ($message, $defaultreply) = @_;
- my $reply;
- my $optSpace = substr($message, -1) eq "\n" ? "" : " ";
- if ($defaultreply ne "") {
- print $message . $optSpace . "[" . $defaultreply . "] ";
- } else {
- print $message . $optSpace;
- }
-
- chop($reply = <STDIN>);
- $reply =~ s/^\s*//; # Kill leading whitespace
- $reply =~ s/\s*$//; # Kill trailing whitespace
- $reply = $defaultreply if $reply eq "";
- return $reply;
- }
-
- sub makeDirectory {
-
- my $path = $_[0];
- my $slashpos;
- my $head;
- my $tail;
-
- if ("$path" eq "") {
- return;
- }
-
- if (not -d "$path") {
- if (-e "$path") {
- die "\n### $path exists but it is not a directory.\n";
- } else {
- $slashpos = rindex($path, "/");
- $head = substr($path, 0, $slashpos);
- makeDirectory($head);
- Log("directory $path\n");
- mkdir($path, 0755) or die "\n### Cannot create $path: $!.\n";
- }
- }
- }
-
-
- sub LogFile {
- my $filename = shift;
- my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
- $atime, $mtime, $ctime) = stat($filename);
- Log("file $filename $mtime\n");
- }
-
-
- sub Log {
- my $string = shift;
- print LOCATIONS $string;
- }
-
- sub OpenLog {
- my $buildNr = "1.0 " . q$Name: build-364 $;
- $buildNr =~ s/Name: //;
-
- if (!(-d $vmware_etc)) {
- # We can't use makeDirectory here, because the fucntion wants to log,
- # and the log file is not opened yet
- mkdir($vmware_etc,0755) or die "\n### Cannot create $vmware_etc\n";
- }
- open(LOCATIONS,">$vmware_locations") or
- die "\n### Cannot open $vmware_locations\n";
-
- #### page 110 of the book
-
- select((select(LOCATIONS), $| = 1)[0]);
-
- Log("VERSION $buildNr\n");
- Log("directory $vmware_etc\n");
- }
-
- sub checkDir {
-
- my ($dir, $option) = @_;
- my $answer;
-
- message("checkDir $dir $option \n");
- if ("$dir" !~ /^\//) {
- chop($answer = direct_command(shell_string($pwd)));
- $dir = $answer . "/" . $dir;
- }
-
- if (not -d "$dir") {
- if ($option eq "uninstall") {
- warn "\n### $dir is not a valid directory.\n";
- } else {
- die "\n### $dir exists and is not a directory.\n" if -e "$dir";
-
- if ($option eq "default" ||
- query("Directory $dir does not exist.\n" .
- "Create it (including needed parent directories)?",
- "yes") =~ /^[Yy]/) {
- message("Making directory $dir\n");
- makeDirectory($dir);
- } else {
- return 0;
- }
- }
- }
- return 1;
- }
-
- # Set bindir, mandir, libdir and initdir.
- # Also check as early as possible if uninstallation is
- # required.
-
-
- sub Init {
-
- my $arg = $_[0];
- my $operation;
-
- my $diroption = $arg =~ /uninstall$/ ? "uninstall" :
- $arg eq "default" ? "default" : $arg;
-
- if ($arg eq "legacy") {
- $diroption = "uninstall";
- $operation = "legacy uninstallation";
- } elsif ($arg eq "uninstall") {
- $operation = "uninstallation";
- } else {
- $operation = "installation";
- }
-
-
- ###
- ### create a misc directory if not present
- ###
-
- if (-d $modulesdir) {
- if (-d "$modulesdir/preferred") {
- checkDir("$modulesdir/preferred/misc", $diroption);
- } else {
- checkDir("$modulesdir/$version/misc", $diroption);
- }
- }
-
-
- if ((! defined($ENV{BINDIR}) ||
- ! defined($ENV{MANDIR}) ||
- ! defined($ENV{LIBDIR}) ||
- ! defined($ENV{INITDIR}))
- && $arg eq "host") {
- print << "EOM";
-
- The host installation requires the knowledge of the site
- installation directories, even though no files will be
- installed in those directories.
-
- EOM
- }
-
- while (1) {
- $bindir = defined($ENV{BINDIR}) ? $ENV{BINDIR} :
- query("Enter binaries $operation directory:",
- "$defaultroot/bin");
-
- if (checkDir($bindir, $diroption)) {
- last;
- } else {
- if (defined($ENV{BINDIR})) {
- undef $ENV{BINDIR};
- }
- }
- }
-
- if ($arg ne "legacy") {
- Log("answer BINDIR $bindir\n");
- }
-
- if ($arg eq "all") {
- print << "EOM";
- Binaries installation directory is $bindir.
- This is the location of the executables.
- EOM
- }
-
- $defaultroot = substr($bindir, 0, rindex($bindir, "/"));
-
- if ($arg eq "legacy") {
- while (1) {
- $legacylibdir = query("Enter legacy library $operation directory:",
- "$defaultroot/lib/vmx86");
-
- if (checkDir($legacylibdir, $diroption)) {
- last;
- } else {
- if (defined($ENV{LIBDIR})) {
- undef $ENV{LIBDIR};
- }
- }
- }
- }
-
- while (1) {
- $libdir = defined($ENV{LIBDIR}) ? $ENV{LIBDIR} :
- query("Enter $operation directory for library files:",
- "$defaultroot/lib/vmware");
-
- message("user entered $libdir\n");
- if (checkDir("$libdir", $diroption)) {
- last;
- } else {
- if (defined($ENV{LIBDIR})) {
- undef $ENV{LIBDIR};
- }
- }
- }
-
- if ($arg ne "legacy") {
- Log("answer LIBDIR $libdir\n");
- }
-
-
- if ($arg eq "all") {
- print << "EOM";
- Library installation directory is $libdir.
- This is the location of the library files.
- EOM
- }
-
- while (1) {
- $mandir = defined($ENV{MANDIR}) ? $ENV{MANDIR} :
- query("Enter $operation directory for manual pages:",
- "$defaultroot/man");
-
- message("user entered $mandir\n");
- if (checkDir("$mandir/man1", $diroption)) {
- last;
- } else {
- if (defined($ENV{MANDIR})) {
- undef $ENV{MANDIR};
- }
- }
- }
-
- if ($arg ne "legacy") {
- Log("answer MANDIR $mandir\n");
- }
-
-
- if ($arg eq "all") {
- print << "EOM";
- Manual installation directory is $mandir.
- This is the location of the manual pages.
- EOM
- }
-
- while (1) {
-
- $initdir = defined($ENV{INITDIR}) ? $ENV{INITDIR} :
- query("Enter the top directory under which the init scripts reside. " .
- "It should contain\n" .
- "init.d/, rc2.d/, rc3.d/, rc5.d/, and rc6.d/:",
- "$default_initdir");
-
- if (checkDir("$initdir/init.d", $diroption) &&
- checkDir("$initdir/rc2.d", $diroption) &&
- checkDir("$initdir/rc3.d", $diroption) &&
- checkDir("$initdir/rc5.d", $diroption) &&
- checkDir("$initdir/rc6.d", $diroption)) {
- last;
- }
- }
-
- if ($arg ne "legacy") {
- Log("answer INITDIR $initdir\n");
- }
-
- print << "EOM";
- The boot-time init script will be stored under $initdir.
- This is the location of the script that loads the vmware
- kernel modules on reboot.
- EOM
-
- }
-
- sub MakeBackup {
- my ($file) = @_;
- my $i;
-
- while (1) {
- TRY:
- for $i (1..99) {
- if (! -e $file . ".old." . $i) {
- rename($file, $file . ".old." . $i) or
- warn "### Cannot rename $file to $file.old.$i: $!.\n";
- print "File $file is backed up to $file.old.$i.\n";
- return;
- }
- }
- print << "EOM";
- You have too many backup copies of file $file.
- They are in the form $file.old.N, where N is a number.
- Please remove them, then press <RETURN>.
- EOM
- <STDIN>;
- }
- }
-
-
- sub Install {
- my ($mode, $src, $dst) = @_;
- my ($sh_bindir, $sh_initdir, $sh_vmware_etc, $sh_net_ifc);
-
- if (-e $dst) {
- die "\n### File $dst should not exist.\n" .
- "### Please remove it and try again.\n";
- }
-
- open(SRC, "<$src") or die "\n### open: $src: $!.\n";
- open(DST, ">$dst") or die "\n### open: $dst: $!.\n";
- chmod $mode, $dst or die "\n### chmod $dst: $!.\n";
-
- if ($src =~ /\.dist$/) { # Need to make changes to contents
- $sh_bindir = shell_string($bindir);
- $sh_initdir = shell_string($initdir);
- $sh_vmware_etc = shell_string($vmware_etc);
- $sh_net_ifc = shell_string($net_ifc);
-
- while(defined($_ = <SRC>)) {
- s/%BINDIR%/$sh_bindir/g;
- s/%INITDIR%/$sh_initdir/g;
- s/%ETCDIR%/$sh_vmware_etc/g;
- s/%NETWORKINTERFACE%/$sh_net_ifc/g;
-
- print DST $_;
- }
- } else { # Just copy
- while(defined($_ = <SRC>)) {
- print DST $_;
- }
- }
-
- close(SRC);
- close(DST);
-
- LogFile($dst);
- }
-
- #
- # Identify the flavor of system we're installing on.
- #
- sub identifyPlatform {
- my $issue = '/etc/issue';
- my $system;
-
- # First use the accurate method that are intended to work reliably on recent
- # distributions (if an FHS guy is listening, we really need a generic way to
- # do this)
- if (-e '/etc/debian_version') {
- return 'debian';
- }
- if (-e '/etc/redhat-release') {
- return 'redhat';
- }
- if (-e '/etc/SuSE-release') {
- return 'suse';
- }
-
- # Then use less accurate methods that should work even on old distributions,
- # if people haven't customized their system too much
- if (-e $issue) {
- $system = direct_command(shell_string($grep) . ' -i ' . shell_string('red *hat') . " " . shell_string($issue)) && "redhat" ||
- direct_command(shell_string($grep) . ' -i ' . shell_string('suse\|s\.u\.s\.e') . " " . shell_string($issue)) && "suse" ||
- direct_command(shell_string($grep) . ' -i ' . shell_string('caldera') . " " . shell_string($issue)) && "caldera" ||
- direct_command(shell_string($grep) . ' -i ' . shell_string('debian') . " " . shell_string($issue)) && "debian" ||
- "unknown";
- } else {
- $system = "unknown";
- }
- return $system;
- }
-
-
- sub checkHostPlatform {
- my($sysname, $f_release, $release, $d_release, $answer, $threecom);
-
- chop($sysname = direct_command(shell_string($uname) . ' -s'));
-
- if ($sysname ne "Linux") {
- die "\n### You are not running Linux.\n" .
- "### This version of the product is for Linux only.\n";
- }
-
- ($f_release, $release, $d_release) = Kernel_RunningVersion();
- if ($d_release < Kernel_MakeVersion(2, 0, 0)) {
- die "\n### You are running Linux release $release.\n" .
- "### This product only runs on 2.0 and later kernels.\n";
- }
-
- $threecom = !(-e "/proc/ioports") || (direct_command(shell_string($grep) . ' -i ' . shell_string('3c90\|3c59') . ' /proc/ioports') ne "");
- if ($threecom && ($d_release >= Kernel_MakeVersion(2, 0, 34)) && ($d_release <= Kernel_MakeVersion(2, 0, 35))) {
- $answer =
- query("The installation script has detected that you are\n" .
- "running Linux version $release possibly with a 3Com\n" .
- "networking card. Linux kernel versions 2.0.34 and 2.0.35\n" .
- "have a bug in the 3Com driver that interacts badly with\n".
- "this product. Specifically, the real machine will\n".
- "occasionally hang and will require a hard reset.\n" .
- "This bug has been fixed in Linux 2.0.36.\n" .
- "\n" .
- "Do you want to continue the installation anyway?", "no");
- ($answer =~ /^[yY]/) || exit(0);
- }
- }
-
-
- sub BuildFailure {
- my $base = shift;
- my $driver_name = shift;
-
- print << "FATAL_VERSION";
-
- The build of the kernel module $driver_name failed.
-
- Please double check that $header_dir is the directory containing
- the header files for the currently running kernel version.
-
- If you detect a mismatch, create a softlink and retry.
-
- Please follow the following steps if you still have problems.
-
- 1. untar '$base-only.tar'
- 2. cd into that directory
- 3a. On a UP kernel, type 'make'
- 3b On an MP kernel, type 'make SUPPORT_SMP=1'
-
- 4. If the compilation is successful, try installing the module:
-
- /sbin/insmod $base-<kernel version>
-
- 5. If this step is successful, copy the module into the distribution directory
- as $base-<kernel version>
-
- Please file an incident report at http://www.vmware.com/support if you
- are still having problems.
-
- FATAL_VERSION
- die "\n### Installation failed.\n";
- }
-
-
- ### How brave are you? This little uber-routine will try and automagically
- ### build the driver (and load it just to be sure).
- sub Build_Driver {
- my ($base, $mod_base,$option) = @_;
- my ($driver_name, $build_dir);
- my $smp_string;
-
- # Do this work in /tmp or TMPDIR b/c we need a local filsystem to avoid
- # NFS vs. root permission problems.
- $build_dir = defined($ENV{TMPDIR}) ? $ENV{TMPDIR} : "/tmp";
-
- die "\n### Cannot untar and build driver in $build_dir. " .
- "Please set \$TMPDIR.\n"
- unless -d "$build_dir";
-
- $build_dir = "$build_dir/vmware-tmp";
-
- if (not -d "$build_dir") {
- $createdBuildDir = $build_dir;
- mkdir "$build_dir", 0700 or
- die "\n### Unable to create $build_dir: $!.\n";
- }
-
- # Okay, let's see if we have a tarfile?
- if (-r $base . '-only.tar') {
- message('Extracting ' . $base . ' source from ' . $base . '-only.tar\n');
- system(shell_string($tar) . ' -C ' . shell_string($build_dir) . ' -xf ' . shell_string($base . '-only.tar')) and warn "Unable to untar.\n";
- }
-
- # Now let's see if we have source?
- if (! -r $build_dir . '/' . $base . '-only/Makefile') {
- die << "EOM";
-
- Unable to find $base source. Either copy $base-only.tar to the current
- directory from the distribution or untar it yourself into the current
- directory. If your distribution did not contain $base source, please
- contact http://www.vmware.com for information about obtaining a working
- module.
-
- EOM
- }
-
- ####
- #### we now support egcs
- ####
-
- if (0) {
- # Fail if gcc on this system is the EGCS compiler.
-
- if (direct_command(shell_string($gcc) . ' --version | ' . shell_string($grep) . ' -i egcs') ne "") {
- die "\n### The default gcc on this system is EGCS, which is not\n" .
- "### compatible with this software.\n";
- }
- }
-
- # Okay, now let's see how good we are.
- $driver_name = $mod_base . $version;
- if ($smp) {
- $smp_string = ' ' . shell_string('SUPPORT_SMP=1');
- } else {
- $smp_string = '';
- }
-
- message "Building the $base with multi-processor support\n";
- system(shell_string($make) . ' -C ' . shell_string($build_dir . '/' . $base . '-only/') . ' auto-build' . $smp_string . ' ' . shell_string('HEADER_DIR=' . $header_dir)) and BuildFailure($base, $driver_name);
-
- # Did it work, did it work?
- message "Verifying the build worked\n";
- # Don't use the force flag: the module is supposed to perfectly load
- if (Try_Insmod($driver_name, $build_dir, 0)) {
- print "Build was successful: Driver name is $driver_name\n";
- } else {
- BuildFailure($base, $driver_name);
- }
-
- return ($driver_name, $build_dir);
- }
-
-
-
- sub Try_Insmod {
- my $mod_name = shift;
- my $path = shift;
- my $force = shift;
- my $retval;
-
- $retval = direct_command(shell_string($insmod) . ($force ? ' -f ' : ' ') . shell_string($path . '/' . $mod_name) . ' 2>&1');
- if ($? != 0) {
- print $retval;
- if ($retval =~ /Device or resource busy/) {
- die << "EOM";
-
- ### Either you currently have a VM running, or another module is
- ### currently using the device number required by our device
- ### driver. Please make certain all VM's are exited, and that
- ### you have either done an uninstall already or are doing an
- ### upgrade installation. If you still get this message, please
- ### contact http://www.vmware.com/support.
-
- EOM
- }
- return 0;
- } else {
- system(shell_string($rmmod) . ' ' . shell_string($mod_name)) and
- warn "Able to load $mod_name, but not unload it!\n";
- return 1;
- }
- }
-
- ### This routine goes through a distribution directory and tries to find a
- ### vm* driver that it can successfully load, or else it tries to build
- ### one. It returns the name of the file that contains a valid driver. It
- ### gets passed the base of the module (vnet or driver)
-
-
- sub Find_Module {
- my ($base,$option) = @_;
- my $mod_base;
- my @options = ();
- my ($ideal, $guess, $driver, $driver_path,$envVar);
-
- $mod_base = $base . ($smp ? '-smp-' : '-up-');
-
- $driver_path = ".";
- $ideal = $mod_base . $version;
- if (-r $ideal) {
- message "Using ideal driver $ideal\n";
- if (Try_Insmod($ideal, ".", -e '.' . $ideal . 'versioned')) {
- message "Success! Using $ideal.\n";
- $driver = $ideal;
- } else {
- warn "Unable to use $ideal, please rebuild it locally\n";
- }
- } else {
- print "No exact match for $ideal. Checking for working alternatives.\n";
- ($guess = $ideal) =~ s/.$//;
- @options = glob("$guess?");
- if ($#options == -1) {
- warn "No alternatives found, please build a driver locally\n";
- } else {
- message "Identifying a match that works with this kernel " .
- "(ignore any errors)\n";
- foreach $guess (@options) {
- ($driver = $guess and last) if Try_Insmod($guess, ".", -e '.' . $guess . 'versioned');
- }
- }
- }
-
- if (defined($driver)) {
- print "Module '$driver' detected to work correctly\n";
- } else {
- print "None of the prebuilt modules seems to work on this machine.\n";
- $envVar = "BUILDR_$base";
- message("ENV $envVar \n");
-
- if (defined($ENV{$envVar})) {
- $_ = $ENV{$envVar};
- } elsif ($option eq "default") {
- $_ = "yes";
- } else {
- $_ = query("This script can try and build one for you." .
- " Would you like to try?", "yes");
- }
-
- Log("answer $envVar $_\n");
-
- if (/^[Nn]/) {
- die << "EOM";
-
- ### Not building automatically. To build by hand, please do the following:
- ###
- ### tar xf $base-only.tar
- ### cd $base-only
- ### make
- ###
- ### and then verify that the module in
- ###
- ### $base-$version/$ideal
- ###
- ### will load.
-
- EOM
- } else {
- if ($header_dir eq '') {
- if (identifyPlatform() eq "debian") {
- # Debian doesn't always put the headers of the running kernel as
- # in /usr/src/linux/include
- $header_dir = query("What is the directory containing the header files for the running kernel?", '/usr/src/linux/include');
- } else {
- $header_dir = '/usr/src/linux/include';
- }
- }
-
- #
- # Let's be prepared to use build tools
- #
- $ksyms = DoesBinaryExist_Prompt('ksyms');
- if ($ksyms eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $make = DoesBinaryExist_Prompt('make');
- if ($make eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- $gcc = DoesBinaryExist_Prompt('gcc');
- if ($gcc eq "") {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- #
- # If a 2.0 kernel, verify that it was built with CONFIG_UMISC
- #
- if ($version =~ /^2[.]0[.]/) {
- if (open(KSYMS, shell_string($ksyms) . ' -a |')) {
- my $misc = 0;
- while (<KSYMS>) {
- if (/^[0-9a-fA-F]+[ \t]*misc_register/) {
- $misc |= 1;
- } elsif (/^[0-9a-fA-F]+[ \t]*misc_deregister/) {
- $misc |= 2;
- }
- }
- close(KSYMS);
- if ($misc != 3) {
- die << "EOF";
-
- ### You appear to have a $version Linux kernel that was not
- ### built with the CONFIG_UMISC configuration parameter set.
- ### The VMware software will not operate without this facility.
- ### Please update your kernel to include this facility and then
- ### redo the installation procedure.
-
- EOF
- }
- } else {
- print << "EOF";
-
- You have a $version Linux kernel but the ksyms program does not seems to
- accept the -a option to dump all the kernel symbols. We were trying to
- verify that your kernel is configured with CONFIG_UMISC set. If it is not
- then the VMware device drivers will not build and/or load correctly. You
- should check if your system is misconfigured.
-
- EOF
- query("Do you want to continue anyway? (yes/no)", "yes") =~
- /^[Nn]/ && die "\n### Unable to setup to build drivers.\n";
- }
- }
-
- #
- # Verify the include files that will be used to build the drivers
- # corresponds to the running kernel.
- #
- my $tempFile = "/tmp/vm" . $$ . ".c";
- if (open(TMPC, '>' . $tempFile)) {
- my $pat = '@@VERSION@@';
- print TMPC << "EOF";
- #include <linux/version.h>
- $pat UTS_RELEASE
- EOF
- close(TMPC);
- my $incVersion = direct_command(
- '(echo default:; echo '
- . shell_string("\t" . '$(CC) -E -I$(HEADER_DIR) ' . $tempFile)
- . ') | '
- . shell_string($make)
- . ' -f - '
- . shell_string('HEADER_DIR=' . $header_dir)
- . ' | '
- . shell_string($grep)
- . ' '
- . shell_string($pat)
- . ' 2>/dev/null'
- );
- unlink($tempFile);
- chop($incVersion);
- $incVersion =~ s/$pat ["]([^"]+).*/$1/;
- if ($incVersion ne $version) {
- die << "EOF";
-
- ### Something is wrong with the system include files on
- ### your machine! The file <linux/version.h> is for a
- ### $incVersion Linux system but you are running a $version
- ### kernel. This will not work for building the VMware device
- ### drivers; you must have include files that match the version
- ### of your operating system.
-
- EOF
- }
- } else {
- print << "EOF";
-
- Something went wrong and I was unable to create the temporary file
- $tempFile that I need to verify your include files correspond to
- the version of the operating system you are running. Beware that
- if these include files are for a different version of Linux that
- the VMware device drivers may not build and most likely will not
- load and/or run correctly on this machine.
-
- EOF
- query("Do you want to continue anyway? (yes/no)", "yes")
- =~ /^[Nn]/ && die "\n### Unable to setup to build drivers.\n";
- }
-
-
- ($driver, $driver_path) = &Build_Driver($base, $mod_base,$option);
- }
- }
-
- return ($driver, $driver_path);
- }
-
- sub printFindPingHelp {
- print << "EOF";
-
- The ping program sends ICMP echo messages to a specific host and
- listens for replies. We use it when probing for an available
- subnet for host-only networking to identify networks that are
- not reachable from your host machine. ping is normally installed
- on your system in a standard location such as /bin, but it might
- be somewhere unexpected in which case you must specify the full
- UNIX pathname for the program. If you do not identify where this
- program is located then we cannot automatically locate a network
- number to use and you must manually specify how to setup the
- host-only network.
-
- EOF
- }
-
- sub findPing {
- my $answer;
- my $ping;
-
- # NB: add alternative locations for ping as needed
- $ping = "/bin/ping" if -e "/bin/ping";
- if ($ping eq "") {
- print "\n";
- print "Cannot locate the ping program in the expected locations.\n";
- do {
- $answer = query("What is the full pathname for the ping program" .
- "(e.g. /bin/ping)?", "");
- if (!(-e $answer)) {
- print "\nSorry that is not an executable program.\n";
- do {
- $answer = query("Try again? (yes/no/help)\n", "yes");
- printFindPingHelp() if $answer =~ /^[Hh]/;
- return ("") if $answer =~ /^[Nn]/;
- } until $answer =~ /^[Yy]/;
- } else {
- $ping = $answer;
- }
- } until $ping ne "";
- }
- return ($ping);
- }
-
- #
- # Routine to generate an interfaces specification for smb.conf
- # that lists each network interface on a Linux host that is
- # marked "up". We assume that ifconfig w/o any arguments will
- # list all such interfaces.
- #
- # We also assume a bunch about the (convoluted) printing format of ifconfig.
- # XXX Such asumptions are unfortunately wrong and break on my system with
- # LANG=fr_FR
- #
- sub printSmbInterfaces {
- my @fields;
- my $_if = "";
- my $nif = 0;
- my (@ifs, %addrs, %masks);
-
- open(IFCONFIG, shell_string($ifconfig) . '|');
- while (<IFCONFIG>) {
- if (/^[a-zA-Z]/) {
- @fields = split(/[ ]+/);
- $_if = $fields[0];
- $ifs[$nif++] = $_if;
- } elsif (/inet addr/) {
- chop;
- ($addrs{$_if} = $_) =~ s/.*[iI]net [aA]ddr://;
- $addrs{$_if} =~ s/ .*//;
- ($masks{$_if} = $_) =~ s/.*[mM]ask://;
- $masks{$_if} =~ s/ .*//;
- }
- }
-
- my $s = "";
- my $sep = "";
- foreach $_if (@ifs) {
- if ($_if ne "" && $_if ne "lo") {
- my $mask = $masks{$_if};
- my @parts = split(/[.]/, $mask);
-
- my %map = (
- 255, 8,
- 254, 7,
- 252, 6,
- 248, 5,
- 240, 4,
- 224, 3,
- 192, 2,
- 128, 1,
- 0, 0,
- );
- my $v;
- my $bits = 0;
-
- foreach $v (@parts) {
- $bits += $map{int($v)};
- }
- $s .= sprintf("%s%s/%d", $sep, $addrs{$_if}, $bits);
- $sep = " ";
- }
- }
- return $s;
- }
-
- sub doPing {
- my $ping = shift;
- my $addr = shift;
-
- #
- # Fork ping and set an alarm to go off in case the
- # program does not terminate (certain versions of
- # nettools apparently no longer timeout when waiting
- # for responses).
- #
- my $pid = fork;
- if ($pid == 0) {
- alarm(20); # 2x ping's builtin timeout
- exec("$ping -n -c 2 $addr >/dev/null 2>&1");
- } elsif ($pid > 0) {
- if (waitpid($pid, 0) != -1) {
- if ($? == 14) {
- return 1; # SIGALARM, assume no response
- } elsif ($? != 0x7e00) {
- return $?>>8; # exit code from ping
- }
- }
- print "Something happened to $ping; assuming failure\n";
- } else {
- print "Cannot fork to start $ping program; assuming failure\n";
- }
- return 2; # failure
- }
-
- sub probeForNetConfig {
- my $subnet;
- my $netmask = "255.255.255.0"; # XXX calculate dynamically
-
- message("\nProbing for an unused private network number:\n");
- my $ping = findPing();
- if ($ping ne "") {
- my $maxProbes = 100;
- my $maxPings = 10;
- #
- # Populate the table with potential addresses
- #
- my $i;
- my @nets;
- for ($i = 0; $i < 255; $i++) {
- $nets[2*$i] = "192.168." . $i;
- $nets[2*$i+1] = "172.16." . $i;
- }
- my $pings = 0;
- my $probes = 0;
- do {
- my $i = int(rand(2*255));
- if ($nets[$i] eq "") {
- next;
- }
- $subnet = $nets[$i];
- $nets[$i] = "";
- # by convention HOS is <net>.1
- my $probeAddress = $subnet . ".1";
- message(" ping $probeAddress...");
- #
- # ping exits with:
- # 1 if no replys
- # 2 if an error
- # 0 otherwise
- #
- my $status = doPing($ping, $probeAddress);
- if ($status == 1) {
- message("(no response)\n");
- print "Network number $subnet (netmask $netmask) " .
- "appears unused.\n";
- return ($probeAddress, $netmask);
- } elsif ($status == 2) {
- message("(error)\n");
- last;
- }
- message("(answered)\n");
- $pings++;
- } while ($pings < $maxPings && ++$probes < $maxProbes);
- }
- print << "EOF";
-
- We were unable to locate an unused Class C subnet in the range
- of private network numbers. For each subnet that we tried we
- received a response to our ICMP ping packets from a host at the
- network address intended for assignment to this host machine.
- Because no private subnet appears to be unused you will need to
- explicitly specify a network number.
-
- EOF
- return ("", "");
- }
-
- sub promptForNetConfig {
- my $hostaddr = "";
- my $netmask = "";
- my $answer;
-
- do {
- do {
- $answer = query("Host address (use a.b.c.d format)?", $hostaddr);
- if ($answer !~ /^[1-9][0-9]{0,2}([.][0-9]{1,3}){3}$/) {
- print << "EOF";
-
- Not an acceptable host address. Please specify a Class C network
- or subnet; i.e. something of the form a.b.c.d where a,b,c, and d are
- decimal numbers. For example, 192.168.0.1 is a valid host address on
- a private network.
-
- EOF
- $answer = "";
- }
- } until $answer ne "";
- $hostaddr = $answer;
- $answer = "";
- do {
- $answer = query("Network mask (use a.b.c.d format)?", $netmask);
- if ($answer !~ /^[1-9][0-9]{0,2}([.][0-9]{1,3}){3}$/) {
- print << "EOF";
-
- Sorry, that does not look like a valid netmask. Please specify a mask
- using the format a.b.c.d where a,b,c and d are decimal numbers. For
- example, if you specified a Class C network above then your netmask
- would be 255.255.255.0.
-
- EOF
- $answer = "";
- }
- } until $answer ne "";
- $netmask = $answer;
-
- $answer = query("Use address $hostaddr and mask $netmask? (yes/no)",
- "yes");
- } until $answer =~ /^[Yy]/;
- return ($hostaddr, $netmask);
- }
-
- sub writeDHCPConfigFile {
- my $hostaddr = shift;
- my $netmask = shift;
- my $net;
-
- ($net = $hostaddr) =~ s/[.][0-9]+$//;
-
- # XXX deal with open errors
- open(DHCPCONFIG, ">$vmware_etc/$vmnet1.conf");
- # XXX this would be a here document but perl keeps barfing on it
- my $handle = select(DHCPCONFIG);
- print << "EOF";
- #
- # Configuration file for ISC 2.0b6pl1 vmnet-dhcpd operating on $vmnet1.
- #
- # Beware, this file was generated by the VMware installation
- # script. If you modify it, it will be clobbered the next time
- # you run the installation script (TO BE FIXED).
- #
- allow unknown-clients;
- default-lease-time 1800; # 30 minutes
- max-lease-time 7200; # 2 hours
-
- subnet $net.0 netmask $netmask {
- range $net.128 $net.254; # up to 126 VM's
- option domain-name-servers $hostaddr; # by convention use HOS
- option broadcast-address $net.255;
- }
- EOF
- select($handle);
- close(DHCPCONFIG);
-
- Log("answer VNET_HOSTONLY_HOSTADDR $hostaddr\n");
- Log("answer VNET_HOSTONLY_NETMASK $netmask\n");
- LogFile("$vmware_etc/$vmnet1.conf");
- }
-
-
- sub printHostOnlyHelp {
- print << "EOF";
-
- Virtual machines configured to use host-only networking are placed on
- a virtual network that is confined to this host. Virtual machines on
- this network can communicate with each other and the host, but no one else.
-
- To setup this host-only networking you need to select a network number
- that is unreachable from the host. We can automatically select this
- number for you, or you can specify a network number that you want.
-
- The automatic selection process works by testing a series of Class C
- subnet numbers to see if they are reachable from the host. The first
- one that is unreachable is used. The subnet numbers are chosen from the
- private network numbers specified by the Internet Engineering Task Force
- (IETF) in RFC 1918 (http://www.isi.edu/in-notes/rfc1918.txt).
-
- Remember that the host-only network that virtual machines reside on
- will not be accessible outside the host. This means that it is ok to
- use the same number on different systems so long as you do not enable
- communication between these networks.
-
- EOF
- }
-
- sub promptForHostOnlyNetworkConfig {
- my $hostaddr = "";
- my $netmask = "";
- my $firstTime = 1;
- my $answer;
-
- while ($hostaddr eq "" || $netmask eq "") {
- #
- # First ask if probing should be tried.
- #
- do {
- $answer = query("Probe for an unused network number? " .
- "(yes/no/help)", "yes");
- if ($answer =~ /^[Yy]/) {
- ($hostaddr, $netmask) = probeForNetConfig();
- next;
- }
- printHostOnlyHelp() if $answer =~ /^[Hh]/;
- } until $answer =~ /^[Nn]/;
-
- #
- # No probing; ask if they want to hand config it.
- #
- do {
- $answer = query("Specify a host address? (yes/no/help)", "yes");
- if ($answer =~ /^[Yy]/) {
- ($hostaddr, $netmask) = promptForNetConfig();
- next;
- }
- printHostOnlyHelp() if $answer =~ /^[Hh]/;
- } until $answer =~ /^[Nn]/;
-
- #
- # Give them some help (the first time through the loop)
- # and then give them a chance to abort configuring host-only
- # networking.
- #
- if ($firstTime != 0 || $answer =~ /^Hh/) {
- $firstTime = 0;
- printHostOnlyHelp();
- } else {
- print << "EOM";
-
- ### To configure host-only networking, you need to either probe
- ### for an unused network number, or specify a host address.
-
- EOM
- }
- $answer = query("Do you want to configure host-only networking? " .
- "(yes/no/help)", "yes");
- if ($answer =~ /^[Nn]/) {
- last;
- }
- printHostOnlyHelp() if $answer =~ /^[Hh]/;
- }
- return ($hostaddr, $netmask);
- }
-
- sub setupHostOnlyNetworkConfig {
- my $hostaddr = shift;
- my $netmask = shift;
- my $net;
-
- ($net = $hostaddr) =~ s/\.[0-9]+$//;
-
- print "\nConfiguring vmnet1 to use host address $hostaddr " .
- "and mask $netmask.\n";
-
- if (not defined($ENV{VNET_HOSTONLY})) {
- # don't print for an upgrade, only a clean install
- printISCCopyrightInfo();
- }
- #
- # 1. Setup the DHCP daemon:
- # write a config file for the DHCP daemon
- # setup a null leases file
- # 2. Configure the vnet1 interface (done by boot-time script).
- # 3. Add a route for vnet1 since it doesn't get done
- # when the interface is marked up (done by boot-time script).
- # 4. Record the net and mask in the global config file
- # so the boot-time script will start DHCPD (done below).
- #
- # XXX save existing .conf and .leases files
- print "Creating $vmware_etc/$vmnet1.conf for vmnet-dhcpd\n";
- writeDHCPConfigFile($hostaddr, $netmask);
-
- print "Creating empty leases file $vmware_etc/$vmnet1.leases " .
- "for vmnet-dhcpd\n";
- # XXX deal with errors
- open(DHCPLEASES, ">$vmware_etc/$vmnet1.leases");
- close(DHCPLEASES);
- LogFile("$vmware_etc/$vmnet1.leases");
- # XXX also include backup file dhcpd creates
- Log("file $vmware_etc/$vmnet1.leases~\n");
-
- #
- # If the host looks to have dhcpd setup then check if
- # it's configured to ignore our subnet. If not warn
- # them that they should do this or they may encounter
- # problems.
- #
- if (-f '/etc/dhcpd.conf' && direct_command(shell_string($grep) . ' -c ' . shell_string('^[ \t]*subnet[ \t]*' . $net . '\.0') . ' /etc/dhcpd.conf') eq "") {
- print << "EOF";
-
- You appear to have dhcpd configured for normal use. Beware that
- you should modify the /etc/dhcpd.conf file to define the subnet
- created for VMware's host-only network; otherwise dhcpd will fail
- to run if it is started with the $vmnet1 network interface enabled.
- A possible subnet configuration to add to dhcpd.conf is:
-
- subnet $net.0 netmask $netmask {
- # note that no range is given so dhcpd will not try to
- # assign IP addresses; this must be done by vmnet-dhcpd
- }
-
- If you do not want to edit dhcpd.conf then you need to always start
- the program with an explicit list of your network interfaces (leaving
- out $vmnet1); e.g.
-
- dhcpd eth0
-
- Consult the dhcpd(8) and dhcpd.conf(5) manual pages for details.
-
- EOF
- query("Hit return to continue:", "");
- }
-
- #
- # If the host looks to have samba setup then check if
- # it's configured to respond on our subnet. If not then
- # warn them that they must list the interface explicitly
- # if they want to server VMs on the host-only subnet.
- #
- if (-f '/etc/smb.conf' && direct_command(shell_string($grep) . ' -c ' . shell_string('^[ \t]*interfaces[ \t]*=.*' . $net) . ' /etc/smb.conf') eq "") {
- my $interfaces = printSmbInterfaces;
- print << "EOF";
-
- You appear to have Samba configured for normal use. Note that
- if you want to offer service to virtual machines running on the
- host-only network that you must update your /etc/smb.conf file
- to list the network interfaces on your system by adding the line:
-
- interfaces = $interfaces $hostaddr/24
-
- You may also need to update any related security controls you
- might have setup such as the "hosts allow" specification.
-
- Consult the smb.conf(5) manual page for more details.
-
- EOF
- query("Hit return to continue:", "");
- }
- print "\n";
- }
-
- sub printISCCopyrightInfo() {
- # $more is already a shell string
- system($more . ' DHCP-COPYRIGHT');
- print "\n";
- query("Hit return to continue:", "");
- print "\n";
- }
-
-
- sub configureHostOnlyNetworking {
- my $hostaddr = "";
- my $netmask = "";
- my $answer;
-
- if (not defined($ENV{VNET_HOSTONLY})) {
- print "\n";
- do {
- $answer = query("Configure host-only networking support? " .
- "(yes/no/help)", "yes");
- printHostOnlyHelp() if !($answer =~ /^[YyNn]/);
- } until $answer =~ /^[YyNn]/;
- if ($answer =~ /^[Yy]/) {
- ($hostaddr, $netmask) = promptForHostOnlyNetworkConfig();
- # check if user aborted at lower-level prompt
- $answer = "no" if ($hostaddr eq "" and $netmask eq "");
- }
- } else {
- $answer = $ENV{VNET_HOSTONLY};
- $hostaddr =
- defined($ENV{VNET_HOSTONLY_HOSTADDR}) ?
- $ENV{VNET_HOSTONLY_HOSTADDR} :
- defined($ENV{VNET_HOSTONLY_NETWORK}) ?
- $ENV{VNET_HOSTONLY_NETWORK} . ".1" : "";
- $netmask = defined($ENV{VNET_HOSTONLY_NETMASK}) ?
- $ENV{VNET_HOSTONLY_NETMASK} : "";
- }
- setupHostOnlyNetworkConfig($hostaddr, $netmask) if ($answer =~ /^[Yy]/);
- Log("answer VNET_HOSTONLY $answer\n");
- return ($hostaddr, $netmask);
- }
-
- sub ChooseNetworkInterface {
-
- my (@fields, $inf, @infs);
- my $ninfs = 0;
- my $question;
- my $previous = "";
- my $answer;
-
- # The -a is important because it lists all interfaces (not only those
- # which are up). The vmnet driver knows how to deal with down interfaces.
- open(IFCONFIG, shell_string($ifconfig) . ' -a |');
- while (<IFCONFIG>) {
- if (/^eth[0-9]/) {
- @fields = split(/[ ]+/);
- $inf = $fields[0];
- $infs[$ninfs++] = $inf;
- }
- }
- message('Found ' . $ninfs . ' ethernet interfaces: ' . join(' ', @infs));
-
- if ($ninfs > 1) {
- if (not defined($ENV{VNET_INTERFACE})) {
- print "\nYour computer has multiple network interfaces.\n";
- $question = "Please choose one of ";
- foreach $inf (@infs) {
- if ($previous ne "") {
- $question .= $previous . ", ";
- }
- $previous = $inf;
- }
- $question .= "or $previous: ";
-
- for (;;) {
- $answer = query($question, $infs[0]);
- if (grep(/$answer/, @infs)) {
- last;
- }
- }
- } else {
- $answer = $ENV{VNET_INTERFACE};
- }
- $net_ifc = $answer;
- }
- Log("answer VNET_INTERFACE $net_ifc\n")
- }
-
- sub Install_Module2 {
- my ($source, $dest, $destdir) = @_;
- if (-d $destdir) {
- -d "$destdir/misc"
- or mkdir "$destdir/misc", 0755
- or die "\n### Cannot create directory $destdir/misc: $!\n";
- &Install(0444, $source, "$destdir/misc/$dest");
- return 1;
- } else {
- return 0;
- }
- }
-
- sub Install_Module {
- my ($src, $dest, $dir) = @_;
- &Install_Module2($src, $dest, "$dir/preferred")
- or &Install_Module2($src, $dest, "$dir/$version")
- or die "\n### Unable to install kernel module $dest in either\n" .
- "### $dir/preferred or $dir/$version.\n\n";
- }
-
-
- # Install a pair of S/K startup scripts for a given runlevel
- sub Install_StartupScript {
- my $level = $_[0];
-
- # Create the S symlink
- #
- # We use 90 because samba is at 91 and it didn't like it
- # when we used 99.
- #
- symlink "../init.d/vmware", $initdir . '/rc' . $level . '.d/S90vmware'
- or warn "### symlink ../init.d/vmware to $initdir/rc" . $level . ".d: $!.\n";
- LogFile($initdir . '/rc' . $level . '.d/S90vmware');
-
- # Create the K symlink
- #
- # Note: SuSE 6.0 handles startup scripts differently (I actually like it).
- # When entering a new runlevel, K* scripts of the _old_ runlevel are
- # executed instead of those of the new runlevel
- if (not (identifyPlatform() eq 'suse')) {
- # Kill the services in the reboot runlevel
- $level = 6;
- }
- symlink "../init.d/vmware", $initdir . '/rc' . $level . '.d/K08vmware'
- or warn "### symlink ../init.d/vmware to $initdir/rc" . $level . ".d: $!.\n";
- LogFile($initdir . '/rc' . $level . '.d/K08vmware');
- }
-
- sub DealWithVmppuser {
- my $option = shift;
- my ($f_release, $release, $d_release);
- my ($ppuser, $ppuser_src, $ppuser_path);
-
- ($f_release, $release, $d_release) = Kernel_RunningVersion();
-
- if ($d_release < Kernel_MakeVersion(2, 1, 127)) {
- print << "EOM";
-
- Your machine appears to be running Linux version $release, and this
- kernel can not provide VMware with Bidirectional Parallel Port support.
- A fully-featured VMware requires Linux version 2.1.127 or higher.
-
- Without this support, VMware will run flawlessly, but will lack the ability
- to use parallel ports in a bidirectional way. This means that it is possible
- that some parallel port devices (scanners, dongles, ...) will not work inside
- a Virtual Machine.
-
- EOM
- return;
- }
-
- if ($d_release > Kernel_MakeVersion(2, 3, 9)) {
- print << "EOM";
-
- Your machine appears to be running Linux version $release, and VMware does
- not provide support for Bidirectional Parallel Ports for Linux version
- 2.3.10 or higher yet.
-
- Without this support, VMware will run flawlessly, but will lack the ability
- to use parallel ports in a bidirectional way. This means that it is possible
- that some parallel port devices (scanners, dongles, ...) will not work inside
- a Virtual Machine.
-
- EOM
- return;
- }
-
- print "Finding an installable vmppuser module\n";
- #
- # The vmppuser module relies on the parport_pc and parport modules. Let's
- # make sure they are loaded before beginning our tests
- #
- if (system(shell_string($modprobe) . ' parport_pc') || system(shell_string($modprobe) . ' parport')) {
- print << "EOM";
-
- This installation script is unable to load the parport_pc and parport modules
- that are required by the vmppuser module. You may want to load them manually
- before re-running this script.
-
- Without this support, VMware will run flawlessly, but will lack the ability
- to use parallel ports in a bidirectional way. This means that it is possible
- that some parallel port devices (scanners, dongles, ...) will not work inside
- a Virtual Machine.
-
- EOM
- } else {
- ($ppuser_src, $ppuser_path) = Find_Module("vmppuser", $option);
- ($ppuser = $ppuser_src) =~ s/\./_/g;
- &Install_Module("$ppuser_path/$ppuser_src", "vmppuser", "$modulesdir");
- # Try to unload the modules. Failure is allowed because some other
- # process could be using them.
- system(shell_string($modprobe) . ' -r parport_pc');
- system(shell_string($modprobe) . ' -r parport');
- }
- }
-
- sub Host_Install {
- my $option = shift;
- my $networking;
- my $answer;
- my ($driver, $driver_src, $driver_path);
- my ($vnet, $vnet_src, $vnet_path);
- my $hostOnlyAddress;
- my $hostOnlyNetMask;
- my $i;
-
- checkHostPlatform();
-
- message("Installing host-specific files.\n");
-
- print "Finding an installable vmmon module\n";
- ($driver_src, $driver_path) = Find_Module("vmmon", $option);
- ($driver = $driver_src) =~ s/\./_/g;
- &Install_Module("$driver_path/$driver_src", "vmmon", "$modulesdir");
-
- DealWithVmppuser($option);
-
- if (not $ENV{NETWORKING}) {
- if ($option eq "default") {
- $answer = "yes";
- } else {
- $answer = query("Do you want to install vmnet (networking " .
- "support for the VM)?", "yes");
- }
- $networking = ($answer =~ /^[yY]/);
- Log("answer NETWORKING $answer\n");
- } else {
- Log("answer NETWORKING $ENV{NETWORKING}\n");
- $networking = ($ENV{NETWORKING} =~ /^[yY]/);
- }
-
- if ($networking) {
- message("Installing networking support.\n");
- print "\nFinding an installable vmnet module\n";
- ($vnet_src, $vnet_path) = Find_Module("vmnet", $option);
- ($vnet = $vnet_src) =~ s/\./_/g;
- &Install_Module("$vnet_path/$vnet_src", "vmnet", "$modulesdir");
- } else {
- message("No networking support will be installed.\n");
- }
-
- message("/dev/vmmon\n");
- system(shell_string($mknod) . ' /dev/vmmon c 10 165') and die "\n### mknod /dev/vmmon: $!.\n";
- chmod 0600, "/dev/vmmon" or die "\n### chmod /dev/vmmon: $!.\n";
- LogFile("/dev/vmmon");
-
- # Create a bunch of parallel port devices if they don't exist yet
- message("/dev/parport*\n");
- $i = 0;
- for ($i = 0; $i < 4; $i++) {
- if (not (-e '/dev/parport' . $i)) {
- message('mknod /dev/parport' . $i . '\n');
- system(shell_string($mknod) . ' ' . shell_string('/dev/parport' . $i) . ' c 99 ' . shell_string($i)) and die "\n### mknod: $!.\n";
- chmod 0600, '/dev/parport' . $i or die "\n### chmod /dev/parport$i: $!.\n";
- LogFile('/dev/parport' . $i);
- }
- }
-
- if ($networking) {
- message("/dev/vmnet*\n");
- $i = 0;
- foreach $vnet ("/dev/vmnet0", "/dev/vmnet1",
- "/dev/vmnet2", "/dev/vmnet3") {
- message("mknod $vnet\n");
- system(shell_string($mknod) . ' ' . shell_string($vnet) . ' c 119 ' . shell_string($i)) and die "\n### mknod: $!.\n";
- chmod 0600, $vnet or die "\n### chmod $vnet: $!.\n";
- LogFile("$vnet");
- $i++;
- }
-
- &ChooseNetworkInterface();
- message("$initdir/init.d/vmware\n");
-
- my $system = identifyPlatform();
- my $bootscript = "load-vmx86-" . $system . ".dist";
- if (! -f $bootscript) {
- # no platform-specific version, use default
- $bootscript = "load-vmx86.dist";
- }
- &Install(0555, $bootscript, "$initdir/init.d/vmware");
-
- ($hostOnlyAddress, $hostOnlyNetMask) = configureHostOnlyNetworking();
-
- } else {
-
- message("$initdir/init.d/vmware\n");
- &Install(0555, "load-vmx86-novmnet.dist", "$initdir/init.d/vmware");
-
- $hostOnlyAddress = "";
- $hostOnlyNetMask = "";
-
- }
-
- my ($unique, $level, $action) =
- split(/:/, direct_command(shell_string($grep) . ' ' . shell_string('^[ \t]*[^ \t#].*:initdefault') . ' /etc/inittab'));
- if (! defined($level) || $level !~ /[123456789]/) {
- Install_StartupScript(2);
- Install_StartupScript(3);
- Install_StartupScript(5);
- } else {
- Install_StartupScript($level);
- }
-
- ###
- ### write the config file
- ###
- open(CONFIGFILE,">$vmware_etc/config");
- print CONFIGFILE "vmware.fullpath = \"$bindir/vmware\"\n";
- print CONFIGFILE "wizard.fullpath = \"$bindir/vmware-wizard\"\n";
- print CONFIGFILE "dhcpd.fullpath = \"$bindir/vmnet-dhcpd\"\n";
- print CONFIGFILE "loop.fullpath = \"$bindir/vmware-loop\"\n";
- print CONFIGFILE "libdir = \"$libdir\"\n";
-
- if (defined($hostOnlyAddress) && $hostOnlyAddress ne "") {
- print CONFIGFILE "vmnet1.HostOnlyAddress = \"$hostOnlyAddress\"\n";
- print CONFIGFILE "vmnet1.HostOnlyNetMask = \"$hostOnlyNetMask\"\n";
- }
- close(CONFIGFILE);
-
- LogFile("$vmware_etc/config");
-
-
- # Avoid reboot.
- message("Running $initdir/init.d/vmware start\n");
- system(shell_string($initdir . '/init.d/vmware') . ' start') and die "\n### vmware start: $!.\n";
- print "Installation successful \n";
- Log("Installation completed\n");
- }
-
-
- sub Legacy_Uninstall_vmx86 {
- my @vmx86files = ("/dev/vmx86", "/dev/vnet0", "/dev/vnet1",
- "/dev/vnet2", "/dev/vnet3",
- "$initdir/init.d/vmx86","$initdir/rc3.d/S99vmx86",
- "$initdir/rc5.d/S99vmx86","$initdir/rc6.d/K08vmx86");
-
- my @vmmonfiles = ("/dev/vmmon",
- "/dev/vmnet0", "/dev/vmnet1",
- "/dev/vmnet2", "/dev/vmnet3",
- "$initdir/init.d/vmware",
- "$initdir/rc3.d/S99vmware",
- "$initdir/rc5.d/S99vmware",
- "$initdir/rc6.d/K08vmware");
-
- my ($file,$oldlibdir);
-
-
-
- if (-e "/dev/vmx86") {
- ###
- ### host
- ###
-
- message("Running $initdir/init.d/vmx86 stop\n");
- system(shell_string($initdir . '/init.d/vmx86') . ' stop') if -x "$initdir/init.d/vmx86";
-
-
- foreach $file (@vmx86files) {
- message("removing legacy $file\n");
- unlink $file;
- }
-
- message ("removing legacy modules \n");
- unlink <$modulesdir/preferred/misc/vmx86-*>;
- unlink <$modulesdir/preferred/misc/vnet-*>;
- unlink <$modulesdir/$version/misc/vmx86-*>;
- unlink <$modulesdir/$version/misc/vnet-*>;
-
- ####
- #### site
- ####
-
- ($oldlibdir = $legacylibdir) =~ s/vmware/vmx86/;
- if (-d "$oldlibdir") {
- my @oldfiles = ("vmm","BIOS.ROM","nvram","config", "demo", "vmx86-test");
- foreach $file (@oldfiles) {
- message("$oldlibdir/$file\n");
- unlink "$oldlibdir/$file" or warn "unlink $oldlibdir/$file: $!.\n";
- }
- rmdir "$oldlibdir" or warn "Cannot remove $oldlibdir: $!.\n";
- }
-
- unlink "$bindir/vmx86" or warn "unlink $bindir/vmx86: $!.\n";
- message("$mandir/man1/vmx86.1 (Manual page)\n");
- unlink "$mandir/man1/vmx86.1" or warn "unlink $mandir/man1/vmx86.1: $!.\n";
-
- }
-
- if (-e "/dev/vmmon") {
-
- message("Running $initdir/init.d/vmware stop\n");
- system(shell_string($initdir . '/init.d/vmware') . ' stop') if -x "$initdir/init.d/vmware";
-
- foreach $file (@vmmonfiles) {
- message("removing legacy $file\n");
- unlink $file;
- }
-
- message ("removing legacy modules \n");
- unlink <$modulesdir/preferred/misc/vmmon>;
- unlink <$modulesdir/preferred/misc/vmnet>;
- unlink <$modulesdir/$version/misc/vmmon>;
- unlink <$modulesdir/$version/misc/vmnet>;
-
- foreach $file ("vmware", "vmnet-bridge", "vmnet-sniffer") {
- message("$bindir/$file\n");
- unlink "$bindir/$file" or warn "unlink $bindir/$file: $!.\n";
- }
-
-
- foreach $file (@legacylibfiles) {
- message("$legacylibdir/$file\n");
- unlink "$legacylibdir/$file" or warn "unlink $legacylibdir/$file: $!.\n";
- }
-
- message("$legacylibdir/nvram (Default NVRAM image)\n");
- unlink "$legacylibdir/nvram" or warn "unlink $legacylibdir/nvram: $!.\n";
-
- message("$legacylibdir/config (Default site configuration)\n");
- unlink "$legacylibdir/config" or warn "unlink $legacylibdir/config: $!.\n";
-
- message("$mandir/man1/vmx86.1 (Manual page)\n");
- unlink "$mandir/man1/vmx86.1" or
- warn "unlink $mandir/man1/vmx86.1: $!.\n";
- }
- }
-
- sub Legacy_Uninstall {
-
- my $answer = query("This script has detected host files from early" .
- " pre-releases. Delete them?", "yes");
-
- if ($answer !~ /^[Yy]/) {
- die "Bye!\n";
- }
-
- print << "EOT";
-
- Previous versions of the installation script did not record the
- location of the installed files.
-
- If you installed pre-release versions of vmx86 or vmware in
- non-standard locations, you will need to remove these files by hand.
-
- This legacy uninstall script will only run once. If it fails during
- this phase, legacy files will remain
-
- We apologize for the inconvenience.
-
- Thank you.
-
-
- EOT
-
- Init("legacy");
- Legacy_Uninstall_vmx86();
-
- }
-
-
- sub ReadLocations {
- open(LOCATIONS,$vmware_locations);
- while (<LOCATIONS>) {
- if (/^answer (\S+) (\S+)/) {
- $previousAnswer{$1} = $2;
- } elsif (/^answer (\S+)/) {
- $previousAnswer{$1} = "";
- } elsif (/^file (\S+) (\S+)/) {
- $previousFileTime{$1} = $2;
- } elsif (/^file (\S+)/) {
- $previousFileTime{$1} = 0;
- }
- }
- }
-
-
- sub UnlinkOrRename {
- my ($file, $previousMtime) = @_;
- my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
- $atime, $mtime, $ctime) = stat($file);
-
- $file =~ /([^\/]*$)/;
-
- if (defined($backupable{$1}) && $mtime ne $previousMtime) {
- MakeBackup($file);
- } else {
- message("Unlinking $file\n");
- unlink $file or warn "unlink $file: $!.\n";
- }
- }
-
-
- sub Uninstall {
- my ($dir, %dirs);
-
- message("Uninstall()\n");
-
- open(LOCATIONS, $vmware_locations);
-
- while (<LOCATIONS>) {
-
- if (/^VERSION (.+)$/) {
- if (defined($1)) {
- print "Uninstalling VMware version $1\n";
- } else {
- print "Uninstalling VMware (unknown version)\n";
- }
- } elsif (/^file (\S+) (\S+)/) {
- &UnlinkOrRename($1, $2);
- } elsif (/^file (\S+)/) {
- &UnlinkOrRename($1, 0);
- } elsif (/^directory (\S+)/) {
- $dirs{$1} = $1;
- }
- }
-
- close(LOCATIONS);
- unlink $vmware_locations or warn "Cannot remove $vmware_locations: $!.\n";
-
- # silently remove these to fix up bad intallers in the past
- unlink "/etc/rc.d/rc3.d/S99vmware";
- unlink "/etc/rc.d/rc5.d/S99vmware";
-
- foreach $dir (keys %dirs) {
- message("Removing directory $dir\n");
- rmdir $dir or warn "rmdir $dir: $!.\n";
- }
- }
-
-
- sub Site_Install {
- my $option = shift;
- my $file;
- my $shared = 0;
- my $answer;
- my %allfiles;
- my %basename;
- my $base;
- my @filelist;
-
- message("Installing site-specific files.\n");
-
- @filelist = @programs;
- push(@filelist, @libfiles);
-
- foreach $file (@filelist) {
- if ($file eq "vmware") {
- $allfiles{"$bindir/$file"} = 04555;
- } else {
- $allfiles{"$bindir/$file"} = 0555;
- }
- $basename{"$bindir/$file"} = $file;
- }
-
- $allfiles{"$mandir/man1/vmware.1"} = 0444;
- $basename{"$mandir/man1/vmware.1"} = "vmx86.1.dist";
-
- $allfiles{"$libdir/config"} = 0444;
- $basename{"$libdir/config"} = "site-config.dist";
-
- foreach $file (keys %allfiles) {
- message("$file\n");
- $shared = 0;
- if (-e "$file") {
- if ($option eq "default") {
- $shared = 1;
- } else {
- $answer = query("File $file already exists. Use it? (yes/no)", "yes");
- if ($answer =~ /^[Yy]/) {
- $shared = 1;
- }
- }
- }
-
- if (not $shared) {
- my $base = $basename{$file};
- print "Installing $file\n";
- &Install($allfiles{$file}, $base, $file);
- }
- }
-
- ##
- ## Install help files.
- ##
- makeDirectory("$libdir/help");
- Log("directory $libdir/help\n");
- foreach $file (internal_ls('help')) {
- &Install(0444, "help/$file", "$libdir/help/$file");
- }
-
- ##
- ## Install X keymap files.
- ##
- makeDirectory("$libdir/xkeymap");
- Log("directory $libdir/xkeymap\n");
- foreach $file (internal_ls('xkeymap')) {
- &Install(0444, "xkeymap/$file", "$libdir/xkeymap/$file");
- }
-
- # Check for correct version of libraries.
-
- if (system(shell_string($ldd) . ' ' . shell_string($bindir . '/vmware') . ' | ' . shell_string($grep) . ' -q -i ' . shell_string('not found')) == 0) {
- print << "EOM";
-
- The correct version of one or more libraries needed to run vmware
- may be missing. This is the output of "$ldd $bindir/vmware":
-
- EOM
- system(shell_string($ldd) . ' ' . shell_string($bindir . '/vmware'));
- print << "EOM";
-
- This script cannot tell for sure, but you may need to upgrade
- libc5 to glibc before you can run vmware.
-
- Hit return to continue.
- EOM
- <STDIN>;
- }
- }
-
-
- sub Cleanup {
- if ($createdBuildDir ne "") {
- message("Removing $createdBuildDir\n");
- system(shell_string($rm) . ' -rf ' . shell_string($createdBuildDir));
- }
- }
-
-
- ################################################################
- # Main #
- ################################################################
-
- sub main {
-
- my ($option, $recursive) = @_;
- my $answer;
- my $initscript;
- my $dirty_suse;
- my $rpm;
-
- $dirty_suse = 0;
-
- ###
- ### legacy deinstall (previous releases)
- ###
-
- if (-d $vmware_tmpdir) {
- print "VMware for Linux \n\n" .
- "The previous installation of VMware was incomplete, or at " .
- "least the directory $vmware_tmpdir exists.\n\n";
-
- $answer =
- query("Would you like me to remove $vmware_tmpdir? (yes/no)", "no");
- if ($answer =~/^[Yy]/) {
- system(shell_string($rm) . ' -rf ' . shell_string($vmware_tmpdir));
- } else {
- die "\n### Please remove $vmware_tmpdir manually.\n";
- }
- }
-
- if (!(-d $vmware_etc) && (-e "/dev/vmx86" )) {
- Legacy_Uninstall();
- print << "LEGACY";
-
- The uninstallation of the pre-beta software was successful.
- Please restart ./install.pl to install the new one.
-
- LEGACY
- die "Thank you\n";
- }
-
- if (! $recursive && $option ne "default" && $option ne "-default") {
- print << "EOM";
-
-
- --------------------------------------------
- VMware for Linux installer
-
- Copyright (C) 1998,1999 VMware, Inc.
- --------------------------------------------
-
- EOM
- }
-
- if ($option eq "uninstall" ||
- $option eq "upgrade") {
- if (! -e $vmware_locations) {
- die "\n### VMware is currently not installed. " .
- "Cannot upgrade or uninstall.\n";
- }
-
- ReadLocations();
-
- } else {
- ###
- ### Upgrade/Deinstall
- ###
- if (!$recursive && -e $vmware_locations) {
-
- ReadLocations();
-
- print "An existing distribution of VMware for Linux " .
- "has been detected.\n";
- if (defined($previousAnswer{BINDIR})) {
- print "The location of existing VMware binaries is: "
- . "$previousAnswer{BINDIR}\n";
- }
-
- if (defined($previousAnswer{NETWORKING}) &&
- $previousAnswer{NETWORKING} =~ /^[yY]/) {
- print "Existing installation has networking enabled.\n";
- } else {
- print "Existing installation has networking disabled.\n";
- }
-
- if (defined($previousAnswer{VNET_HOSTONLY}) &&
- $previousAnswer{VNET_HOSTONLY} =~ /^[yY]/) {
- print "Existing installation has host-only networking enabled.\n";
- } else {
- print "Existing installation has host-only networking disabled.\n";
- }
- print "\n";
-
- $answer = query("Would you like to upgrade VMware for Linux? (yes/no)",
- "yes");
-
- if ($answer =~/^[Yy]/) {
- $option = "upgrade";
- } else {
- $answer = query("Would you like to uninstall ".
- "VMware for Linux? (yes/no)","no");
-
- if ($answer =~/^[Yy]/) {
- $option = "uninstall";
- } else {
- die "\n### You need to choose between upgrading ".
- "and uninstalling.\n";
- }
- }
- }
- }
-
- print "\n";
- if (($option eq "upgrade" || $option eq "uninstall") &&
- -e $vmware_locations &&
- defined($previousAnswer{INITDIR})) {
-
- # SUSE RPM ALERT ON
-
- # Do not remove the previous comment and the next one. They are used by
- # our main Makefile to remove this section from the rpm installer to
- # avoid a deadlock.
-
- if (identifyPlatform() eq 'suse') {
- $rpm = DoesBinaryExist_Prompt('rpm');
- if ($rpm eq '') {
- print STDERR "\nUnable to continue.\n";
- exit(1);
- }
-
- if ( (not(direct_command(shell_string($rpm) . ' -q vmware-1.0.2-7 2> /dev/null') eq ''))
- || (not(direct_command(shell_string($rpm) . ' -q vmmodule-1.0.2-4 2> /dev/null') eq ''))) {
- # Arg, SuSE's dirty packages are installed
- $dirty_suse = 1;
- # Their INITDIR answer is complety bogus. Fix it.
- $previousAnswer{INITDIR} = '/etc/rc.d';
- }
- }
- # SUSE RPM ALERT OFF
-
- $initscript = "$previousAnswer{INITDIR}/init.d/vmware";
- message("Running $initscript stop.\n");
- if (-x "$initscript") {
- if (system(shell_string($initscript) . ' stop')) {
- die "\n### $initscript stop: failed.\n";
- }
- }
-
- # As of VMware 1.0.8 this case should be correctly handled
- # by the startup script and should trigger the previous test
- if (not (direct_command(shell_string($lsmod) . ' | ' . shell_string($grep) . ' ' . shell_string('^vmmon\|vmnet\|vmppuser')) eq "")) {
- die "\n### At least one VMware kerner module is still loaded.\n" .
- "### Cannot upgrade or uninstall.\n" .
- "### This can happen if you are running a VM.\n";
- }
-
- if ($dirty_suse == 1) {
- print << "EOSUSE";
-
- This script has detected that you were running a SuSE distribution with
- an old version of vmware (namely two packages: vmmodule-1.0.2-4 and
- vmware-1.0.2-7) that interacts badly with this version.
-
- This script is going to remove these packages.
-
- Please do not re-install these specific packages with YaST or rpm in the
- future.
-
- Press return to proceed, or Control-C to abort and exit.
- EOSUSE
- <STDIN>;
-
- system(shell_string($rpm) . ' -e vmware-1.0.2-7 2> /dev/null');
- system(shell_string($rpm) . ' -e vmmodule-1.0.2-4 2> /dev/null');
- } else {
- Uninstall();
- }
- }
-
- if ($recursive) {
- return;
- }
-
- if ($option eq "uninstall") {
- print "Thank you for trying VMware. VMware is now uninstalled\n";
- exit 0;
- }
-
-
- ###
- ###
- ###
-
- print "\n";
- while ($option eq "none") {
- $answer = query("Perform default installation? (yes/no/help)", "yes");
- if ($answer =~ /^[Yy]/) {
- $option = "default";
- } elsif ($answer =~ /^[Nn]/) {
- $option = "all";
- } else {
- print << "EOM";
-
- If you answer YES, this script will install the executables
- in $default_bindir, the library files in $default_libdir,
- the manual pages in $default_mandir, and the boot-time
- init scripts in $default_initdir.
- If these directories contain a previous installation, it will be
- uninstalled first. If these directories do not exist, they will be
- created. No questions will be asked, unless problems arise.
-
- If you answer NO, this script will prompt for the names
- of the installation directories (unless BINDIR, LIBDIR,
- MANDIR, and INITDIR are set), and may ask further questions
- to direct the installation.
-
- Please answer yes or no, or type ^C to exit.
-
- EOM
- }
- }
-
- if ($option =~ /^-/) {
- $option = substr($option, 1);
- }
-
- if ($option eq "default") {
- $ENV{BINDIR} = $default_bindir;
- $ENV{LIBDIR} = $default_libdir;
- $ENV{MANDIR} = $default_mandir;
- $ENV{INITDIR} = $default_initdir;
- }
-
- if ($option eq "upgrade") {
- foreach $answer ("BINDIR","LIBDIR","MANDIR","INITDIR","NETWORKING",
- "BUILDR_vmmon","BUILDR_vmnet", "VNET_HOSTONLY",
- "VNET_HOSTONLY_NETWORK", "VNET_HOSTONLY_HOSTADDR",
- "VNET_HOSTONLY_NETMASK", "VNET_INTERFACE") {
- if (defined($previousAnswer{$answer})) {
- message("Upgrading $answer with $previousAnswer{$answer}\n");
- $ENV{$answer} = $previousAnswer{$answer};
- }
- }
- }
-
-
- if ($option eq "default" ||
- $option eq "all" ||
- $option eq "upgrade") {
- &Show_EULA();
- OpenLog();
- &Init($option);
- &Site_Install($option);
- &Host_Install($option);
- close (LOCATIONS);
- &Cleanup();
- if (-e "PROMCONFIG") {
- system(shell_string($cat) . ' PROMCONFIG >> ' . shell_string($vmware_etc . '/config'));
- }
-
- if (-e "PROMOCODE") {
- system(shell_string($cat) . ' PROMOCODE');
- print "Hit return to continue. ";
- <STDIN>;
- }
-
- print << "DONE";
-
- To run vmware, exit from root, leave this distribution directory
- and type '$bindir/vmware'.
-
- For technical support, please visit our website at
- http://www.vwmare.com/support and our newsgroups at
- nntp://news.vmware.com
-
- For software updates, please visit our website at
- http://www.vmware.com/download
-
- Enjoy,
-
- --the VMware team
-
- DONE
-
- } else {
-
- die << "EOM"
- $0: unknown argument $option.
-
- Usage: $0 [MODE]
- where MODE is one of:
-
- all - install everything
- default - quietly install everything in the default locations
- upgrade - upgrade to a new version of VMware
- uninstall - remove VMware all its associated files
- EOM
- }
- }
-
-
- ###############
- # #
- # Really Main #
- # #
- ###############
-
- if (not is_root()) {
- die "\n### You must be root to install the VMware software.\n";
- }
-
- # Force the path to reduce the risk of using "modified" external helpers
- # If the user has a special system setup, he will be prompted for the
- # proper location anyway
- $ENV{'PATH'} = "/bin:/usr/bin:/sbin:/usr/sbin";
-
- initialize_external_helpers();
-
- $umask = umask 022;
- $smp = (direct_command(shell_string($uname) . ' -v') =~ / SMP /) ? 1 : 0;
- ($version) = Kernel_RunningVersion();
-
- $option = shift;
-
- if (defined($option) && $option eq "-v") {
- $verbose = 1;
- $option = shift;
- }
-
- $option = "none" unless defined($option);
-
- main($option, 0);
-
- cleanup:
- umask $umask;
-
-