Package osx dependencies separately from the main download; Game is now run from inside app bundle; Support dir used to cache downloads only
This commit is contained in:
@@ -16,17 +16,21 @@
|
||||
# along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
# Tweakable options
|
||||
#export MONO_LOG_LEVEL=debug
|
||||
GAME_PATH=~/Library/"Application Support"/OpenRA
|
||||
RA_MIXEN="http://open-ra.org/packages/ra-packages.zip"
|
||||
CNC_MIXEN="http://open-ra.org/packages/cnc-packages.zip"
|
||||
SUPPORT_PATH=~/Library/"Application Support"/OpenRA
|
||||
DEPS_PACKAGE="osx-deps-v1.zip"
|
||||
DEPS_URL="http://localhost/~paul/osx-deps-v1.zip"
|
||||
#RA_URL="http://open-ra.org/packages/ra-packages.zip"
|
||||
#CNC_URL="http://open-ra.org/packages/cnc-packages.zip"
|
||||
RA_URL="http://localhost/~paul/ra-packages.zip"
|
||||
CNC_URL="http://localhost/~paul/cnc-packages.zip"
|
||||
|
||||
# Internal options
|
||||
APP_PATH=`echo $0 | awk '{split($0,patharr,"/"); idx=1; while(patharr[idx+3] != "") { if (patharr[idx] != "/") {printf("%s/", patharr[idx]); idx++ }} }'`
|
||||
EXE_PATH=$APP_PATH/Contents/MacOS/
|
||||
RESOURCES_PATH=$APP_PATH/Contents/Resources
|
||||
GAME_PATH=$RESOURCES_PATH
|
||||
PAYLOAD=$RESOURCES_PATH/payload.zip
|
||||
VERSION=`cat "$APP_PATH/Contents/Resources/VERSION"`
|
||||
export LD_LIBRARY_PATH="$EXE_PATH/lib":$LD_LIBRARY_PATH
|
||||
@@ -61,11 +65,18 @@ EOT`
|
||||
# $5: download url
|
||||
function download_package
|
||||
{
|
||||
PWD=`pwd`
|
||||
if [ ! -d "$SUPPORT_PATH" ]; then
|
||||
mkdir -p "$SUPPORT_PATH"
|
||||
fi
|
||||
|
||||
cd "$SUPPORT_PATH"
|
||||
|
||||
if [ -e "downloads/${1}" ]; then
|
||||
mkdir -p "${2}"
|
||||
unzip -o "downloads/${1}" -d "${2}"
|
||||
else
|
||||
|
||||
pwd
|
||||
CONTINUE=`/usr/bin/osascript << EOT
|
||||
tell application "Finder"
|
||||
display dialog "OpenRA needs to download the ${4} game data.\nDownload size: ${3}" \
|
||||
@@ -78,14 +89,16 @@ EOT`
|
||||
if [ "$CONTINUE" != "Download" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "${2}"
|
||||
|
||||
/usr/bin/osascript << EOT
|
||||
tell application "Terminal"
|
||||
activate
|
||||
do script "cd \"${GAME_PATH}\"; curl --create-dirs -o \"./downloads/${1}\" \"${5}\"; touch \"downloads/done\"; exit;"
|
||||
do script "cd \"${SUPPORT_PATH}\"; curl --create-dirs -o \"./downloads/${1}\" \"${5}\"; touch \"downloads/done\"; exit;"
|
||||
end tell
|
||||
EOT
|
||||
|
||||
# Hack around osascript returning before the download finishes
|
||||
while [ ! -e "downloads/done" ]; do
|
||||
sleep 1
|
||||
@@ -97,23 +110,12 @@ EOT
|
||||
fi
|
||||
unzip -o "downloads/${1}" -d "${2}"
|
||||
fi
|
||||
cd "$PWD"
|
||||
}
|
||||
|
||||
# Install the game in the users Application Support directory if it doesn't exist
|
||||
if [ ! -e "$GAME_PATH/OpenRA.Game.exe" ]; then
|
||||
mkdir -p ~/Library/Application\ Support/OpenRA
|
||||
unzip "$PAYLOAD" -d "$GAME_PATH"
|
||||
|
||||
if [ ! -e "$GAME_PATH/OpenRA.Game.exe" ]; then
|
||||
display_error "Installation error" "Game setup failed"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Is the installed version older than the current version?
|
||||
INSTVER=`cat "$GAME_PATH/VERSION"`
|
||||
if [ $INSTVER -lt $VERSION ]; then
|
||||
echo "Updating installed version $INSTVER to $VERSION"
|
||||
unzip -o "$PAYLOAD" -d "$GAME_PATH"
|
||||
# Download and install game dependencies if needed
|
||||
if [[ ! -e "$EXE_PATH/mono" ]]; then
|
||||
download_package "$DEPS_PACKAGE" "$EXE_PATH" "17.2 Mb" "Game Dependencies" $DEPS_URL
|
||||
fi
|
||||
|
||||
# Prompt for the mod to run
|
||||
@@ -134,19 +136,20 @@ MOD="ra"
|
||||
if [ "$MODBUTTON" == "C&C" ]; then
|
||||
MOD="cnc"
|
||||
fi
|
||||
cd "$GAME_PATH"
|
||||
|
||||
|
||||
# Check that the game data is installed
|
||||
if [[ $MOD == "ra" && ! -e "mods/ra/packages/redalert.mix" ]]; then
|
||||
download_package "ra-packages.zip" "mods/ra/packages/" "10 Mb" "Red Alert" $RA_MIXEN
|
||||
if [[ $MOD == "ra" && ! -e "$GAME_PATH/mods/ra/packages/redalert.mix" ]]; then
|
||||
download_package "ra-packages.zip" "$GAME_PATH/mods/ra/packages/" "10 Mb" "Red Alert" $RA_URL
|
||||
fi
|
||||
|
||||
if [[ $MOD == "cnc" && ! -e "mods/cnc/packages/conquer.mix" ]]; then
|
||||
download_package "cnc-packages.zip" "mods/cnc/packages/" "5.9 Mb" "C&C" $CNC_MIXEN
|
||||
if [[ $MOD == "cnc" && ! -e "$GAME_PATH/mods/cnc/packages/conquer.mix" ]]; then
|
||||
download_package "cnc-packages.zip" "$GAME_PATH/mods/cnc/packages/" "5.9 Mb" "C&C" $CNC_URL
|
||||
fi
|
||||
|
||||
# Run the game
|
||||
${EXE_PATH}mono OpenRA.Game.exe InitialMods=$MOD
|
||||
cd "${GAME_PATH}"
|
||||
${EXE_PATH}mono "OpenRA.Game.exe" InitialMods=$MOD
|
||||
|
||||
# Did we crash?
|
||||
STATUS=$?
|
||||
|
||||
@@ -1,30 +1,26 @@
|
||||
#!/bin/sh
|
||||
# OpenRA Packaging script for osx
|
||||
# Creates a self contained app bundle that contains
|
||||
# all the dependencies required to run the game.
|
||||
# Packages all the dependencies required to run the game.
|
||||
# This script assumes that it is being run on osx >= 10.5
|
||||
# and that all the required dependencies are installed
|
||||
# and the dependant dlls exist in the system GAC.
|
||||
# $GAME_PATH in OpenRA.app/Contents/MacOS/OpenRA
|
||||
# specifies the game directory to load. This can point
|
||||
# anywhere on the filesystem.
|
||||
|
||||
# A list of the binaries that we want to be able to run
|
||||
DEPS_LOCAL="OpenRA.Game.exe OpenRA.Gl.dll OpenRA.FileFormats.dll"
|
||||
PACKAGING_DIR="osxbuild/launcher"
|
||||
PWD=`pwd`
|
||||
PACKAGING_PATH="$PWD/osxbuild"
|
||||
BINARY_PATH="$PACKAGING_PATH/deps"
|
||||
LIB_PATH="$BINARY_PATH/lib"
|
||||
SYSTEM_MONO="/Library/Frameworks/Mono.framework/Versions/2.6.3"
|
||||
|
||||
# dylibs referred to by dlls in the gac; won't show up to otool
|
||||
GAC_DYLIBS="$SYSTEM_MONO/lib/libMonoPosixHelper.dylib $SYSTEM_MONO/lib/libgdiplus.dylib "
|
||||
|
||||
####################################################################################
|
||||
EXE_DIR="$PACKAGING_DIR/OpenRA.app/Contents/MacOS"
|
||||
LIB_DIR="$EXE_DIR/lib"
|
||||
|
||||
function patch_mono {
|
||||
echo "Patching binary: "$1
|
||||
LIBS=$( otool -L $1 | grep /Library/Frameworks/Mono.framework/ | awk {'print $1'} )
|
||||
# Todo: fix the -id?
|
||||
for i in $LIBS; do
|
||||
install_name_tool -change $i @executable_path/lib/`basename $i` $1
|
||||
done
|
||||
@@ -37,9 +33,9 @@ function patch_mono {
|
||||
|
||||
for i in $LIBS; do
|
||||
FILE=`basename $i`
|
||||
if [ ! -e $LIB_DIR/$FILE ]; then
|
||||
cp $i $LIB_DIR
|
||||
patch_mono $LIB_DIR/$FILE
|
||||
if [ ! -e $LIB_PATH/$FILE ]; then
|
||||
cp $i $LIB_PATH
|
||||
patch_mono $LIB_PATH/$FILE
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -51,36 +47,29 @@ export CC="gcc -arch i386 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/Ma
|
||||
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig/
|
||||
export PATH=/sw/bin:/sw/sbin:$PATH
|
||||
|
||||
# Copy and patch mono
|
||||
echo "Creating app bundle..."
|
||||
|
||||
|
||||
# Create the directory tree and copy in our existing files
|
||||
mkdir -p $PACKAGING_DIR/OpenRA.app
|
||||
cp -r ./packaging/osx/OpenRA.app/* $PACKAGING_DIR/OpenRA.app/
|
||||
mkdir -p $LIB_DIR
|
||||
mkdir -p "$LIB_PATH"
|
||||
cp "$SYSTEM_MONO/bin/mono" "$BINARY_PATH"
|
||||
patch_mono "$BINARY_PATH/mono"
|
||||
|
||||
|
||||
cp "$SYSTEM_MONO/bin/mono" $EXE_DIR
|
||||
patch_mono "$EXE_DIR/mono"
|
||||
|
||||
# Copy the gac dylibs into the app bundle
|
||||
# Copy the gac dylibs=
|
||||
for i in $GAC_DYLIBS; do
|
||||
cp $i $LIB_DIR
|
||||
patch_mono $LIB_DIR/`basename $i`
|
||||
cp $i $LIB_PATH
|
||||
patch_mono $LIB_PATH/`basename $i`
|
||||
done
|
||||
|
||||
|
||||
# Find the dlls that are used by the game; copy them into the app bundle and patch/package any dependencies
|
||||
echo "Searching for dlls..."
|
||||
echo "Searching for dlls... (this will take a while)"
|
||||
|
||||
# This is a huge hack, but it works
|
||||
DLLS=`mkbundle --deps --static -z -c -o OpenRA $DEPS_LOCAL | grep "embedding: "`
|
||||
DLLS=`mkbundle --deps -c -o "$PACKAGING_PATH/bogus" $DEPS_LOCAL | grep "embedding: "`
|
||||
rm "$PACKAGING_PATH/bogus"
|
||||
for i in $DLLS; do
|
||||
if [ "$i" != "embedding:" ]; then
|
||||
cp $i $LIB_DIR
|
||||
cp $i $LIB_PATH
|
||||
if [ -e "$i.config" ]; then
|
||||
CONFIG=$LIB_DIR/"`basename $i`.config"
|
||||
CONFIG=$LIB_PATH/"`basename $i`.config"
|
||||
|
||||
echo "Patching config: $CONFIG"
|
||||
# Remove any references to the hardcoded mono framework; the game will look in the right location anyway
|
||||
@@ -94,18 +83,22 @@ done
|
||||
|
||||
# Remove the files that we want to run that we accidentally copied over
|
||||
for i in $DEPS_LOCAL; do
|
||||
rm "$LIB_DIR/$i"
|
||||
rm "$LIB_PATH/$i"
|
||||
done
|
||||
|
||||
|
||||
# Copy external frameworks
|
||||
echo "Copying Cg..."
|
||||
cp /Library/Frameworks/Cg.framework/Cg $LIB_DIR
|
||||
chmod 755 $LIB_DIR/Cg
|
||||
cp -X /Library/Frameworks/Cg.framework/Cg $LIB_PATH
|
||||
chmod 755 $LIB_PATH/Cg
|
||||
|
||||
echo "Copying SDL..."
|
||||
cp /Library/Frameworks/SDL.framework/SDL $LIB_DIR
|
||||
xattr -d com.apple.quarantine $LIB_DIR/SDL
|
||||
chmod 755 $LIB_DIR/SDL
|
||||
cp -X /Library/Frameworks/SDL.framework/SDL $LIB_PATH
|
||||
chmod 755 $LIB_PATH/SDL
|
||||
|
||||
cd "$BINARY_PATH"
|
||||
zip osx-deps-v1 -r -9 *
|
||||
mv osx-deps-v1.zip "$PACKAGING_PATH"
|
||||
rm -rf "$BINARY_PATH"
|
||||
|
||||
echo "All Done!"
|
||||
@@ -5,35 +5,29 @@
|
||||
|
||||
PWD=`pwd`
|
||||
PACKAGING_PATH="$PWD/osxbuild"
|
||||
LAUNCHER_PATH="$PACKAGING_PATH/launcher/OpenRA.app"
|
||||
SOURCE_PATH="$PWD/."
|
||||
BUNDLE_PATH="$SOURCE_PATH/packaging/osx/OpenRA.app"
|
||||
TARGET_PATH="$PACKAGING_PATH/OpenRA.app/Contents/Resources"
|
||||
|
||||
FILES="OpenRA.Game.exe OpenRA.Gl.dll OpenRA.FileFormats.dll FreeSans.ttf FreeSansBold.ttf titles.ttf shaders maps mods/ra mods/cnc"
|
||||
EXCLUDE="*.mdb ./mods/cnc/packages/*.mix ./mods/ra/packages/*.mix ./mods/cnc/packages/*.MIX ./mods/ra/packages/*.MIX"
|
||||
|
||||
# Copy source files into packaging dir
|
||||
PAYLOAD="$PACKAGING_PATH/payload"
|
||||
mkdir -p $PAYLOAD
|
||||
mkdir -p "$PAYLOAD/mods"
|
||||
mkdir -p $PACKAGING_PATH
|
||||
cp -r "$BUNDLE_PATH" "$PACKAGING_PATH/OpenRA.app"
|
||||
mkdir -p "$TARGET_PATH/mods"
|
||||
|
||||
for i in $FILES; do
|
||||
cp -RX "$i" "$PAYLOAD/$i"
|
||||
cp -R "$i" "$TARGET_PATH/$i"
|
||||
done
|
||||
|
||||
# Delete unwanted files
|
||||
cd $PAYLOAD
|
||||
cd $TARGET_PATH
|
||||
for i in $EXCLUDE; do
|
||||
find . -path "$i" -delete
|
||||
done
|
||||
date "+%Y%m%d%H%M" > "VERSION"
|
||||
zip payload -r -9 *
|
||||
|
||||
git describe --tags > "VERSION"
|
||||
cd $PACKAGING_PATH
|
||||
|
||||
# Move everything into the app bundle
|
||||
cp -r "$LAUNCHER_PATH" .
|
||||
cp "$PAYLOAD/payload.zip" "OpenRA.app/Contents/Resources/"
|
||||
cp "$PAYLOAD/VERSION" "OpenRA.app/Contents/Resources/"
|
||||
|
||||
rm -rf $PAYLOAD
|
||||
zip OpenRA -r -9 OpenRA.app
|
||||
#zip OpenRA -r -9 OpenRA.app
|
||||
echo "Done!"
|
||||
Reference in New Issue
Block a user