Navigation Menu

Skip to content

Commit

Permalink
Initial shot at standalone postal 1 and postal 2 installers.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 20, 2009
1 parent 870100a commit d03e6ea
Show file tree
Hide file tree
Showing 8 changed files with 596 additions and 0 deletions.
207 changes: 207 additions & 0 deletions examples/postal1/make.sh
@@ -0,0 +1,207 @@
#!/bin/sh

# This script is not robust for all platforms or situations. Use as a rough
# example, but invest effort in what it's trying to do, and what it produces.
# (make sure you don't build in features you don't need, etc).

# Stop if anything produces an error.
set -e

DEBUG=0
if [ "$1" = "--debug" ]; then
echo "debug build!"
DEBUG=1
fi

if [ ! -d data/res ]; then
echo "We don't see data/res ..."
echo " Either you're in the wrong directory, or you didn't copy the"
echo " install data into here (it's unreasonably big to store it in"
echo " revision control for no good reason)."
exit 1
fi

APPNAME="Postal 1 Installer"

# I use a "cross compiler" to build binaries that are isolated from the
# particulars of my Linux workstation's current distribution. This both
# keeps me at a consistent ABI for generated binaries and prevent subtle
# dependencies from leaking in.
# You may not care about this at all. In which case, just use the
# CC=gcc and CXX=g++ lines instead.
CC=/usr/bin/gcc
CXX=/usr/bin/g++
#CC=/opt/crosstool/gcc-3.3.6-glibc-2.3.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/gcc
#CXX=/opt/crosstool/gcc-3.3.6-glibc-2.3.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/g++

OSTYPE=`uname -s`
if [ "$OSTYPE" = "Linux" ]; then
NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
let NCPU=$NCPU+1
elif [ "$OSTYPE" = "Darwin" ]; then
NCPU=`sysctl -n hw.ncpu`
elif [ "$OSTYPE" = "SunOS" ]; then
NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
else
NCPU=1
fi

if [ "x$NCPU" = "x" ]; then
NCPU=1
fi
if [ "x$NCPU" = "x0" ]; then
NCPU=1
fi

echo "Will use make -j$NCPU. If this is wrong, check NCPU at top of script."

# Show everything that we do here on stdout.
set -x

if [ "$DEBUG" = "1" ]; then
LUASTRIPOPT=
BUILDTYPE=Debug
TRUEIFDEBUG=TRUE
FALSEIFDEBUG=FALSE
else
LUASTRIPOPT=-s
BUILDTYPE=MinSizeRel
TRUEIFDEBUG=FALSE
FALSEIFDEBUG=TRUE
fi

# Clean up previous run, build fresh dirs for Base Archive.
rm -rf image postal1-installer pdata.zip
mkdir image
mkdir image/guis
mkdir image/scripts
mkdir image/data
mkdir image/meta

# Build MojoSetup binaries from scratch.
# YOU ALWAYS NEED THE LUA PARSER IF YOU WANT UNINSTALL SUPPORT!
cd ../..
rm -rf cmake-build
mkdir cmake-build
cd cmake-build
cmake \
-DCMAKE_BUILD_TYPE=$BUILDTYPE \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DMOJOSETUP_MULTIARCH=FALSE \
-DMOJOSETUP_ARCHIVE_ZIP=TRUE \
-DMOJOSETUP_ARCHIVE_TAR=FALSE \
-DMOJOSETUP_ARCHIVE_TAR_BZ2=FALSE \
-DMOJOSETUP_ARCHIVE_TAR_GZ=FALSE \
-DMOJOSETUP_GUI_GTKPLUS2=TRUE \
-DMOJOSETUP_GUI_GTKPLUS2_STATIC=FALSE \
-DMOJOSETUP_GUI_NCURSES=TRUE \
-DMOJOSETUP_GUI_NCURSES_STATIC=FALSE \
-DMOJOSETUP_GUI_STDIO=TRUE \
-DMOJOSETUP_GUI_STDIO_STATIC=TRUE \
-DMOJOSETUP_GUI_WWW=FALSE \
-DMOJOSETUP_GUI_WWW_STATIC=FALSE \
-DMOJOSETUP_LUALIB_DB=FALSE \
-DMOJOSETUP_LUALIB_IO=FALSE \
-DMOJOSETUP_LUALIB_MATH=FALSE \
-DMOJOSETUP_LUALIB_OS=FALSE \
-DMOJOSETUP_LUALIB_PACKAGE=FALSE \
-DMOJOSETUP_LUA_PARSER=TRUE \
-DMOJOSETUP_IMAGE_BMP=TRUE \
-DMOJOSETUP_IMAGE_JPG=FALSE \
-DMOJOSETUP_IMAGE_PNG=FALSE \
-DMOJOSETUP_INTERNAL_BZLIB=FALSE \
-DMOJOSETUP_INTERNAL_ZLIB=TRUE \
-DMOJOSETUP_URL_HTTP=FALSE \
-DMOJOSETUP_URL_FTP=FALSE \
..
make -j$NCPU

# Strip the binaries and GUI plugins, put them somewhere useful.
if [ "$DEBUG" != "1" ]; then
strip ./mojosetup
fi

mv ./mojosetup ../examples/postal1/postal1-installer
for feh in *.so *.dll *.dylib ; do
if [ -f $feh ]; then
if [ "$DEBUG" != "1" ]; then
strip $feh
fi
mv $feh ../examples/postal1/image/guis
fi
done

