在Fedora Core上安装VMWare for Linux的时候,有时候会出一些问题,比如在执行 vmware-config.pl 的时候报错:
What is the location of the directory of C header files that match your running
kernel? [/usr/src/linux/include] /lib/modules/2.6.15-1.1907_FC5/build/include
The kernel defined by this directory of header files does not have the same
address space size as your running kernel.
即使给了正确的路径,依旧不对。因此,安装的时候不得不每次先去修改vmware的一些文件。为了方便起见,我写了个傻瓜脚本,能够帮助做一些包括打补丁之类的琐碎事情,当然,执行前最好知道自己在做什么:)
这个脚本仅仅是为了方便起见,没有考虑各种情况的检测,所以,事先要做好备份,另外需要注意执行多于一遍的时候,原始文件的备份可能被覆盖掉。虽然说一般不会出什么问题。:)
这个脚本需要root权限执行。
测试过的环境:
VMWare
VMware Player 1.0.1 build-19317
VMware Workstation 5.5.1
Linux
Fedora Core 5
Slackware 10.2
Kernel
kernel 2.6.16-rc4
kernel 2.6.16-1.2122_FC5
kernel 2.6.16-1.2122_FC5smp
kernel 2.6.16-1.2122_FC5xen0
#!/bin/bash
CURDIR=`pwd`
VM_CONFIG_PATCH='vmware-config.pl.patch'
VM_CONFIG=`which vmware-config.pl`
# generate the patch
cat > $VM_CONFIG_PATCH << EOF
1972,1973c1972,1973
< \$header_page_offset =~ s/^\$pattern \(?0x([0-9a-fA-F]{8,}).*\$/\$1/;
< if (\$header_page_offset =~ /[0-9a-fA-F]{8,}/) {
---
> if (\$header_page_offset =~ /^\$pattern \(?0x([0-9a-fA-F]{8,})/) {
> \$header_page_offset = \$1;
EOF
# apply the patch to vmware-config.pl
patch $VM_CONFIG $VM_CONFIG_PATCH
# Modify the compressed archives
search_base(){
# 2 level search, for increase search speed
FIRST_LEVEL=$1
FINAL_SEARCH=$2
list=`find / -name $FIRST_LEVEL -maxdepth 4 2>/dev/null`
basedir=''
for item in $list; do
file=`find $item -name $FINAL_SEARCH`
if [ ! -z $file ]; then
break;
fi
done
if [ -z $file ]; then
echo "Cannot find $FINAL_SEARCH"
return 1
else
basedir=${file%/$FINAL_SEARCH}
fi
echo $basedir
}
SOURCE_DIR=`search_base vmware vmmon.tar`
VM_SOURCE_PATCH='vm.patch'
mkdir vmtemp
cd vmtemp
tar xf $SOURCE_DIR/vmmon.tar
tar xf $SOURCE_DIR/vmnet.tar
# generate patch
cat > $VM_SOURCE_PATCH <<EOF
10c10
< \$(EXTRA_CFLAGS) -Iinclude2/asm/mach-default \---
> \$(EXTRA_CFLAGS) -Iinclude2/asm/mach-default -DKBUILD_BASENAME="\$(DRIVER)" \EOF
# apply the patch
patch vmmon-only/Makefile.kernel $VM_SOURCE_PATCH
patch vmnet-only/Makefile.kernel $VM_SOURCE_PATCH
# backup the original tar
if [ ! -f $SOURCE_DIR/vmmon.tar.bak ]; then
mv $SOURCE_DIR/vmmon.tar $SOURCE_DIR/vmmon.tar.bak
fi
if [ ! -f $SOURCE_DIR/vmnet.tar.bak ]; then
mv $SOURCE_DIR/vmnet.tar $SOURCE_DIR/vmnet.tar.bak
fi
# create new tars
tar cf $SOURCE_DIR/vmmon.tar vmmon-only/
tar cf $SOURCE_DIR/vmnet.tar vmnet-only/
cp $VM_SOURCE_PATCH $SOURCE_DIR
cd ..
rm -rf vmtemp
Reference
这个脚本主要是参照cacao74的发言进行的修改
cacao74 at http://www.vmware.com/community/thread.jspa?threadID=31877&tstart=0
另一个可供使用的脚本
http://platan.vc.cvut.cz/ftp/pub/vmware/vmware-any-any-update101.tar.gz