]> Dogcows Code - chaz/yoink/blobdiff - win32/makepackage.sh
now can create win32 portable packages
[chaz/yoink] / win32 / makepackage.sh
diff --git a/win32/makepackage.sh b/win32/makepackage.sh
new file mode 100755 (executable)
index 0000000..6cb1afa
--- /dev/null
@@ -0,0 +1,143 @@
+#!/bin/sh
+
+#
+# Yoink
+# Run this script to create a portable win32 package.
+#
+
+function showhelp()
+{
+       echo "Create a portable win32 package or installer."
+       echo "Usage: $0 [-h] [-i makensis] [-s strip] -d assets -V version -p prefix"
+       echo ""
+       echo "  -d  Specify the game assets to be included."
+       echo "  -h  Show this help an exit."
+       echo "  -i  To make an installer, specify the makensis program."
+       echo "  -V  Specify the version of the program to be packaged"
+       echo "  -s  To strip the binaries, specify the strip program."
+       echo "  -p  Specify the path to your toolchain installation."
+}
+
+while getopts ":V:hd:i:p:s:" opt
+do
+       case $opt in
+               V)
+                       VERSION="$OPTARG"
+                       ;;
+               d)
+                       ASSETS="$OPTARG"
+                       ;;
+               h)
+                       showhelp
+                       exit 0
+                       ;;
+               i)
+                       MAKENSIS="$OPTARG"
+                       ;;
+               p)
+                       PREFIX="$OPTARG"
+                       ;;
+               s)
+                       STRIP="$OPTARG"
+                       ;;
+               \?)
+                       echo "Invalid option: -$OPTARG" >&2
+                       showhelp
+                       exit 1
+                       ;;
+       esac
+done
+
+if test "x$ASSETS" = x || test "x$VERSION" = x || test "x$PREFIX" = x
+then
+       showhelp
+       exit 1
+fi
+
+function die()
+{
+       rm -rf "$BUILD"
+       echo "die:" $@
+       exit 1
+}
+
+ROOT="$PWD"
+BUILD="$PWD/tmp-$$"
+NAME="yoink-$VERSION"
+ARCHIVE="$BUILD/$NAME"
+INSTALLER_SCRIPT="$ROOT/win32/yoink.nsi"
+
+MAN2HTML="$ROOT/doc/man2html.sh"
+UNIX2DOS="$ROOT/win32/unix2dos.sh"
+
+DLLS="libogg-0 libpng14-14 libvorbis-0 libvorbisfile-3 lua51 OpenAL32 SDL zlib1"
+
+
+if test ! -f "src/version.c"
+then
+       echo "Run the script from the repository root directory."
+       exit 1
+fi
+
+if ! mkdir "$BUILD"
+then
+       "The temp directory $BUILD could not be created."
+       exit 1
+fi
+mkdir -p "$ARCHIVE"
+
+
+cp -f "$ROOT/src/yoink.exe" "$ARCHIVE" || die "copying yoink.exe"
+test "x$STRIP" != x && "$STRIP" "$ARCHIVE/yoink.exe"
+
+for dll in $DLLS
+do
+       cp -f "$PREFIX/bin/$dll.dll" "$ARCHIVE" || die "copying $dll"
+       test "x$STRIP" != x && "$STRIP" "$ARCHIVE/$dll.dll"
+done
+
+for asset in $ASSETS
+do
+       cp -f --parents "data/$asset" "$ARCHIVE"
+done
+
+for doc in AUTHORS ChangeLog COPYING README TODO
+do
+       "$UNIX2DOS" "$doc" "$ARCHIVE/$doc.txt" || die "unix2dos $doc"
+done
+
+"$MAN2HTML" -f -o "$ARCHIVE/Manual.html"
+"$UNIX2DOS" "$ARCHIVE/Manual.html"
+
+cp -rf "$ROOT/doc/licenses" "$ARCHIVE" || die "copying doc/licenses"
+cd "$ARCHIVE/licenses"
+for license in $(ls)
+do
+       (mv "$license" "$license.txt" && "$UNIX2DOS" "$license.txt") \
+               || die "moving and unix2dos $license"
+done
+cd "$ROOT"
+
+
+if test "x$MAKENSIS" = x
+then
+# build the portable archive
+       cd "$BUILD"
+       zip -r $NAME.zip $NAME || die "zipping portable archive"
+       cd "$ROOT"
+       mv "$BUILD/$NAME.zip" .
+       echo "Done! Package saved to $NAME.zip."
+else
+# build an installer
+       cd "$BULID"
+       "$MAKENSIS" "$INSTALLER_SCRIPT" \
+               -DINSTALLFILES="$NAME" -DVERSION="$VERSION" \
+               || die "running '$MAKENSIS'"
+       cd "$ROOT"
+       mv "$BUILD/$NAME.exe" .
+       echo "Done! Installer saved to $NAME.exe."
+fi
+
+
+rm -rf "$BUILD"
+
This page took 0.022295 seconds and 4 git commands to generate.