# Compile the Lua scripts, put them in the base archive.
for feh in ../scripts/*.lua ; do
./mojoluac $LUASTRIPOPT -o ../examples/postal1/image/scripts/${feh}c $feh
done

# Don't want the example config...use our's instead.
rm -f ../examples/postal1/image/scripts/config.luac
./mojoluac $LUASTRIPOPT -o ../examples/postal1/image/scripts/config.luac ../examples/postal1/scripts/config.lua

# Don't want the example app_localization...use our's instead.
rm -f ../examples/postal1/image/scripts/app_localization.luac
./mojoluac $LUASTRIPOPT -o ../examples/postal1/image/scripts/app_localization.luac ../examples/postal1/scripts/app_localization.lua

# Fill in the rest of the Base Archive...
cd ../examples/postal1
cp -R data/* image/data/
cp meta/* image/meta/

# Need these scripts to do things like install menu items, etc, on Unix.
if [ "$OSTYPE" = "Linux" ]; then
USE_XDG_UTILS=1
fi
if [ "$OSTYPE" = "SunOS" ]; then
USE_XDG_UTILS=1
fi

if [ "x$USE_XDG_UTILS" = "x1" ]; then
mkdir image/meta/xdg-utils
cp ../../meta/xdg-utils/* image/meta/xdg-utils/
chmod a+rx image/meta/xdg-utils/*
fi

if [ "$OSTYPE" = "Darwin" ]; then
# Build up the application bundle for Mac OS X...
APPBUNDLE="$APPNAME.app"
rm -rf "$APPBUNDLE"
cp -Rv ../../misc/MacAppBundleSkeleton "$APPBUNDLE"
perl -w -pi -e 's/YOUR_APPLICATION_NAME_HERE/'"$APPNAME"'/g;' "${APPBUNDLE}/Contents/Info.plist"
mv postal1-installer "${APPBUNDLE}/Contents/MacOS/mojosetup"
mv image/* "${APPBUNDLE}/Contents/MacOS/"
rmdir image
ibtool --compile "${APPBUNDLE}/Contents/Resources/MojoSetup.nib" ../../misc/MojoSetup.xib
else
# Make a .zip archive of the Base Archive dirs and nuke the originals...
cd image
zip -9r ../pdata.zip *
cd ..
rm -rf image
# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./postal1-installer
rm -f pdata.zip
fi

# ...and that's that.
set +e
set +x
echo "Successfully built!"

if [ "$DEBUG" = "1" ]; then
echo
echo
echo
echo 'ATTENTION: THIS IS A DEBUG BUILD!'
echo " DON'T DISTRIBUTE TO THE PUBLIC."
echo ' THIS IS PROBABLY BIGGER AND SLOWER THAN IT SHOULD BE.'
echo ' YOU HAVE BEEN WARNED!'
echo
echo
echo
fi

exit 0

Binary file added examples/postal1/meta/splash.bmp
Binary file not shown.
33 changes: 33 additions & 0 deletions examples/postal1/scripts/app_localization.lua
@@ -0,0 +1,33 @@
-- Lines starting with "--" are comments in this file.
-- You should add your installer's strings here, instead of localization.lua,
-- but localization.lua has instructions on how this file is formatted.

MojoSetup.applocalization = {
["Uninstall complete"] = {
en = "Uninstall complete. You may also delete '.postal1' in your home directory to remove personal savegames and settings.",
de = "Deinstallation komplett. Du kannst auch '.postal1' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.",
es = "Desinstalación completa. Puedes borrar '.postal1' en tu directorio home para borrar configuraciones personales y tus juegos grabados.",
pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć '.postal1' z domowego katalogu.",
it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella '.postal1' nella tua directory home.",
};

["Postal README"] = {
de = "Postal-README",
es = "LEEME",
pl = "Postal README",
it = "Informazioni su Postal",
};

["Postal License"] = {
en_GB = "Postal Licence",
en_CA = "Postal Licence",
de = "Postal-Lizenz",
es = "Licencia de uso de Postal",
pl = "Licencja Postal",
it = "Licenza di Postal",
};

};

-- end of app_localization.lua ...

60 changes: 60 additions & 0 deletions examples/postal1/scripts/config.lua
@@ -0,0 +1,60 @@
local GAME_INSTALL_SIZE = 245613846;

local _ = MojoSetup.translate

Setup.Package
{
vendor = "runningwithscissors.com",
id = "postal1",
description = _("Postal 1"),
version = "1.0",
splash = "splash.bmp",
superuser = false,
write_manifest = true,
support_uninstall = true,
recommended_destinations =
{
MojoSetup.info.homedir,
"/opt/games",
"/usr/local/games"
},

postinstall = function(package)
MojoSetup.launchbrowser(MojoSetup.destination .. "/postal1_guide.html")
end,

Setup.Eula
{
description = _("Postal License"),
source = _("postal1_license.txt")
},

Setup.Option
{
value = true,
required = true,
disabled = false,
bytes = GAME_INSTALL_SIZE,
description = _("Postal 1"),

Setup.File
{
-- Just install everything we see...
},

Setup.DesktopMenuItem
{
disabled = false,
name = _("Postal 1"),
genericname = _("Postal 1"),
tooltip = _("Politically incorrect shoot-em-up from Running With Scissors"),
builtin_icon = false,
icon = "rws.png",
commandline = "%0/postal1",
category = "Game"
}
}
}

-- end of config.lua ...

0 comments on commit d03e6ea

Please sign in to comment.