summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2009-04-13 12:31:42 +0100
committerNick White <git@njw.me.uk>2009-04-13 12:31:42 +0100
commit1bbff3ce1b261ef9cb6ba217ca0d8fcb54971513 (patch)
treeac5ca6418afec68f5f5c3f2f84601559d41d144b
downloadgemrb-gameinstallers-1bbff3ce1b261ef9cb6ba217ca0d8fcb54971513.tar.bz2
gemrb-gameinstallers-1bbff3ce1b261ef9cb6ba217ca0d8fcb54971513.zip
Initial import
-rw-r--r--TODO8
-rwxr-xr-xauto-installer.sh110
-rwxr-xr-xbg1/install-3cd-extra.sh21
-rwxr-xr-xbg1/install-3cd-minimal.sh43
-rwxr-xr-xbg1/install-5cd-extra.sh25
-rwxr-xr-xbg1/install-5cd-minimal.sh36
-rwxr-xr-xbg1/install-patch-baldurdash-fix.sh23
-rwxr-xr-xbg1/install-patch-baldurdash-text.sh27
-rwxr-xr-xbg1/install-patch-intl.sh23
-rwxr-xr-xbg1/install-patch-us.sh22
-rw-r--r--includes/autoinstall-includes.sh59
-rw-r--r--includes/cd-includes.sh52
-rw-r--r--includes/generic-includes.sh122
-rw-r--r--includes/patch-includes.sh17
-rwxr-xr-xpst/install-2cd-extra.sh24
-rwxr-xr-xpst/install-2cd-minimal.sh30
-rwxr-xr-xpst/install-4cd-extra.sh21
-rwxr-xr-xpst/install-4cd-minimal.sh27
-rwxr-xr-xpst/install-patch-fixpack.sh35
-rwxr-xr-xpst/install-patch-official.sh22
-rwxr-xr-xpst/install-patch-tweaks.sh37
-rwxr-xr-xpst/install-patch-ub.sh35
-rwxr-xr-xtotsc/auto-totsc-installer.sh43
-rwxr-xr-xtotsc/install-1cd-uk.sh36
-rwxr-xr-xtotsc/install-patch-baldurdash-fix.sh23
-rwxr-xr-xtotsc/install-patch-baldurdash-text.sh27
-rwxr-xr-xtotsc/install-patch-intl.sh22
-rwxr-xr-xtotsc/install-patch-uk.sh22
-rwxr-xr-xtotsc/install-patch-us.sh22
29 files changed, 1014 insertions, 0 deletions
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..108b3ec
--- /dev/null
+++ b/TODO
@@ -0,0 +1,8 @@
+Add option to manually choose game version from list
+
+Version control
+
+email qwinn, thank, and suggest offering zipped pkgs & maybe direct link to latest
+
+Ask on the forum about splitting to two cfg files, eg gemrb.cfg & bg1.cfg, listing utility & rationale (particularly gemrb install details should be separate from game install details). Offer to code it
+ best would be to read system / user (/etc|.gemrb)/gemrb.cfg, plus .gemrb/gamename.cfg
diff --git a/auto-installer.sh b/auto-installer.sh
new file mode 100755
index 0000000..d79f8af
--- /dev/null
+++ b/auto-installer.sh
@@ -0,0 +1,110 @@
+#!/bin/sh
+
+FULLGAMENAME=''
+MINSCRIPT=''
+EXTRASCRIPT=''
+PATCHES=''
+CDNO=''
+
+scriptdir="$(dirname $0)"
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/cd-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+source "$scriptdir/includes/autoinstall-includes.sh"
+
+parseargs "$@"
+
+echo "Checking CD version"
+CDMD5=$(md5sum $CDMOUNT/data1.cab|awk '{print $1}')
+
+case "$CDMD5" in
+ "138528155dfeb695bd63f90eacee7dc0" )
+ FULLGAMENAME="Baldurs Gate 1: 5CD International version"
+ SHORTGAMENAME="bg1"
+ MINSCRIPT=bg1/install-5cd-minimal.sh
+ EXTRASCRIPT=bg1/install-5cd-extra.sh
+ PATCHES="bg1/install-patch-intl.sh bg1/install-patch-baldurdash-fix.sh bg1/install-patch-baldurdash-text.sh"
+ WINDOWSFILES="baldur.exe bgmain.exe config.exe keymap.ini luaauto.cfg update.url"
+ CDNO=5
+ ;;
+ "1a6828b97a27967e8c4acc25e1ef48d2" )
+ FULLGAMENAME="Baldurs Gate Tales of the Sword Coast: 3CD US version"
+ SHORTGAMENAME="bg1"
+ MINSCRIPT=totsc/install-3cd-minimal.sh
+ EXTRASCRIPT=bg1/install-3cd-extra.sh
+ PATCHES="bg1/install-patch-baldurdash-fix.sh bg1/install-patch-baldurdash-text.sh"
+ WINDOWSFILES="baldur.exe bgmain.exe config.exe keymap.ini luaauto.cfg update.url"
+ CDNO=3
+ ;;
+ "e27d259ddc0171ff945dbba136e60309" )
+ FULLGAMENAME="Baldurs Gate Tales of the Sword Coast: 1CD UK version"
+ SHORTGAMENAME="totsc"
+ MINSCRIPT=totsc/install-1cd-uk.sh
+ PATCHES="totsc/install-patch-uk.sh totsc/install-patch-baldurdash-fix.sh totsc/install-patch-baldurdash-text.sh"
+ WINDOWSFILES="bgmain2.exe baldur.exe config.exe mconvert.exe"
+ ;;
+ "640b61443cc86c434f1b6826e63c0e33" )
+ FULLGAMENAME="Planescape Torment: 2CD version"
+ SHORTGAMENAME="pst"
+ MINSCRIPT=pst/install-2cd-minimal.sh
+ EXTRASCRIPT=pst/install-2cd-extra.sh
+ PATCHES="pst/install-patch-fixpack.sh pst/install-patch-ub.sh pst/install-patch-tweaks.sh"
+ WINDOWSFILES="torment.exe ereg"
+ CDNO=2
+ ;;
+ "5e8c2075163aca124de4a467fb33063d" )
+ FULLGAMENAME="Planescape Torment: 4CD version"
+ SHORTGAMENAME="pst"
+ MINSCRIPT=pst/install-4cd-minimal.sh
+ EXTRASCRIPT=pst/install-4cd-extra.sh
+ PATCHES="pst/install-patch-official.sh pst/install-patch-fixpack.sh pst/install-patch-ub.sh pst/install-patch-tweaks.sh"
+ WINDOWSFILES="torment.exe ereg"
+ CDNO=4
+ ;;
+ * )
+ echo "Unrecognised CD - please select game from menu"
+ # TODO: Add menu to show and select all known BG1 versions
+ exit 1
+ ;;
+esac
+
+echo "$FULLGAMENAME detected, installing"
+
+$MINSCRIPT -i "$TARGETDIR" -c "$CDMOUNT" 1>/dev/null || diequietly
+
+if [ -n "$EXTRASCRIPT" ]; then
+ if query "Do you want to do a full install, so the CDs will not be needed again?" y; then
+ FULLINSTALL=1
+ $EXTRASCRIPT -i "$TARGETDIR" -c "$CDMOUNT" 1>/dev/null || diequietly
+ else
+ FULLINSTALL=0
+ fi
+fi
+
+if [ -n "$PATCHES" ]; then
+ for patch in $PATCHES; do
+ # grab 2nd line from scripts
+ patchtitle=$(sed -n 2p $patch|cut -d ' ' -f 2-)
+ if query "Do you want to install $patchtitle" y; then
+ $patch \
+ -i "$TARGETDIR" \
+ -p "$PATCHDIR" \
+ -l "$LANGUAGE" \
+ -c "$CDMOUNT" \
+ 1>/dev/null || diequietly
+ fi
+ done
+fi
+
+if [ -n "$WINDOWSFILES" ]; then
+ if query "Do you want to remove unneeded windows files?" n; then
+ for badfile in $WINDOWSFILES; do
+ rm -rf "$TARGETDIR"/$badfile
+ done
+ fi
+fi
+
+echo
+echo "$FULLGAMENAME installed successfully"
+
+recommendcfg $CDNO
diff --git a/bg1/install-3cd-extra.sh b/bg1/install-3cd-extra.sh
new file mode 100755
index 0000000..a5d1b8e
--- /dev/null
+++ b/bg1/install-3cd-extra.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+# Extra Baldur's Gate content (so CDs aren't needed)
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/cd-includes.sh"
+
+parseargs "$@"
+
+copylower "$CDMOUNT/cd1/" "$TARGETDIR"
+
+getcd 2 c04758a6af171bf9a35d8e3d4dcd807c CD2/Movies/MovieCD2.bif
+copylower "$CDMOUNT/cd2/" "$TARGETDIR"
+copylower "$CDMOUNT/cd5/" "$TARGETDIR"
+cp $CDMOUNT/CD2/Manual/Baldur.pdf "$TARGETDIR"/manual || die
+
+getcd 3 ba4224f50f890e10561d22f602d6a991 CD3/Movies/MovieCD3.bif
+copylower "$CDMOUNT/cd3/" "$TARGETDIR"
+copylower "$CDMOUNT/cd4/" "$TARGETDIR"
+copylower "$CDMOUNT/cd6/" "$TARGETDIR"
+setperms "$TARGETDIR"
diff --git a/bg1/install-3cd-minimal.sh b/bg1/install-3cd-minimal.sh
new file mode 100755
index 0000000..42d3c0d
--- /dev/null
+++ b/bg1/install-3cd-minimal.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Baldur's Gate & Tales of the Sword Coast 3CD version minimal
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/cd-includes.sh"
+
+parseargs "$@"
+
+checkforbin unshield
+
+getcd 1 1a6828b97a27967e8c4acc25e1ef48d2 data1.cab
+
+mkdir -p "$TARGETDIR" || die
+
+cp $CDMOUNT/dialog.tlk "$TARGETDIR" || die
+
+unshield -L x $CDMOUNT/data1.cab -d "$TARGETDIR" || die
+
+cp -R "$TARGETDIR"/minimumdata/* "$TARGETDIR" || die
+rm -r "$TARGETDIR"/minimumdata
+
+cp -R "$TARGETDIR"/recommended_music/music/* "$TARGETDIR"/music/ || die
+rm -r "$TARGETDIR"/recommended_music
+
+cp -R "$TARGETDIR"/english_sounds/sounds/* "$TARGETDIR"/sounds/ || die
+rm -r "$TARGETDIR"/english_sounds
+
+cp -R "$TARGETDIR"/english/* "$TARGETDIR" || die
+rm -r "$TARGETDIR"/english
+
+mkdir -p "$TARGETDIR"/movies
+mkdir -p "$TARGETDIR"/manual
+
+mkdir -p "$TARGETDIR"/save
+cp -R $CDMOUNT/[Ss]ave/* "$TARGETDIR"/save || die
+
+cp $CDMOUNT/Manual/BGManual.pdf "$TARGETDIR"/manual/ || die
+cp $CDMOUNT/Manual/TotscManual.pdf "$TARGETDIR"/manual/ || die
+
+cp $CDMOUNT/baldur.ico "$TARGETDIR" || die
+
+setperms "$TARGETDIR"
diff --git a/bg1/install-5cd-extra.sh b/bg1/install-5cd-extra.sh
new file mode 100755
index 0000000..445b36c
--- /dev/null
+++ b/bg1/install-5cd-extra.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Installs all extra Baldur's Gate content (so CDs aren't needed)
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/cd-includes.sh"
+
+parseargs "$@"
+
+for CDNUMBER in 1 2 3 4 5; do
+ moviesum=""
+ case $CDNUMBER in
+ 2 ) moviesum="c04758a6af171bf9a35d8e3d4dcd807c" ;;
+ 3 ) moviesum="ba4224f50f890e10561d22f602d6a991" ;;
+ 4 ) moviesum="a066c263e13bf20b84d71c2ca7120fde" ;;
+ 5 ) moviesum="f19415703d3ccad01325b9338380ac7c" ;;
+ esac
+
+ if [ $CDNUMBER -gt 1 ]; then
+ getcd $CDNUMBER $moviesum CD$CDNUMBER/Movies/MovieCD$CDNUMBER.bif
+ fi
+
+ copylower "$CDMOUNT/cd$CDNUMBER/" "$TARGETDIR"
+ setperms "$TARGETDIR"
+done
diff --git a/bg1/install-5cd-minimal.sh b/bg1/install-5cd-minimal.sh
new file mode 100755
index 0000000..3db68d0
--- /dev/null
+++ b/bg1/install-5cd-minimal.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Baldur's Gate 5CD International version minimal
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/cd-includes.sh"
+
+parseargs "$@"
+
+checkforbin unshield
+
+getcd 1 138528155dfeb695bd63f90eacee7dc0 data1.cab
+
+mkdir -p "$TARGETDIR" || die
+
+cp $CDMOUNT/dialog.tlk "$TARGETDIR" || die
+
+unshield -L x $CDMOUNT/data1.cab -d "$TARGETDIR" || die
+
+cp -R "$TARGETDIR"/minimumdata/* "$TARGETDIR" || die
+rm -r "$TARGETDIR"/minimumdata
+
+cp -R "$TARGETDIR"/recommended_music/music/* "$TARGETDIR"/music/ || die
+rm -r "$TARGETDIR"/recommended_music
+
+cp -R "$TARGETDIR"/english_sounds/sounds/* "$TARGETDIR"/sounds/ || die
+rm -r "$TARGETDIR"/english_sounds
+
+cp -R "$TARGETDIR"/english/* "$TARGETDIR" || die
+rm -r "$TARGETDIR"/english
+
+mkdir -p "$TARGETDIR"/movies
+
+cp $CDMOUNT/baldur.ico "$TARGETDIR" || die
+
+setperms "$TARGETDIR"
diff --git a/bg1/install-patch-baldurdash-fix.sh b/bg1/install-patch-baldurdash-fix.sh
new file mode 100755
index 0000000..939d4f6
--- /dev/null
+++ b/bg1/install-patch-baldurdash-fix.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# BG1/TOTSC Baldurdash fix pack
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin unzip wget
+
+setuptmp
+
+getpatch http://www.baldurdash.org/LargeDownloads/BG1FixPack11.exe
+
+# unzip complains unnecessarily about skipping non-zip
+# part so don't print errors or die on failure
+unzip -L $TMPDIR/BG1FixPack11.exe -d $TMPDIR 2>/dev/null
+rm $TMPDIR/BG1FixPack11.exe $TMPDIR/bg1fixpack11readme.txt
+cp $TMPDIR/* "$TARGETDIR/override/" || die
+
+cleanuptmp
+setperms "$TARGETDIR"
diff --git a/bg1/install-patch-baldurdash-text.sh b/bg1/install-patch-baldurdash-text.sh
new file mode 100755
index 0000000..266c4ee
--- /dev/null
+++ b/bg1/install-patch-baldurdash-text.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# BG1 Baldurdash text pack
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+if [ "$LANGUAGE" != "English" ]; then
+ echo "The Baldurdash text pack is only available in English"
+ die
+fi
+
+checkforbin unzip wget
+
+setuptmp
+
+getpatch http://www.baldurdash.org/LargeDownloads/BG1NoTOSCGameTextUpdate10.exe
+
+# unzip complains unnecessarily about skipping non-zip
+# part so don't print errors or die on failure
+unzip -L $TMPDIR/BG1NoTOSCGameTextUpdate10.exe -d $TMPDIR 2>/dev/null
+cp $TMPDIR/dialog.tlk "$TARGETDIR/" || die
+
+cleanuptmp
+setperms "$TARGETDIR"
diff --git a/bg1/install-patch-intl.sh b/bg1/install-patch-intl.sh
new file mode 100755
index 0000000..5126ec7
--- /dev/null
+++ b/bg1/install-patch-intl.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# BG1 official international patch
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin unzip unshield wget
+
+setuptmp
+
+getpatch http://downloads.bioware.com/baldursgate1/bgintl114315.exe
+
+unzip $TMPDIR/bgintl114315.exe -d $TMPDIR || die
+unshield -g "$LANGUAGE" -L x $TMPDIR/data1.cab -d $TMPDIR || die
+
+LANGUAGE="$(echo $LANGUAGE|tr A-Z a-z|tr ' ' _)" # alter formatting
+cp -R $TMPDIR/"$LANGUAGE"/* "$TARGETDIR" || die
+
+cleanuptmp
+setperms "$TARGETDIR"
diff --git a/bg1/install-patch-us.sh b/bg1/install-patch-us.sh
new file mode 100755
index 0000000..3e0d2cb
--- /dev/null
+++ b/bg1/install-patch-us.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# BG1 official US/Canada patch
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin cabextract unshield wget
+
+setuptmp
+
+getpatch http://downloads.bioware.com/baldursgate1/bg114315.exe
+
+cabextract -L $TMPDIR/bg114315.exe -d $TMPDIR || die
+unshield -L x $TMPDIR/data1.cab -d $TMPDIR || die
+
+cp -R $TMPDIR/english/* "$TARGETDIR" || die
+
+cleanuptmp
+setperms "$TARGETDIR"
diff --git a/includes/autoinstall-includes.sh b/includes/autoinstall-includes.sh
new file mode 100644
index 0000000..a3bfa52
--- /dev/null
+++ b/includes/autoinstall-includes.sh
@@ -0,0 +1,59 @@
+### variables ###
+
+[ -z "$FULLINSTALL" ] && export FULLINSTALL=1
+
+### functions ###
+
+# a simplified version of query() from sorcery
+# $1 = question
+# $2 = default boolean answer [yYnN]
+function query {
+ while true; do
+ RESPONSE=""
+ echo -e -n "$1 [$2] "
+ read -n 1 RESPONSE
+ echo
+
+ RESPONSE=${RESPONSE:=$2}
+ case $RESPONSE in
+ n|N) return 1 ;;
+ y|Y) return 0 ;;
+ esac
+ done
+}
+
+function recommendcfg
+{
+ # usage: recommendcfg [numofcds]
+
+ if [ "$1" ]; then
+ NUMOFCDS=$1
+ else
+ NUMOFCDS=0
+ fi
+
+ echo
+ echo "To play the game with GemRB, you will need to add the following"
+ echo "lines to your GemRB.cfg file:"
+ echo
+ LINE="GamePath=$TARGETDIR"; echo $LINE
+ if [ $FULLINSTALL -eq 1 ]; then
+ LINE="CD1=$TARGETDIR"; echo $LINE
+ if [ $NUMOFCDS -gt 0 ]; then
+ for CDNUMBER in $(seq 2 $NUMOFCDS); do
+ LINE="CD$CDNUMBER=$TARGETDIR"
+ echo $LINE
+ done
+ fi
+ echo "GameOnCD=0"
+ else
+ LINE="CD1=$CDMOUNT"; echo $LINE
+ if [ $NUMOFCDS -gt 0 ]; then
+ for CDNUMBER in $(seq 2 $NUMOFCDS); do
+ LINE="CD$CDNUMBER=$CDMOUNT/cd$CDNUMBER"
+ echo $LINE
+ done
+ fi
+ echo "GameOnCD=1"
+ fi
+}
diff --git a/includes/cd-includes.sh b/includes/cd-includes.sh
new file mode 100644
index 0000000..e3d00fd
--- /dev/null
+++ b/includes/cd-includes.sh
@@ -0,0 +1,52 @@
+### default variables ###
+
+[ -z "$CDMOUNT" ] && export CDMOUNT="/media/cdrom"
+
+### functions ###
+
+function checkcd
+{
+ # usage: checkcd md5sum md5file
+ checksum=$(md5sum $2 2>/dev/null|awk '{print $1}')
+
+ if [ "$checksum" != "$1" ]; then
+ return 1
+ fi
+
+ return 0
+}
+
+function getcd
+{
+ # usage: getcd cdnum [md5sum] [md5file]
+ # note we're redirecting to stderr to ensure questions
+ # are always shown
+
+ if [ $# -ge 3 ]; then
+ answer=""
+ while [ $(checkcd $2 $CDMOUNT/$3; echo $?) -ne 0 ]; do
+ echo " * Insert CD $1 and press any key, or press 'c' to continue without checking" 1>&2
+ read -sn 1 answer
+ if [ "$answer" == 'c' ]; then
+ return 0
+ fi
+ done
+ else
+ echo "* Please insert CD $1 and press any key" 1>&2
+ read -sn 1
+ fi
+
+ return 0
+}
+
+function copycdextras
+{
+ # usage: copycdextras cdnum
+ # essentially a case insensitive cp -R cd#/*
+ CDNUMBER=$1
+
+ for filename in $(find $CDMOUNT/[cC][dD]$CDNUMBER/ -type f || die); do
+ relativepath=$(echo $filename|gawk -F "$CDMOUNT/[cC][dD]$CDNUMBER" '{print $2}'|tr A-Z a-z)
+ cp $filename "$TARGETDIR"/$relativepath || die
+ done
+}
diff --git a/includes/generic-includes.sh b/includes/generic-includes.sh
new file mode 100644
index 0000000..e14138f
--- /dev/null
+++ b/includes/generic-includes.sh
@@ -0,0 +1,122 @@
+### default variables ###
+
+[ -z "$TMPDIR" ] && export TMPDIR="/tmp/iepatch"
+
+[ -z "$TARGETDIR" ] && export TARGETDIR="$PWD/$SHORTGAMENAME"
+
+[ -z "$LANGUAGE" ] && export LANGUAGE="English"
+
+### functions ###
+
+function die
+{
+ #echo "Install can not continue, cleaning up partial install"
+ #rm -rf "$TARGETDIR"
+
+ echo ""
+ echo "The install failed; sorry."
+ echo "Please make sure you have the correct CDs for $FULLGAMENAME"
+ echo "and enough free disk space, and try again."
+
+ exit 1
+}
+
+function diequietly
+{
+ exit 1
+}
+
+function setuptmp
+{
+ rm -rf $TMPDIR
+ mkdir -p $TMPDIR || die
+}
+
+function cleanuptmp
+{
+ rm -rf $TMPDIR
+}
+
+function checkforbin
+{
+ # usage: checkforbin binnames...
+ retstatus=0
+
+ while [ "$1" != "" ]; do
+ binname=$1
+
+ which "$binname" &> /dev/null
+ if [ $? -ne 0 ]; then
+ echo "WARNING: This script needs $binname, which doesn't appear to be installed." 1>&2
+ retstatus=1
+ fi
+
+ shift
+ done
+
+ return $retstatus
+}
+
+function setperms
+{
+ # usage setperms targetdir
+
+ if ! [ -d "$1" ]; then
+ return 1
+ fi
+
+ find "$1" -type d -exec chmod 755 '{}' \;
+ find "$1" -type f -exec chmod 644 '{}' \;
+ find "$1" -type f -iname '*.exe' -exec chmod 755 '{}' \;
+ find "$1" -type f -iname '*.ini' -exec chmod 664 '{}' \;
+ chgrp -R games "$1"
+ if [ -d "$1"/save ]; then
+ chmod -R g+w "$1"/save
+ fi
+ if [ -d "$1"/mpsave ]; then
+ chmod -R g+w "$1"/mpsave
+ fi
+}
+
+function usage
+{
+ echo "Usage:" $0 "[-i installdir] [-p patchdir] [-c cdmount] [-l language]"
+ echo -e " -i installdir is the directory to install to."
+ echo -e " default:" $TARGETDIR
+ echo -e " -c cdmount is the mount location of the cd drive used."
+ echo -e " default:" $CDMOUNT
+ echo -e " -p patchdir is an optional directory containing patch files."
+ echo -e " default:" $PATCHDIR
+ echo -e " -l language can be one of English, Spanish, French, German, Italian or Language Independant"
+ echo -e " default:" $LANGUAGE
+ # TODO: Add option to show and select all known BG1 versions
+}
+
+function parseargs
+{
+ while getopts ":i:p:c:l:" options; do
+ case $options in
+ i ) export TARGETDIR="$OPTARG";;
+ p ) export PATCHDIR="$OPTARG";;
+ c ) export CDMOUNT="${OPTARG%\/}";; # ensure no trailing slash
+ l ) export LANGUAGE="$OPTARG";;
+ \? ) usage
+ exit 1;;
+ h ) usage
+ exit 1;;
+ esac
+ done
+}
+
+function copylower
+{
+ #usage: copylower source destination
+ if [ -d "$1" ]; then
+ for filename in $(find "$1" -type f); do
+ lowerpath="$(echo $filename|gawk -F "$1" '{print $2}'|tr A-Z a-z)"
+ cp -f "$filename" "$2/$lowerpath" || die
+ done
+ elif [ -f "$1" ]; then
+ cp -f "$(echo $1|tr A-Z a-z)" "$2"
+ fi
+}
diff --git a/includes/patch-includes.sh b/includes/patch-includes.sh
new file mode 100644
index 0000000..0f76409
--- /dev/null
+++ b/includes/patch-includes.sh
@@ -0,0 +1,17 @@
+### default variables ###
+
+[ -z "$PATCHDIR" ] && export PATCHDIR="$PWD"
+
+### functions ###
+
+function getpatch
+{
+ url=$1
+ filename=$(basename $url)
+
+ if [ -f "$PATCHDIR/$filename" ]; then
+ cp "$PATCHDIR/$filename" $TMPDIR || die
+ else
+ wget $url -O $TMPDIR/$filename || die
+ fi
+}
diff --git a/pst/install-2cd-extra.sh b/pst/install-2cd-extra.sh
new file mode 100755
index 0000000..6901c10
--- /dev/null
+++ b/pst/install-2cd-extra.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Installs Planescape Torment 2CD version extras
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/cd-includes.sh"
+
+parseargs "$@"
+
+checkforbin unshield
+
+getcd 1 640b61443cc86c434f1b6826e63c0e33 data1.cab
+
+unshield -g OtherData -L x $CDMOUNT/data1.cab -d "$TARGETDIR" || die
+unshield -g OtherData -L x $CDMOUNT/data2.cab -d "$TARGETDIR" || die
+
+mv "$TARGETDIR"/otherdata/* "$TARGETDIR" || die
+rmdir "$TARGETDIR"/otherdata || die
+
+getcd 2 610d9f6354be741b09fc25b5e9645328 cd2/movies4.bif
+
+copylower "$CDMOUNT/cd2/" "$TARGETDIR" || die
+
+setperms "$TARGETDIR"
diff --git a/pst/install-2cd-minimal.sh b/pst/install-2cd-minimal.sh
new file mode 100755
index 0000000..d868b90
--- /dev/null
+++ b/pst/install-2cd-minimal.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Installs Planescape Torment 2CD version minimal
+
+FULLGAMENAME="Planescape Torment: 2CD version"
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/cd-includes.sh"
+
+parseargs "$@"
+
+checkforbin unshield
+
+getcd 1 640b61443cc86c434f1b6826e63c0e33 data1.cab
+
+mkdir -p "$TARGETDIR" || die
+
+unshield -g MinimumData -L x $CDMOUNT/data1.cab -d "$TARGETDIR" || die
+unshield -g MinimumData -L x $CDMOUNT/data2.cab -d "$TARGETDIR" || die
+
+cp $CDMOUNT/Manual/Torment.pdf "$TARGETDIR"/manual.pdf || die
+cp $CDMOUNT/Torment.ico "$TARGETDIR"/torment.ico || die
+cp $CDMOUNT/Torment.ex_ "$TARGETDIR"/torment.exe || die
+
+mv "$TARGETDIR"/minimumdata/* "$TARGETDIR" || die
+rmdir "$TARGETDIR"/minimumdata || die
+
+mkdir -p "$TARGETDIR/save" || die
+
+setperms "$TARGETDIR"
diff --git a/pst/install-4cd-extra.sh b/pst/install-4cd-extra.sh
new file mode 100755
index 0000000..064edb4
--- /dev/null
+++ b/pst/install-4cd-extra.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Installs Planescape Torment 4CD version extras
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/cd-includes.sh"
+
+parseargs "$@"
+
+checkforbin unshield
+
+getcd 2 99be7c8544016302c820088091c52fef cd2/movies2.bif
+copylower "$CDMOUNT/cd2/" "$TARGETDIR" || die
+
+getcd 3 6ffd2c51a41603c7dca6196d9bef2e26 cd3/AR0500.bif
+copylower "$CDMOUNT/cd3/" "$TARGETDIR" || die
+
+getcd 4 b70322aaa7b1d61a168a766eba399085 cd4/movies4.bif
+copylower "$CDMOUNT/cd4/" "$TARGETDIR" || die
+
+setperms "$TARGETDIR"
diff --git a/pst/install-4cd-minimal.sh b/pst/install-4cd-minimal.sh
new file mode 100755
index 0000000..5ffb88b
--- /dev/null
+++ b/pst/install-4cd-minimal.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Installs Planescape Torment 4CD version minimal
+
+FULLGAMENAME="Planescape Torment: 4CD version"
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/cd-includes.sh"
+
+parseargs "$@"
+
+checkforbin unshield
+
+getcd 1 5e8c2075163aca124de4a467fb33063d data1.cab
+
+mkdir -p "$TARGETDIR" || die
+
+unshield -L x $CDMOUNT/data1.cab -d "$TARGETDIR" || die
+
+cp -R "$TARGETDIR"/program_executable_files/* "$TARGETDIR" || die
+rm -r "$TARGETDIR"/program_executable_files
+
+cp $CDMOUNT/torment.ico "$TARGETDIR" || die
+
+mkdir -p "$TARGETDIR/save" || die
+
+setperms "$TARGETDIR"
diff --git a/pst/install-patch-fixpack.sh b/pst/install-patch-fixpack.sh
new file mode 100755
index 0000000..6630023
--- /dev/null
+++ b/pst/install-patch-fixpack.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Planescape: Torment Ultimate Weidu Fixpack
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin WeiDU unrar
+
+setuptmp
+
+if [ ! -f "$PATCHDIR/pstfixpack.rar" ]; then
+ echo "You need to download the fixpack from http://dl.spellholdstudios.net/pst-fixpack" 1>&2
+ echo "and put it in $PATCHDIR to install this patch" 1>&2
+ exit
+fi
+
+unrar x -o+ -cl "$PATCHDIR/pstfixpack.rar" "$TARGETDIR" || die
+rm "$TARGETDIR/setup-pst-fix.exe"
+cd "$TARGETDIR"
+
+case "$LANGUAGE" in
+ "German" ) langno=1 ;;
+ "Spanish" ) langno=2 ;;
+ "Italian" ) langno=3 ;;
+ * ) langno=0 ;;
+esac
+
+# echo to install all manually as --yes assumes English
+echo -e "${langno}\nn\ni\ni\ni\n\n" \
+| WeiDU --continue setup-pst-fix.tp2 || die
+
+setperms "$TARGETDIR"
diff --git a/pst/install-patch-official.sh b/pst/install-patch-official.sh
new file mode 100755
index 0000000..485fad1
--- /dev/null
+++ b/pst/install-patch-official.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Planescape: Torment official patch
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin cabextract unshield wget
+
+setuptmp
+
+getpatch http://www.sorcerers.net/Games2/Torment/Trmt11.exe
+
+cabextract -L $TMPDIR/Trmt11.exe -d $TMPDIR || die
+unshield -L x $TMPDIR/data1.cab -d $TMPDIR || die
+
+cp -R $TMPDIR/program_executable_files/* "$TARGETDIR" || die
+
+cleanuptmp
+setperms "$TARGETDIR"
diff --git a/pst/install-patch-tweaks.sh b/pst/install-patch-tweaks.sh
new file mode 100755
index 0000000..a90ee40
--- /dev/null
+++ b/pst/install-patch-tweaks.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# Planescape: Torment Tweak Pack
+# Note: this only installs the Banter Accelerator
+# and Stackable Items tweaks
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin WeiDU unrar
+
+setuptmp
+
+if [ ! -f "$PATCHDIR/psttweak.rar" ]; then
+ echo "You need to download the fixpack from http://dl.spellholdstudios.net/pst-qtweaks" 1>&2
+ echo "and put it in $PATCHDIR to install this patch" 1>&2
+ exit
+fi
+
+unrar x -o+ -cl "$PATCHDIR/psttweak.rar" "$TARGETDIR" || die
+rm "$TARGETDIR/setup-pst-tweak.exe"
+cd "$TARGETDIR"
+
+case "$LANGUAGE" in
+ "German" ) langno=1 ;;
+ "Spanish" ) langno=2 ;;
+ "Italian" ) langno=3 ;;
+ * ) langno=0 ;;
+esac
+
+# echo to install all manually as --yes assumes English
+echo -e "${langno}\nn\n2\nn\nn\ni\nn\ni\nn\nn\nn\nn\nn\nn\nn\nn\nn\n" \
+| WeiDU --continue setup-pst-tweak.tp2 || die
+
+setperms "$TARGETDIR"
diff --git a/pst/install-patch-ub.sh b/pst/install-patch-ub.sh
new file mode 100755
index 0000000..b26a66c
--- /dev/null
+++ b/pst/install-patch-ub.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Planescape: Torment Unfinished Business
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin WeiDU unrar
+
+setuptmp
+
+if [ ! -f "$PATCHDIR/pstub.rar" ]; then
+ echo "You need to download the fixpack from http://dl.spellholdstudios.net/pst-ub" 1>&2
+ echo "and put it in $PATCHDIR to install this patch" 1>&2
+ exit
+fi
+
+unrar x -o+ -cl "$PATCHDIR/pstub.rar" "$TARGETDIR" || die
+rm "$TARGETDIR/setup-pst-ub.exe"
+cd "$TARGETDIR"
+
+case "$LANGUAGE" in
+ "German" ) langno=1 ;;
+ "Spanish" ) langno=2 ;;
+ "Italian" ) langno=3 ;;
+ * ) langno=0 ;;
+esac
+
+# echo to install all manually as --yes assumes English
+echo -e "${langno}\nn\ni\ni\nn\n\n" \
+| WeiDU --continue setup-pst-ub.tp2 || die
+
+setperms "$TARGETDIR"
diff --git a/totsc/auto-totsc-installer.sh b/totsc/auto-totsc-installer.sh
new file mode 100755
index 0000000..f82114a
--- /dev/null
+++ b/totsc/auto-totsc-installer.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+source ../includes/generic-includes.sh
+source ../cd-includes.sh
+source ../patch-includes.sh
+source ../autoinstall-includes.sh
+
+parseargs "$@"
+
+echo "Checking CD version"
+CDMD5=$(md5sum $CDMOUNT/data1.cab|awk '{print $1}')
+
+case "$CDMD5" in
+ "e27d259ddc0171ff945dbba136e60309" )
+ FULLGAMENAME="Baldurs Gate Tales of the Sword Coast: 1CD UK version"
+ INSTALLSCRIPT=./install-totsc-1cd-uk.sh
+ OFFICIALPATCH=./install-totsc-patch-uk.sh
+ ;;
+ * )
+ echo "Unrecognised CD - please select Baldurs Gate version from menu"
+ # TODO: Add menu to show and select all known BG1 versions
+ exit 1
+ ;;
+esac
+
+echo "$FULLGAMENAME detected, installing"
+$INSTALLSCRIPT -i "$TARGETDIR" -c "$CDMOUNT" 1>/dev/null || diequietly
+if query "Do you want to install the official patch?" y; then
+ $OFFICIALPATCH -i "$TARGETDIR" -p "$PATCHDIR" 1>/dev/null || diequietly
+fi
+if query "Do you want to install the baldurdash fixes?" y; then
+ ./install-totsc-patch-baldurdash-fix.sh -i "$TARGETDIR" -p "$PATCHDIR" 1>/dev/null || diequietly
+ if [ "$LANGUAGE" = "English" ]; then
+ ./install-totsc-patch-baldurdash-text.sh -i "$TARGETDIR" -p "$PATCHDIR" 1>/dev/null || diequietly
+ fi
+fi
+if query "Do you want to remove unneeded windows files?" n; then
+ rm -f "$TARGETDIR"/*.exe
+ rm -f "$TARGETDIR"/*.url
+ rm -f "$TARGETDIR"/luaauto.cfg
+fi
+echo
+echo "$FULLGAMENAME installed successfully"
diff --git a/totsc/install-1cd-uk.sh b/totsc/install-1cd-uk.sh
new file mode 100755
index 0000000..d1d2ccb
--- /dev/null
+++ b/totsc/install-1cd-uk.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Tales of the Sword Coast 1CD version
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/cd-includes.sh"
+
+parseargs "$@"
+
+checkforbin unshield
+
+getcd 1 e27d259ddc0171ff945dbba136e60309 data1.cab
+
+mkdir -p "$TARGETDIR" || die
+
+unshield -L x $CDMOUNT/data1.cab -d "$TARGETDIR" || die
+
+cp $CDMOUNT/dialog.tlk "$TARGETDIR" || die
+
+mkdir -p "$TARGETDIR"/save || die
+cp -R $CDMOUNT/[Ss]ave/* "$TARGETDIR"/save || die
+
+cp -R "$TARGETDIR"/minimumdata/* "$TARGETDIR" || die
+rm -r "$TARGETDIR"/minimumdata
+
+cp -R "$TARGETDIR"/english/* "$TARGETDIR" || die
+rm -r "$TARGETDIR"/english
+
+cp -R "$CDMOUNT"/override/* "$TARGETDIR"/override/ || die
+
+mkdir -p "$TARGETDIR"/movies
+copylower "$CDMOUNT/cd6/" "$TARGETDIR"
+
+mkdir -p "$TARGETDIR"/mpsave
+
+setperms "$TARGETDIR"
diff --git a/totsc/install-patch-baldurdash-fix.sh b/totsc/install-patch-baldurdash-fix.sh
new file mode 100755
index 0000000..939d4f6
--- /dev/null
+++ b/totsc/install-patch-baldurdash-fix.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# BG1/TOTSC Baldurdash fix pack
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin unzip wget
+
+setuptmp
+
+getpatch http://www.baldurdash.org/LargeDownloads/BG1FixPack11.exe
+
+# unzip complains unnecessarily about skipping non-zip
+# part so don't print errors or die on failure
+unzip -L $TMPDIR/BG1FixPack11.exe -d $TMPDIR 2>/dev/null
+rm $TMPDIR/BG1FixPack11.exe $TMPDIR/bg1fixpack11readme.txt
+cp $TMPDIR/* "$TARGETDIR/override/" || die
+
+cleanuptmp
+setperms "$TARGETDIR"
diff --git a/totsc/install-patch-baldurdash-text.sh b/totsc/install-patch-baldurdash-text.sh
new file mode 100755
index 0000000..35fba39
--- /dev/null
+++ b/totsc/install-patch-baldurdash-text.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# BG1 TOTSC Baldurdash text pack
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+if [ "$LANGUAGE" != "English" ]; then
+ echo "The Baldurdash text pack is only available in English"
+ die
+fi
+
+checkforbin unzip wget
+
+setuptmp
+
+getpatch http://www.baldurdash.org/LargeDownloads/BG1TOSCGameTextUpdate11.exe
+
+# unzip complains unnecessarily about skipping non-zip
+# part so don't print errors or die on failure
+unzip -L $TMPDIR/BG1TOSCGameTextUpdate11.exe -d $TMPDIR 2>/dev/null
+cp $TMPDIR/dialog.tlk "$TARGETDIR/" || die
+
+cleanuptmp
+setperms "$TARGETDIR"
diff --git a/totsc/install-patch-intl.sh b/totsc/install-patch-intl.sh
new file mode 100755
index 0000000..4581c9d
--- /dev/null
+++ b/totsc/install-patch-intl.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# BG1 TOTSC official International patch
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin cabextract unshield wget
+
+setuptmp
+
+getpatch http://downloads.bioware.com/baldursgate1/BGTalesIntl5512.exe
+
+cabextract -L $TMPDIR/BGTalesIntl5512.exe -d $TMPDIR || die
+unshield -L x $TMPDIR/data1.cab -d $TMPDIR || die
+
+cp -R $TMPDIR/minimumdata/* "$TARGETDIR" || die
+
+cleanuptmp
+setperms "$TARGETDIR"
diff --git a/totsc/install-patch-uk.sh b/totsc/install-patch-uk.sh
new file mode 100755
index 0000000..b7cc2f2
--- /dev/null
+++ b/totsc/install-patch-uk.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# BG1 TOTSC official UK patch
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin cabextract unshield wget
+
+setuptmp
+
+getpatch http://downloads.bioware.com/baldursgate1/BGTalesUK5512.exe
+
+cabextract -L $TMPDIR/BGTalesUK5512.exe -d $TMPDIR || die
+unshield -L x $TMPDIR/data1.cab -d $TMPDIR || die
+
+cp -R $TMPDIR/minimumdata/* "$TARGETDIR" || die
+
+cleanuptmp
+setperms "$TARGETDIR"
diff --git a/totsc/install-patch-us.sh b/totsc/install-patch-us.sh
new file mode 100755
index 0000000..1c400d6
--- /dev/null
+++ b/totsc/install-patch-us.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# BG1 TOTSC official US/Canada patch
+
+scriptdir="$(dirname $0)"/..
+source "$scriptdir/includes/generic-includes.sh"
+source "$scriptdir/includes/patch-includes.sh"
+
+parseargs "$@"
+
+checkforbin cabextract unshield wget
+
+setuptmp
+
+getpatch http://downloads.bioware.com/baldursgate1/BGTalesUS5512.exe
+
+cabextract -L $TMPDIR/BGTalesUS5512.exe -d $TMPDIR || die
+unshield -L x $TMPDIR/data1.cab -d $TMPDIR || die
+
+cp -R $TMPDIR/minimumdata/* "$TARGETDIR" || die
+
+cleanuptmp
+setperms "$TARGETDIR"