summaryrefslogtreecommitdiff
path: root/games/wargus/extract-warcraft2
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2014-05-09 17:33:33 +0700
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2014-05-12 07:36:01 +0700
commit5195e7fd091ef8467fe2c04354175a3dc6b8ea2f (patch)
tree1d8120f13036bb1ae1c9be3f40df3f4cb6289e4d /games/wargus/extract-warcraft2
parent327a851e33ad34eef2c43cbb23c88ad9bcff13f5 (diff)
downloadslackbuilds-5195e7fd091ef8467fe2c04354175a3dc6b8ea2f.tar.gz
games/wargus: Added (Warcraft II data game set).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'games/wargus/extract-warcraft2')
-rw-r--r--games/wargus/extract-warcraft2129
1 files changed, 129 insertions, 0 deletions
diff --git a/games/wargus/extract-warcraft2 b/games/wargus/extract-warcraft2
new file mode 100644
index 0000000000..6ede653d18
--- /dev/null
+++ b/games/wargus/extract-warcraft2
@@ -0,0 +1,129 @@
+#!/bin/sh
+
+DEFAULTDEST="/usr/share/games/stratagus/wargus"
+
+SOURCE="$1"
+DEST="${2:-$DEFAULTDEST}"
+WARTOOL="${WARTOOL:-wartool}"
+
+SELF="$( basename "$0" )"
+if [ -z "$SOURCE" ]; then
+ cat <<EOF
+$SELF - extract game data files from Warcraft II
+
+Usage: $SELF [source] <dest>
+
+source is one of:
+
+- A block device node or symlink to one (e.g. /dev/cdrom). The
+ device must contain a Warcraft II CD-ROM.
+
+- An ISO image of the Warcraft II CD-ROM.
+
+- A directory containing an installed copy of Warcraft II.
+
+- A zip, rar, 7z, or tar.(gz|xz|bz2) archive containing either the
+ contents of the Warcraft II CD-ROM or an installed copy of the game
+ (but NOT an archive containing an ISO image).
+
+By "Warcraft II", we mean the original DOS version (or the expansion
+pack for the DOS version), *not* the Battle.net edition. The expansion
+is probably preferable (has more maps), but either one will work.
+
+Filename case inside archives is ignored.
+
+dest is the optional directory to output extracted data to. If not
+given, $DEFAULTDEST is used.
+
+Since this script wants to do things like mount CDs and write to
+/usr/share, it generally needs to be run as root.
+
+For extracting 7z or rar archives, you will need p7zip or unrar.
+
+This script was written by B. Watson for the SlackBuilds.org
+project and is released under the terms of the WTFPL. See
+http://www.wtfpl.net/txt/copying/ for details.
+EOF
+ exit 0
+fi
+
+# try to figure out what $SOURCE is. It can be the CD-ROM, an ISO
+# image, an installed directory, or a zip/rar/7z/tar/etc archive
+# of an installed dir or the contents of the CD.
+
+# NOT supported: archives containing the .iso image.
+
+SOURCE=$( readlink -q -n -f "$SOURCE" )
+TYPE=$( file "$SOURCE" )
+
+SRCDIR=$( mktemp -d -t extract-warcraft2.XXXXXX )
+
+case "$TYPE" in
+ *directory*) rm -rf "$SRCDIR" ; SRCDIR="$SOURCE" ; KEEPSRC="yes" ;;
+
+ *block*special*)
+ mount "$SOURCE" "$SRCDIR"
+ MOUNTED="$SRCDIR"
+ ROPT="-r"
+ ;;
+
+ *ISO*9660*data*)
+ mount -o loop "$SOURCE" "$SRCDIR"
+ MOUNTED="$SRCDIR"
+ ;;
+
+ *7-zip*)
+ ( cd "$SRCDIR" && 7za x "$SOURCE" )
+ ;;
+
+ *RAR*arch*)
+ ( cd "$SRCDIR" && unrar x "$SOURCE" )
+ ;;
+
+ *Zip*arch*)
+ ( cd "$SRCDIR" && unzip "$SOURCE" )
+ ;;
+
+ *gzip*|*bzip2*|*XZ*)
+ ( cd "$SRCDIR" && tar xvf "$SOURCE" )
+ ;;
+
+ *)
+ echo "Can't figure out what '$SOURCE' is, aborting" 1>&2
+ exit 1
+ ;;
+esac
+
+# now find the data dir, if it exists
+DATADIR="$SRCDIR"
+for i in data DATA Data; do
+ if [ -d "$SRCDIR/$i" ]; then
+ DATADIR="$SRCDIR/$i"
+ fi
+done
+
+# sanity check the data dir we think we found
+for i in REZDAT rezdat Rezdat; do
+ if [ -e "$DATADIR/$i.war" ] ||
+ [ -e "$DATADIR/$i.WAR" ] ||
+ [ -e "$DATADIR/$i.War" ]
+ then
+ FOUND=yes
+ fi
+done
+
+if [ "$FOUND" != "yes" ]; then
+ echo "Can't find rezdat.war in $DATADIR, aborting" 1>&2 &&
+ exit 1
+fi
+
+mkdir -p $DEST
+"$WARTOOL" -m -v $ROPT "$DATADIR" "$DEST"
+
+if [ "$MOUNTED" != "" ]; then
+ umount "$MOUNTED"
+fi
+
+if [ "$KEEPSRC" != "yes" ]; then
+ rm -rf "$SRCDIR"
+fi