#!/bin/sh
# Quick and dirty script to download and install various
# redistributable runtime libraries
#
# Copyright 2007 Google (Dan Kegel, dank@kegel.com)
# Thanks to Detlef Riekenberg for lots of updates
# Thanks to Saulius Krasuckas for corrections and suggestions
# FIXME get these settings right
WINE=${WINE:-wine}
WINEPREFIXCREATE=${WINEPREFIXCREATE:-wineprefixcreate}
WINEPREFIX=${WINEPREFIX:-$HOME/.wine}
WINETRICKS_CACHE=$HOME/winetrickscache
WINETRICKS_TMP=$WINEPREFIX/drive_c/winetrickstmp
# Set this to /q to skip EULAS; see -q option
WINETRICKS_QUIET=${WINETRICKS_QUIET:-""}
#----------------------------------------------------------------
usage() {
set +x
echo "Usage: $0 [options] package [package] ..."
echo "This script can help you prepare your system for Windows applications"
echo "that mistakenly assume all users' systems have all the needed"
echo "redistributable runtime libraries or fonts."
echo ""
echo "Options:"
echo " -q quiet. You must have already agreed to the EULAs."
echo " -v Verbose"
echo "Packages:"
echo " art2kmin Access 2000 runtime. License required!"
echo " corefonts Install MS Times, Arial fonts"
echo " dcom98 Install native DCOM, override the Wine implementation"
echo " fakeie6 Set registry to claim IE6sp1 is installed"
echo " gdiplus Install gdiplus.dll from pp viewer (got a better idea?)"
echo " jet40 Install Jet 4.0 Service Pack 8"
echo " mdac27 MDAC 2.7: Microsoft ODBC drivers, etc."
echo " mdac28 MDAC 2.8. (Run twice for now; see bug 5824.)"
echo " mfc40"
echo " mono1.1 mono 1.1.13-gtksharp-2.8.2"
echo " mono1.2 mono 1.2.3.1-gtksharp-2.8.3"
echo " vbvm50 Visual Basic 5 runtime"
echo " vbrun60 Visual Basic 6 runtime"
echo " vcrun6 vc6redist from VS6sp4, including mfc42"
echo " wsh51 Windows Scripting Host 5.1"
echo " wsh56js Windows scripting 5.6, jscript only, no cscript"
echo " wsh56vb Windows scripting 5.6, vbscript only, no cscript"
exit 1
}
#----------------------------------------------------------------
if test "$1" = ""
then
usage
fi
test -d $WINEPREFIX || $WINEPREFIXCREATE
mkdir -p $WINETRICKS_CACHE
mkdir -p $WINETRICKS_TMP
olddir=`pwd`
#----- Helpers ------------------------------------------------
# Download a file
download() {
file=`basename $1`
test -f $WINETRICKS_CACHE/$file || (cd $WINETRICKS_CACHE; wget -c $1)
}
# Execute with error checking
try() {
"$@"
status=$?
if test $status -ne 0
then
echo "Note: command '$@' returned status $status. We need to figure out why eventually. Probably ok to ignore for now."
#exit $status
fi
}
set_win98() {
# Pick win98 (e.g. so we can install native dcom)
cat > $WINETRICKS_TMP/set-win98.reg <<_EOF_
REGEDIT4
[HKEY_CURRENT_USER\Software\Wine]
"Version"="win98"
_EOF_
$WINE regedit $WINETRICKS_TMP/set-win98.reg
}
unset_win98() {
# Remove win98 setting
cat > $WINETRICKS_TMP/unset-win98.reg <<_EOF_
REGEDIT4
[HKEY_CURRENT_USER\Software\Wine]
"Version"=-
_EOF_
$WINE regedit $WINETRICKS_TMP/unset-win98.reg
}
#----- One function per package, in alphabetical order ----------
load_art2kmin() {
download http://download.microsoft.com/download/office2000dev/art2kmin/1/win98/en-us/art2kmin.exe
try $WINE $WINETRICKS_CACHE/art2kmin.exe
cd "$WINEPREFIX/drive_c/ART2KMin Setup"
try WINE Setup.exe INSTALLPFILES=1
cd "$olddir"
}
#----------------------------------------------------------------
load_corefonts() {
# See http://corefonts.sf.net
# TODO: let user pick mirror?
# TODO: add more fonts
download http://internap.dl.sourceforge.net/sourceforge/corefonts/arial32.exe
download http://internap.dl.sourceforge.net/sourceforge/corefonts/times32.exe
$WINE $WINETRICKS_CACHE/arial32.exe
$WINE $WINETRICKS_CACHE/times32.exe
}
#----------------------------------------------------------------
# TODO add common controls 5.x
# http://www.microsoft.com/downloads/details.aspx?familyid=6f94d31a-d1e0-4658-a566-93af0d8d4a1e
#----------------------------------------------------------------
load_dcom98() {
# Install native dcom per http://wiki.winehq.org/NativeDcom
# to avoid http://bugs.winehq.org/show_bug.cgi?id=4228
download http://download.microsoft.com/download/d/1/3/d13cd456-f0cf-4fb2-a17f-20afc79f8a51/DCOM98.EXE
# Pick win98 so we can install native dcom
set_win98
# Avoid "err:setupapi:SetupDefaultQueueCallbackA copy error 5 ..."
# Those messages are suspect, probably shouldn't be err's.
rm -f $WINEPREFIX/drive_c/windows/system32/ole32.dll
rm -f $WINEPREFIX/drive_c/windows/system32/olepro32.dll
rm -f $WINEPREFIX/drive_c/windows/system32/oleaut32.dll
rm -f $WINEPREFIX/drive_c/windows/system32/rpcrt4.dll
# "VAR=foo try cmd" fails to put VAR in the environment
# with bash 3.1.17 if try is a shell function?!
# Adding this explicit export works around it.
export WINEDLLOVERRIDES
# Normally only need to override ole32, but overriding advpack
# as well gets us the correct exit status.
WINEDLLOVERRIDES="ole32,advpack=n" try $WINE $WINETRICKS_CACHE/DCOM98.EXE $WINETRICKS_QUIET
# Set native DCOM by default for all apps (ok, this might be overkill)
cat > $WINETRICKS_TMP/dcom98-default.reg <<_EOF_
REGEDIT4
[HKEY_CURRENT_USER\Software\Wine\DllOverrides]
"ole32"="native"
"oleaut32"="native"
"rpcrt4"="native"
_EOF_
$WINE regedit $WINETRICKS_TMP/dcom98-default.reg
# and undo version win98
unset_win98
}
#----------------------------------------------------------------
# Fake IE per workaround in http://bugs.winehq.org/show_bug.cgi?id=3453
load_fakeie6() {
cat > $WINETRICKS_TMP/fakeie6.reg <<"_EOF_"
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer]
"Version"="6.0.2900.2180"
_EOF_
$WINE regedit $WINETRICKS_TMP/fakeie6.reg
}
#----------------------------------------------------------------
load_gdiplus() {
# gdiplus is documented here as a redistributable:
# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/GDIPlus.asp
# however, there's no standalone installer. So install a random
# app that happens to bundle it.
download http://download.microsoft.com/download/a/1/a/a1adc39b-9827-4c7a-890b-91396aed2b86/ppviewer.exe
$WINE $WINETRICKS_CACHE/ppviewer.exe $WINETRICKS_QUIET
# And then make it globally available.
cp $WINEPREFIX/drive_c/Program\ Files/Microsoft\ Office/PowerPoint\ Viewer/GDIPLUS.DLL $WINEPREFIX/drive_c/windows/system32/
}
#----------------------------------------------------------------
load_jet40() {
# http://support.microsoft.com/kb/239114
download http://download.microsoft.com/download/4/3/9/4393c9ac-e69e-458d-9f6d-2fe191c51469/jet40sp8_9xnt.exe
$WINE $WINETRICKS_CACHE/jet40sp8_9xnt.exe $WINETRICKS_QUIET
}
#----------------------------------------------------------------
load_mdac27() {
# FIXME to support other versions of mdac, will need to change
# 'download' to save in a subdirectory named after the package,
# since every version of mdac uses the same installer filename
download http://download.microsoft.com/download/3/b/f/3bf74b01-16ba-472d-9a8c-42b2b4fa0d76/mdac_typ.exe
WINEDLLOVERRIDES="odbccp32,odbc32=n" $WINE $WINETRICKS_CACHE/mdac_typ.exe
# Set those overrides globally so user programs get MDAC's odbc
# instead of wine's unixodbc
cat > $WINETRICKS_TMP/mdac-default.reg <<_EOF_
REGEDIT4
[HKEY_CURRENT_USER\Software\Wine\DllOverrides]
"odbc32"="native"
"odbccp32"="native"
}
_EOF_
$WINE regedit $WINETRICKS_TMP/mdac-default.reg
rm -f $WINETRICKS_TMP/*
}
#----------------------------------------------------------------
load_mdac28() {
# FIXME to support other versions of mdac, will need to change
# 'download' to save in a subdirectory named after the package,
# since every version of mdac uses the same installer filename
# Well, shoot. Can we get away with case sensitivity here?
download http://download.microsoft.com/download/c/d/f/cdfd58f1-3973-4c51-8851-49ae3777586f/MDAC_TYP.EXE
WINEDLLOVERRIDES="odbccp32,odbc32=n" try $WINE $WINETRICKS_CACHE/MDAC_TYP.EXE
# Set those overrides globally so user programs get MDAC's odbc
# instead of wine's unixodbc
cat > $WINETRICKS_TMP/mdac-default.reg <<_EOF_
REGEDIT4
[HKEY_CURRENT_USER\Software\Wine\DllOverrides]
"odbc32"="native"
"odbccp32"="native"
}
_EOF_
$WINE regedit $WINETRICKS_TMP/mdac-default.reg
rm -f $WINETRICKS_TMP/*
}
#----------------------------------------------------------------
load_mfc40() {
# See also http://www.microsoft.com/downloads/details.aspx?FamilyID=cf3005d4-7009-4d2d-89d1-b32c482c8a2d
download http://download.microsoft.com/download/sql65/Patch/6.5/WIN98/EN-US/MFC40i.exe
cd $WINETRICKS_TMP/
rm -f $WINETRICKS_TMP/*
cabextract $WINETRICKS_CACHE/MFC40i.exe
cp mfc40.dll $WINEPREFIX/drive_c/windows/system32/
cd "$olddir"
}
#----------------------------------------------------------------
load_mono11() {
# Load Mono, have it handle all .net requests
download ftp://www.go-mono.com/archive/1.1.13.8.2/windows-installer/0/mono-1.1.13.8.2-gtksharp-2.8.2-win32-0.exe
$WINE $WINETRICKS_CACHE/mono-1.1.13.8.2-gtksharp-2.8.2-win32-0.exe
# FIXME: what are the right registry entries here?
cat > $WINETRICKS_TMP/mono.reg <<_EOF_
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322]
"Install"=dword:00000001
"SP"=dword:00000001
[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\policy\v1.1]
"4322"="3706-4322"
_EOF_
$WINE regedit $WINETRICKS_TMP/mono.reg
rm -f $WINETRICKS_TMP/mono.reg
}
#----------------------------------------------------------------
load_mono12() {
# Load Mono, have it handle all .net requests
download ftp://www.go-mono.com/archive/1.2.3.1/windows-installer/0/mono-1.2.3.1-gtksharp-2.8.3-win32-0.exe
$WINE $WINETRICKS_CACHE/mono-1.2.3.1-gtksharp-2.8.3-win32-0.exe
cat > $WINETRICKS_TMP/mono_1.2.3.1.reg <<_EOF_
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322]
"Install"=dword:00000001
"SP"=dword:00000001
[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\policy\v1.1]
"4322"="3706-4322"
_EOF_
$WINE regedit $WINETRICKS_TMP/mono_1.2.3.1.reg
rm -f $WINETRICKS_TMP/mono_1.2.3.1.reg
}
#----------------------------------------------------------------
load_vbvm50() {
download http://download.microsoft.com/download/vb50pro/utility/1/win98/en-us/msvbvm50.exe
$WINE $WINETRICKS_CACHE/msvbvm50.exe $WINETRICKS_QUIET
}
#----------------------------------------------------------------
load_vbrun60() {
download http://download.microsoft.com/download/vb60pro/install/6/win98me/en-us/vbrun60.exe
$WINE $WINETRICKS_CACHE/vbrun60.exe $WINETRICKS_QUIET
}
#----------------------------------------------------------------
load_vc6run() {
# Load the Visual C++ 6 runtime libraries, including the elusive mfc42u.dll
if ! test -f $WINETRICKS_CACHE/vcredist.exe
then
download http://download.microsoft.com/download/vc60pro/update/1/w9xnt4/en-us/vc6redistsetup_enu.exe
rm -f $WINETRICKS_TMP/*
$WINE $WINETRICKS_CACHE/vc6redistsetup_enu.exe "/T:`$WINE winepath -w $WINETRICKS_TMP`" /c $WINETRICKS_QUIET
if ! test -f $WINETRICKS_TMP/vcredist.exe
then
echo vcredist.exe not found
exit 1
fi
mv $WINETRICKS_TMP/vcredist.exe $WINETRICKS_CACHE
fi
$WINE $WINETRICKS_CACHE/vcredist.exe
# And then some apps need mfc42u.dll, dunno what right way
# is to get it, vcredist doesn't install it by default?
cd $WINETRICKS_TMP/
rm -f $WINETRICKS_TMP/*
cabextract $WINETRICKS_CACHE/vcredist.exe
mv mfc42u.dll $WINEPREFIX/drive_c/windows/system32/
cd "$olddir"
}
#----------------------------------------------------------------
load_wsh51() {
# See also http://www.microsoft.com/downloads/details.aspx?FamilyID=bfdb7709-51e4-4aa6-adb0-05444e68dd80&DisplayLang=en
download http://download.microsoft.com/download/8/7/5/8751c696-282d-49da-b118-2735315dbb5e/ste51en.exe
try $WINE $WINETRICKS_CACHE/ste51en.exe $WINETRICKS_QUIET
# Not sure why this gets installed to the wrong directory
mv $WINEPREFIX/drive_c/windows/system32/unknown/cscript.exe $WINEPREFIX/drive_c/windows/system32
}
#----------------------------------------------------------------
load_wsh56js() {
# This installs jscript 5.6 (but not vbscript)
# See also http://www.microsoft.com/downloads/details.aspx?FamilyID=16dd21a1-c4ee-4eca-8b80-7bd1dfefb4f8&DisplayLang=en
download http://download.microsoft.com/download/b/c/3/bc3a0c36-fada-497d-a3de-8b0139766f3b/Windows2000-KB917344-56-x86-enu.exe
try $WINE $WINETRICKS_CACHE/Windows2000-KB917344-56-x86-enu.exe $WINETRICKS_QUIET
}
#----------------------------------------------------------------
load_wsh56vb() {
# This installs vbscript 5.6 (but not jscript)
# See also http://www.microsoft.com/downloads/details.aspx?familyid=4F728263-83A3-464B-BCC0-54E63714BC75
download http://download.microsoft.com/download/IE60/Patch/Q318089/W9XNT4Me/EN-US/vbs56men.exe
try $WINE $WINETRICKS_CACHE/vbs56men.exe $WINETRICKS_QUIET
}
#----------------------------------------------------------------
while test "$1" != ""
do
case $1 in
-q) WINETRICKS_QUIET="/q"
WINEDEBUG=${WINEDEBUG:-"fixme-all"}
export WINEDEBUG
;;
-v) set -x;;
art2kmin) load_art2kmin;;
corefonts) load_corefonts;;
dcom98) load_dcom98;;
fakeie6) load_fakeie6;;
gdiplus) load_gdiplus;;
jet40) load_jet40;;
mdac27) load_mdac27;;
mdac28) load_mdac28;;
mfc40) load_mfc40;;
mono1.1) load_mono11;;
mono1.2) load_mono12;;
vbvm50) load_vbvm50;;
vbrun60) load_vbrun60;;
vcrun6) load_vc6run;;
wsh51) load_wsh51;;
wsh56js) load_wsh56js;;
wsh56vb) load_wsh56vb;;
*) echo Unknown arg $1; usage;;
esac
# Provide a bit of feedback
test "$WINETRICKS_QUIET" = "" && case $1 in
-q) echo Setting quiet mode;;
-v) echo Setting verbose mode;;
*) echo "Install of $1 done" ;;
esac
shift
done
# cleanup
rm -f $WINETRICKS_TMP/*
test "$WINETRICKS_QUIET" = "" && echo winetricks done. || true