Add Linux AppImage packaging.
Requires a system installation of mono >= 4.2 but bundles all other requirements.
This commit is contained in:
parent
bea1216f8b
commit
0ebff73e8e
@ -30,6 +30,7 @@ deploy:
|
||||
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}.exe
|
||||
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-macOS.zip
|
||||
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-winportable.zip
|
||||
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}.AppImage
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
This repository contains a bare development environment for creating a new mod/game on the [OpenRA](https://github.com/OpenRA/OpenRA) engine.
|
||||
|
||||
These scripts and support files wrap and automatically manage a copy of the OpenRA game engine and common files, and provide entrypoints to run development versions of your project and to generate platform-specific installers for your players.
|
||||
These scripts and support files wrap and automatically manage a copy of the OpenRA game engine and common files during development, and generates Windows installers, macOS .app bundles, and Linux [AppImages](https://appimage.org/) for distribution.
|
||||
|
||||
The key scripts in this SDK are:
|
||||
|
||||
|
||||
11
mod.config
11
mod.config
@ -41,6 +41,7 @@ TRAVIS_TEST_PACKAGING="False"
|
||||
# The prefix used for the installer filenames.
|
||||
# - Windows installers will be named as {PACKAGING_INSTALLER_NAME}-{TAG}.exe
|
||||
# - macOS installers will be named as {PACKAGING_INSTALLER_NAME}-{TAG}.zip
|
||||
# - Linux .appimages will be named as {PACKAGING_INSTALLER_NAME}-${TAG}.AppImage
|
||||
PACKAGING_INSTALLER_NAME="ExampleMod"
|
||||
|
||||
# The human-readable name for this project.
|
||||
@ -53,6 +54,7 @@ PACKAGING_INSTALLER_NAME="ExampleMod"
|
||||
# - Windows start menu
|
||||
# - Windows desktop shortcut
|
||||
# - Windows "Programs and Features" list
|
||||
# - Linux launcher shortcut
|
||||
PACKAGING_DISPLAY_NAME="Example Mod"
|
||||
|
||||
# The URL for the project homepage.
|
||||
@ -81,6 +83,9 @@ PACKAGING_WINDOWS_INSTALL_DIR_NAME="OpenRA Example Mod"
|
||||
# This should not contain spaces or special characters.
|
||||
PACKAGING_WINDOWS_REGISTRY_KEY="OpenRAExampleMod"
|
||||
|
||||
# The git tag to use for the AppImage dependencies.
|
||||
PACKAGING_APPIMAGE_DEPENDENCIES_TAG="20180408"
|
||||
|
||||
##############################################################################
|
||||
# Advanced Configuration
|
||||
#
|
||||
@ -105,3 +110,9 @@ PACKAGING_OSX_LAUNCHER_SOURCE="https://github.com/OpenRA/OpenRALauncherOSX/relea
|
||||
|
||||
# Temporary file name used when downloading the OpenRA macOS launcher files.
|
||||
PACKAGING_OSX_LAUNCHER_TEMP_ARCHIVE_NAME="launcher.zip"
|
||||
|
||||
# The url to download the OpenRA AppImage dependencies.
|
||||
PACKAGING_APPIMAGE_DEPENDENCIES_SOURCE="https://github.com/OpenRA/AppImageSupport/releases/download/${PACKAGING_APPIMAGE_DEPENDENCIES_TAG}/libs.tar.bz2"
|
||||
|
||||
# Temporary file name used when downloading the OpenRA AppImage dependencies.
|
||||
PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME="libs.tar.bz2"
|
||||
|
||||
125
packaging/linux/buildpackage.sh
Executable file
125
packaging/linux/buildpackage.sh
Executable file
@ -0,0 +1,125 @@
|
||||
#!/bin/bash
|
||||
# OpenRA packaging script for Linux (AppImage)
|
||||
set -e
|
||||
|
||||
command -v make >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires make."; exit 1; }
|
||||
command -v python >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires python."; exit 1; }
|
||||
command -v tar >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires tar."; exit 1; }
|
||||
command -v curl >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires curl."; exit 1; }
|
||||
|
||||
if [ $# -eq "0" ]; then
|
||||
echo "Usage: `basename $0` version [outputdir]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PACKAGING_DIR=$(python -c "import os; print(os.path.dirname(os.path.realpath('$0')))")
|
||||
TEMPLATE_ROOT="${PACKAGING_DIR}/../../"
|
||||
|
||||
# shellcheck source=mod.config
|
||||
. "${TEMPLATE_ROOT}/mod.config"
|
||||
|
||||
if [ -f "${TEMPLATE_ROOT}/user.config" ]; then
|
||||
# shellcheck source=user.config
|
||||
. "${TEMPLATE_ROOT}/user.config"
|
||||
fi
|
||||
|
||||
if [ "${INCLUDE_DEFAULT_MODS}" = "True" ]; then
|
||||
echo "Cannot generate installers while INCLUDE_DEFAULT_MODS is enabled."
|
||||
echo "Make sure that this setting is disabled in both your mod.config and user.config."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TAG="$1"
|
||||
if [ $# -eq "1" ]; then
|
||||
OUTPUTDIR=$(python -c "import os; print(os.path.realpath('.'))")
|
||||
else
|
||||
OUTPUTDIR=$(python -c "import os; print(os.path.realpath('$2'))")
|
||||
fi
|
||||
|
||||
BUILTDIR="${PACKAGING_DIR}/${PACKAGING_INSTALLER_NAME}.appdir"
|
||||
|
||||
# Set the working dir to the location of this script
|
||||
cd "${PACKAGING_DIR}"
|
||||
|
||||
pushd "${TEMPLATE_ROOT}" > /dev/null
|
||||
|
||||
if [ ! -f "${ENGINE_DIRECTORY}/Makefile" ]; then
|
||||
echo "Required engine files not found."
|
||||
echo "Run \`make\` in the mod directory to fetch and build the required files, then try again.";
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "${OUTPUTDIR}" ]; then
|
||||
echo "Output directory '${OUTPUTDIR}' does not exist.";
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Building core files"
|
||||
|
||||
make version VERSION="${TAG}"
|
||||
|
||||
pushd "${ENGINE_DIRECTORY}" > /dev/null
|
||||
make linux-dependencies
|
||||
make core SDK="-sdk:4.5"
|
||||
make install-engine prefix="usr" DESTDIR="${BUILTDIR}/"
|
||||
make install-common-mod-files prefix="usr" DESTDIR="${BUILTDIR}/"
|
||||
|
||||
popd > /dev/null
|
||||
popd > /dev/null
|
||||
|
||||
# Add native libraries
|
||||
echo "Downloading dependencies"
|
||||
curl -s -L -o "${PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME}" -O "${PACKAGING_APPIMAGE_DEPENDENCIES_SOURCE}" || exit 3
|
||||
tar xf "${PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME}"
|
||||
|
||||
curl -s -L -O https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
|
||||
chmod a+x appimagetool-x86_64.AppImage
|
||||
|
||||
echo "Building AppImage"
|
||||
|
||||
# Add mod files
|
||||
cp -r "${TEMPLATE_ROOT}/mods/"* "${BUILTDIR}/usr/lib/openra/mods"
|
||||
|
||||
install -Dm 0755 libSDL2.so "${BUILTDIR}/usr/lib/openra/"
|
||||
install -Dm 0644 include/SDL2-CS.dll.config "${BUILTDIR}/usr/lib/openra/"
|
||||
install -Dm 0755 libopenal.so "${BUILTDIR}/usr/lib/openra/"
|
||||
install -Dm 0644 include/OpenAL-CS.dll.config "${BUILTDIR}/usr/lib/openra/"
|
||||
install -Dm 0755 liblua.so "${BUILTDIR}/usr/lib/openra/"
|
||||
install -Dm 0644 include/Eluant.dll.config "${BUILTDIR}/usr/lib/openra/"
|
||||
|
||||
# Add launcher and icons
|
||||
sed "s/{MODID}/${MOD_ID}/g" include/AppRun.in | sed "s/{MODNAME}/${PACKAGING_DISPLAY_NAME}/g" > AppRun.temp
|
||||
install -m 0755 AppRun.temp "${BUILTDIR}/AppRun"
|
||||
|
||||
sed "s/{MODID}/${MOD_ID}/g" include/mod.desktop.in | sed "s/{MODNAME}/${PACKAGING_DISPLAY_NAME}/g" | sed "s/{TAG}/${TAG}/g" > temp.desktop
|
||||
install -Dm 0755 temp.desktop "${BUILTDIR}/usr/share/applications/openra-${MOD_ID}.desktop"
|
||||
install -m 0755 temp.desktop "${BUILTDIR}/openra-${MOD_ID}.desktop"
|
||||
|
||||
sed "s/{MODID}/${MOD_ID}/g" include/mod-mimeinfo.xml.in | sed "s/{TAG}/${TAG}/g" > temp.xml
|
||||
install -Dm 0755 temp.xml "${BUILTDIR}/usr/share/mime/packages/openra-${MOD_ID}.xml"
|
||||
|
||||
if [ -f "${PACKAGING_DIR}/mod_scalable.svg" ]; then
|
||||
install -Dm644 "${PACKAGING_DIR}/mod_scalable.svg" "${BUILTDIR}/usr/share/icons/hicolor/scalable/apps/openra-${MOD_ID}.svg"
|
||||
fi
|
||||
|
||||
for i in 16x16 32x32 48x48 64x64 128x128 256x256 512x512 1024x1024; do
|
||||
if [ -f "${PACKAGING_DIR}/mod_${i}.png" ]; then
|
||||
install -Dm644 "${PACKAGING_DIR}/mod_${i}.png" "${BUILTDIR}/usr/share/icons/hicolor/${i}/apps/openra-${MOD_ID}.png"
|
||||
install -m644 "${PACKAGING_DIR}/mod_${i}.png" "${BUILTDIR}/openra-${MOD_ID}.png"
|
||||
fi
|
||||
done
|
||||
|
||||
install -d "${BUILTDIR}/usr/bin"
|
||||
|
||||
sed "s/{MODID}/${MOD_ID}/g" include/mod.in | sed "s/{TAG}/${TAG}/g" | sed "s/{MODNAME}/${PACKAGING_DISPLAY_NAME}/g" | sed "s/{MODINSTALLERNAME}/${PACKAGING_INSTALLER_NAME}/g" | sed "s|{MODFAQURL}|${PACKAGING_FAQ_URL}|g" > openra-mod.temp
|
||||
install -m 0755 openra-mod.temp "${BUILTDIR}/usr/bin/openra-${MOD_ID}"
|
||||
|
||||
sed "s/{MODID}/${MOD_ID}/g" include/mod-server.in > openra-mod-server.temp
|
||||
install -m 0755 openra-mod-server.temp "${BUILTDIR}/usr/bin/openra-${MOD_ID}-server"
|
||||
|
||||
# travis-ci doesn't support mounting FUSE filesystems so extract and run the contents manually
|
||||
./appimagetool-x86_64.AppImage --appimage-extract
|
||||
ARCH=x86_64 ./squashfs-root/AppRun "${BUILTDIR}" "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}.AppImage"
|
||||
|
||||
# Clean up
|
||||
rm -rf openra-mod.temp openra-mod-server.temp temp.desktop temp.xml AppRun.temp libSDL2.so libopenal.so liblua.so appimagetool-x86_64.AppImage squashfs-root "${PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME}" "${BUILTDIR}"
|
||||
36
packaging/linux/include/AppRun.in
Executable file
36
packaging/linux/include/AppRun.in
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Make sure the user has a sufficiently recent version of mono on the PATH
|
||||
MINIMUM_MONO_VERSION="4.2"
|
||||
|
||||
make_version() {
|
||||
echo "$1" | tr '.' '\n' | head -n 4 | xargs printf "%03d%03d%03d%03d";
|
||||
}
|
||||
|
||||
mono_missing_or_old() {
|
||||
command -v mono >/dev/null 2>&1 || return 0
|
||||
MONO_VERSION=$(mono --version | head -n1 | cut -d' ' -f5)
|
||||
[ "$(make_version "${MONO_VERSION}")" -lt "$(make_version "${MINIMUM_MONO_VERSION}")" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
if mono_missing_or_old; then
|
||||
if command -v zenity > /dev/null
|
||||
then
|
||||
zenity --no-wrap --error --title "{MODNAME}" --text "{MODNAME} requires Mono ${MINIMUM_MONO_VERSION} or greater.\nPlease install Mono using your system package manager."
|
||||
else
|
||||
printf "{MODNAME} requires Mono %s or greater.\nPlease install Mono using your system package manager.\n" "${MINIMUM_MONO_VERSION}"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run the game or server
|
||||
HERE="$(dirname "$(readlink -f "${0}")")"
|
||||
export PATH="${HERE}"/usr/bin/:"${PATH}"
|
||||
export XDG_DATA_DIRS="${HERE}"/usr/share/:"${XDG_DATA_DIRS}"
|
||||
|
||||
if [ -n "$1" ] && [ "$1" = "--server" ]; then
|
||||
exec "openra-{MODID}-server" "$@"
|
||||
else
|
||||
exec "openra-{MODID}" "$@"
|
||||
fi
|
||||
3
packaging/linux/include/Eluant.dll.config
Normal file
3
packaging/linux/include/Eluant.dll.config
Normal file
@ -0,0 +1,3 @@
|
||||
<configuration>
|
||||
<dllmap os="linux" dll="lua51.dll" target="./liblua.so" />
|
||||
</configuration>
|
||||
4
packaging/linux/include/OpenAL-CS.dll.config
Normal file
4
packaging/linux/include/OpenAL-CS.dll.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<dllmap dll="soft_oal.dll" os="linux" target="./libopenal.so"/>
|
||||
</configuration>
|
||||
4
packaging/linux/include/SDL2-CS.dll.config
Normal file
4
packaging/linux/include/SDL2-CS.dll.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<dllmap os="linux" dll="SDL2.dll" target="./libSDL2.so" />
|
||||
</configuration>
|
||||
8
packaging/linux/include/mod-mimeinfo.xml.in
Normal file
8
packaging/linux/include/mod-mimeinfo.xml.in
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="x-scheme-handler/openra-{MODID}-{TAG}">
|
||||
<generic-icon name="applications-games"/>
|
||||
<comment>Join OpenRA server</comment>
|
||||
<glob weight="60" pattern="openra-{MODID}-{TAG}://*"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
||||
6
packaging/linux/include/mod-server.in
Executable file
6
packaging/linux/include/mod-server.in
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
HERE="$(dirname "$(readlink -f "${0}")")"
|
||||
cd "${HERE}/../lib/openra" || exit 1
|
||||
|
||||
mono --debug OpenRA.Server.exe Game.Mod={MODID} "$@"
|
||||
11
packaging/linux/include/mod.desktop.in
Normal file
11
packaging/linux/include/mod.desktop.in
Normal file
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Version=1.0
|
||||
Name=OpenRA - {MODNAME}
|
||||
GenericName=Real Time Strategy Game
|
||||
Icon=openra-{MODID}
|
||||
Exec=openra-{MODID} %u
|
||||
Terminal=false
|
||||
Categories=Game;StrategyGame;
|
||||
StartupWMClass=openra-{MODID}
|
||||
MimeType=x-scheme-handler/openra-{MODID}-{TAG};
|
||||
46
packaging/linux/include/mod.in
Executable file
46
packaging/linux/include/mod.in
Executable file
@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
LAUNCHER=$(readlink -f "${0}")
|
||||
HERE="$(dirname "${LAUNCHER}")"
|
||||
cd "${HERE}/../lib/openra" || exit 1
|
||||
|
||||
# APPIMAGE is an environment variable set by the runtime
|
||||
# defining the absolute path to the .AppImage file
|
||||
if [ ! -z "${APPIMAGE}" ]; then
|
||||
LAUNCHER=${APPIMAGE}
|
||||
|
||||
# appimaged doesn't update the mime cache database when registering AppImages.
|
||||
# Run update-desktop-database ourselves if we detect that the desktop file has
|
||||
# been installed but the handler is not yet present in the cache
|
||||
if command -v update-desktop-database > /dev/null; then
|
||||
APPIMAGEID=$(printf "file://%s" "${APPIMAGE}" | md5sum | cut -d' ' -f1)
|
||||
LAUNCHER_NAME="appimagekit_${APPIMAGEID}-openra-{MODID}.desktop"
|
||||
LAUNCHER_PATH="${HOME}/.local/share/applications/${LAUNCHER_NAME}"
|
||||
MIMECACHE_PATH="${HOME}/.local/share/applications/mimeinfo.cache"
|
||||
SCHEME="x-scheme-handler/openra-{MODID}-{TAG}"
|
||||
if [ -f "${LAUNCHER_PATH}" ] && ! grep -qs "${SCHEME}=" "${MIMECACHE_PATH}"; then
|
||||
update-desktop-database "${HOME}/.local/share/applications"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Search for server connection
|
||||
PROTOCOL_PREFIX="openra-{MODID}-{TAG}://"
|
||||
JOIN_SERVER=""
|
||||
if [ "${1#${PROTOCOL_PREFIX}}" != "${1}" ]; then
|
||||
JOIN_SERVER="Launch.Connect=${1#${PROTOCOL_PREFIX}}"
|
||||
fi
|
||||
|
||||
# Run the game
|
||||
export SDL_VIDEO_X11_WMCLASS="openra-{MODID}"
|
||||
mono --debug OpenRA.Game.exe Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" "${JOIN_SERVER}" "$@"
|
||||
|
||||
# Show a crash dialog if something went wrong
|
||||
if [ $? != 0 ] && [ $? != 1 ]; then
|
||||
if command -v zenity > /dev/null; then
|
||||
zenity --no-wrap --question --title "{MODNAME}" --text "{MODNAME} has encountered a fatal error.\nLog Files are available in ~/.openra." --ok-label "Quit" --cancel-label "View FAQ" || xdg-open "{MODFAQURL}"
|
||||
else
|
||||
printf "{MODNAME} has encountered a fatal error.\n -> Log Files are available in ~/.openra\n -> FAQ is available at {MODFAQURL}\n"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
BIN
packaging/linux/mod_128x128.png
Normal file
BIN
packaging/linux/mod_128x128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
packaging/linux/mod_16x16.png
Normal file
BIN
packaging/linux/mod_16x16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 265 B |
BIN
packaging/linux/mod_256x256.png
Normal file
BIN
packaging/linux/mod_256x256.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
BIN
packaging/linux/mod_32x32.png
Normal file
BIN
packaging/linux/mod_32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 542 B |
BIN
packaging/linux/mod_48x48.png
Normal file
BIN
packaging/linux/mod_48x48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
packaging/linux/mod_64x64.png
Normal file
BIN
packaging/linux/mod_64x64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 952 B |
@ -32,4 +32,14 @@ if [ $? -ne 0 ]; then
|
||||
echo "macOS package build failed."
|
||||
fi
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
echo "Linux AppImage packaging requires a Linux host."
|
||||
else
|
||||
echo "Building Linux AppImage package"
|
||||
${PACKAGING_DIR}/linux/buildpackage.sh "${TAG}" "${OUTPUTDIR}"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Linux AppImage package build failed."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Package build done."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user