Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port macOS and Linux release packages to .NET 5 #18955

Merged
merged 8 commits into from Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/packaging.yml
Expand Up @@ -39,6 +39,11 @@ jobs:
- name: Clone Repository
uses: actions/checkout@v2

- name: Install .NET 5
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'

- name: Prepare Environment
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV}

Expand Down
15 changes: 0 additions & 15 deletions Makefile
Expand Up @@ -25,18 +25,6 @@
# make help
#

############################## TOOLCHAIN ###############################
#
# List of .NET assemblies that we can guarantee exist
WHITELISTED_OPENRA_ASSEMBLIES = OpenRA.dll OpenRA.Utility.dll OpenRA.Server.dll OpenRA.Platforms.Default.dll OpenRA.Game.dll OpenRA.Mods.Common.dll OpenRA.Mods.Cnc.dll OpenRA.Mods.D2k.dll

# These are explicitly shipped alongside our core files by the packaging script
WHITELISTED_THIRDPARTY_ASSEMBLIES = ICSharpCode.SharpZipLib.dll FuzzyLogicLibrary.dll Eluant.dll BeaconLib.dll Open.Nat.dll SDL2-CS.dll OpenAL-CS.Core.dll DiscordRPC.dll Newtonsoft.Json.dll

# These are shipped in our custom minimal mono runtime and also available in the full system-installed .NET/mono stack
# This list *must* be kept in sync with the files packaged by the AppImageSupport and OpenRALauncherOSX repositories
WHITELISTED_CORE_ASSEMBLIES = mscorlib.dll System.dll System.Configuration.dll System.Core.dll System.Numerics.dll System.Security.dll System.Xml.dll Mono.Security.dll netstandard.dll Microsoft.Win32.Registry.dll System.Security.AccessControl.dll System.Security.Principal.Windows.dll System.Xml.Linq.dll System.Runtime.Serialization.dll

######################### UTILITIES/SETTINGS ###########################
#
# Install locations for local installs and downstream packaging
Expand Down Expand Up @@ -100,9 +88,6 @@ check:
@echo "Compiling in debug mode..."
@$(MSBUILD) -t:build -restore -p:Configuration=Debug -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true -p:DefineConstants="MONO"
@echo
@echo "Checking runtime assemblies..."
@$(OPENRA_UTILITY) all --check-runtime-assemblies $(WHITELISTED_OPENRA_ASSEMBLIES) $(WHITELISTED_THIRDPARTY_ASSEMBLIES) $(WHITELISTED_CORE_ASSEMBLIES)
@echo
@echo "Checking for explicit interface violations..."
@$(OPENRA_UTILITY) all --check-explicit-interfaces
@echo
Expand Down
5 changes: 5 additions & 0 deletions OpenRA.Launcher/OpenRA.Launcher.csproj
Expand Up @@ -65,4 +65,9 @@
<Analyzer Remove="@(Analyzer)" />
</ItemGroup>
</Target>
<ItemGroup>
<TrimmerRootAssembly Include="mscorlib" />
<TrimmerRootAssembly Include="netstandard" />
<TrimmerRootAssembly Include="System.IO.Pipes" />
teinarss marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>
</Project>

This file was deleted.

5 changes: 5 additions & 0 deletions OpenRA.Server/OpenRA.Server.csproj
Expand Up @@ -40,4 +40,9 @@
<Analyzer Remove="@(Analyzer)" />
</ItemGroup>
</Target>
<ItemGroup>
<TrimmerRootAssembly Include="mscorlib" />
<TrimmerRootAssembly Include="netstandard" />
<TrimmerRootAssembly Include="System.IO.Pipes" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions OpenRA.Utility/OpenRA.Utility.csproj
Expand Up @@ -40,4 +40,9 @@
<Analyzer Remove="@(Analyzer)" />
</ItemGroup>
</Target>
<ItemGroup>
<TrimmerRootAssembly Include="mscorlib" />
<TrimmerRootAssembly Include="netstandard" />
<TrimmerRootAssembly Include="System.IO.Pipes" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions OpenRA.WindowsLauncher/OpenRA.WindowsLauncher.csproj
Expand Up @@ -58,4 +58,9 @@
<Analyzer Remove="@(Analyzer)" />
</ItemGroup>
</Target>
<ItemGroup>
<TrimmerRootAssembly Include="mscorlib" />
<TrimmerRootAssembly Include="netstandard" />
<TrimmerRootAssembly Include="System.IO.Pipes" />
</ItemGroup>
</Project>
62 changes: 20 additions & 42 deletions packaging/functions.sh
Expand Up @@ -16,8 +16,6 @@
# COPY_D2K_DLL: If set to True the OpenRA.Mods.D2k.dll will also be copied (True, False)
# Used by:
# Makefile (install target for local installs and downstream packaging)
# Linux AppImage packaging
# macOS packaging
# Mod SDK Linux AppImage packaging
# Mod SDK macOS packaging
# Mod SDK Windows packaging
Expand All @@ -41,58 +39,36 @@ install_assemblies_mono() {
./configure-system-libraries.sh
fi

cd "${ORIG_PWD}" || exit 1

echo "Installing engine to ${DEST_PATH}"
install -d "${DEST_PATH}"

# Core engine
install -m755 "${SRC_PATH}/bin/OpenRA.Server.dll" "${DEST_PATH}"
install -m755 "${SRC_PATH}/bin/OpenRA.Utility.dll" "${DEST_PATH}"
install -m644 "${SRC_PATH}/bin/OpenRA.Game.dll" "${DEST_PATH}"
install -m644 "${SRC_PATH}/bin/OpenRA.Platforms.Default.dll" "${DEST_PATH}"
if [ "${COPY_GENERIC_LAUNCHER}" = "True" ]; then
install -m755 "${SRC_PATH}/bin/OpenRA.dll" "${DEST_PATH}"
if [ "${COPY_GENERIC_LAUNCHER}" != "True" ]; then
rm "${SRC_PATH}/bin/OpenRA.dll"
fi

# Mod dlls
install -m644 "${SRC_PATH}/bin/OpenRA.Mods.Common.dll" "${DEST_PATH}"
if [ "${COPY_CNC_DLL}" = "True" ]; then
install -m644 "${SRC_PATH}/bin/OpenRA.Mods.Cnc.dll" "${DEST_PATH}"
if [ "${COPY_CNC_DLL}" != "True" ]; then
rm "${SRC_PATH}/bin/OpenRA.Mods.Cnc.dll"
fi

if [ "${COPY_D2K_DLL}" = "True" ]; then
install -m644 "${SRC_PATH}/bin/OpenRA.Mods.D2k.dll" "${DEST_PATH}"
if [ "${COPY_D2K_DLL}" != "True" ]; then
rm "${SRC_PATH}/bin/OpenRA.Mods.D2k.dll"
fi

# Managed Dependencies
for LIB in ICSharpCode.SharpZipLib.dll FuzzyLogicLibrary.dll Open.Nat.dll BeaconLib.dll DiscordRPC.dll Newtonsoft.Json.dll SDL2-CS.dll OpenAL-CS.Core.dll Eluant.dll; do
install -m644 "${SRC_PATH}/bin/${LIB}" "${DEST_PATH}"
done
cd "${ORIG_PWD}" || exit 1

# Native dependencies
if [ "${TARGETPLATFORM}" = "win-x86" ] || [ "${TARGETPLATFORM}" = "win-x64" ]; then
echo "Installing dependencies for ${TARGETPLATFORM} to ${DEST_PATH}"
for LIB in soft_oal.dll SDL2.dll freetype6.dll lua51.dll libEGL.dll libGLESv2.dll; do
install -m644 "${SRC_PATH}/bin/${LIB}" "${DEST_PATH}"
done
else
for LIB in OpenRA.Platforms.Default.dll.config SDL2-CS.dll.config OpenAL-CS.Core.dll.config Eluant.dll.config; do
install -m644 "${SRC_PATH}/bin/${LIB}" "${DEST_PATH}"
done
fi
echo "Installing engine to ${DEST_PATH}"
install -d "${DEST_PATH}"

for LIB in "${SRC_PATH}/bin/"*.dll "${SRC_PATH}/bin/"*.dll.config; do
install -m644 "${LIB}" "${DEST_PATH}"
done

if [ "${TARGETPLATFORM}" = "linux-x64" ]; then
echo "Installing dependencies for ${TARGETPLATFORM} to ${DEST_PATH}"
for LIB in soft_oal.so SDL2.so freetype6.so lua51.so; do
install -m755 "${SRC_PATH}/bin/${LIB}" "${DEST_PATH}"
for LIB in "${SRC_PATH}/bin/"*.so; do
install -m755 "${LIB}" "${DEST_PATH}"
done
fi

if [ "${TARGETPLATFORM}" = "osx-x64" ]; then
echo "Installing dependencies for ${TARGETPLATFORM} to ${DEST_PATH}"
for LIB in soft_oal.dylib SDL2.dylib freetype6.dylib lua51.dylib; do
install -m755 "${SRC_PATH}/bin/${LIB}" "${DEST_PATH}"
for LIB in "${SRC_PATH}/bin/"*.dylib; do
install -m755 "${LIB}" "${DEST_PATH}"
done
fi
}
Expand All @@ -107,6 +83,8 @@ install_assemblies_mono() {
# COPY_D2K_DLL: If set to True the OpenRA.Mods.D2k.dll will also be copied (True, False)
# Used by:
# Windows packaging
# macOS packaging
# Linux AppImage packaging
install_assemblies() {
SRC_PATH="${1}"
DEST_PATH="${2}"
Expand All @@ -118,7 +96,7 @@ install_assemblies() {
ORIG_PWD=$(pwd)
cd "${SRC_PATH}" || exit 1

dotnet publish -c Release -p:TargetPlatform="${TARGETPLATFORM}" -p:CopyGenericLauncher="${COPY_GENERIC_LAUNCHER}" -p:CopyCncDll="${COPY_CNC_DLL}" -p:CopyD2kDll="${COPY_D2K_DLL}" -r "${TARGETPLATFORM}" -o "${DEST_PATH}"
dotnet publish -c Release -p:TargetPlatform="${TARGETPLATFORM}" -p:PublishTrimmed=true -p:CopyGenericLauncher="${COPY_GENERIC_LAUNCHER}" -p:CopyCncDll="${COPY_CNC_DLL}" -p:CopyD2kDll="${COPY_D2K_DLL}" -r "${TARGETPLATFORM}" -o "${DEST_PATH}"

cd "${ORIG_PWD}" || exit 1
}
Expand Down
34 changes: 3 additions & 31 deletions packaging/linux/AppRun.in
Expand Up @@ -2,43 +2,15 @@

HERE="$(dirname "$(readlink -f "${0}")")"

# Stash original environment values so they can be restored
# when switching to other mods using restore-environment
export OPENRA_ORIG_PATH="${PATH}"
export OPENRA_ORIG_XDG_DATA_DIRS="${XDG_DATA_DIRS}"
export OPENRA_ORIG_DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}"
export OPENRA_ORIG_LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"
export OPENRA_ORIG_MONO_PATH="${MONO_PATH}"
export OPENRA_ORIG_MONO_CFG_DIR="${MONO_CFG_DIR}"
export OPENRA_ORIG_MONO_CONFIG="${MONO_CONFIG}"

# Override runtime paths to use bundled mono and shared libraries
export PATH="${HERE}/usr/bin:${PATH}"
export XDG_DATA_DIRS="${HERE}/usr/share:${XDG_DATA_DIRS}"
export DYLD_LIBRARY_PATH="${HERE}/usr/lib:${DYLD_LIBRARY_PATH}"
export LD_LIBRARY_PATH="${HERE}/usr/lib:${LD_LIBRARY_PATH}"
export MONO_PATH="${HERE}/usr/lib/mono/4.5"
export MONO_CFG_DIR="${HERE}/etc"
export MONO_CONFIG="${HERE}/etc/mono/config"

# Update/create the mono certificate store to enable https web queries
if [ -f "/etc/pki/tls/certs/ca-bundle.crt" ]; then
mono "${HERE}/usr/lib/mono/4.5/cert-sync.exe" --quiet --user /etc/pki/tls/certs/ca-bundle.crt
elif [ -f "/etc/ssl/certs/ca-certificates.crt" ]; then
mono "${HERE}/usr/lib/mono/4.5/cert-sync.exe" --quiet --user /etc/ssl/certs/ca-certificates.crt
else
echo "WARNING: Unable to sync system certificate store - https requests will fail"
fi

# Run the game or server
if [ -n "$1" ] && [ "$1" = "--server" ]; then
# Drop the --server argument
shift
exec "openra-{MODID}-server" "$@"
"${HERE}/usr/bin/openra-{MODID}-server" "$@"
elif [ -n "$1" ] && [ "$1" = "--utility" ]; then
# Drop the --utility argument
shift
exec "openra-{MODID}-utility" "$@"
"${HERE}/usr/bin/openra-{MODID}-utility" "$@"
else
exec "openra-{MODID}" "$@"
"${HERE}/usr/bin/openra-{MODID}" "$@"
fi
31 changes: 7 additions & 24 deletions packaging/linux/buildpackage.sh
Expand Up @@ -19,7 +19,6 @@ cd "$(dirname "$0")" || exit 1
TAG="$1"
OUTPUTDIR="$2"
SRCDIR="$(pwd)/../.."
BUILTDIR="$(pwd)/build"
ARTWORK_DIR="$(pwd)/../artwork/"

UPDATE_CHANNEL=""
Expand All @@ -43,30 +42,16 @@ if [ ! -d "${OUTPUTDIR}" ]; then
fi

# Add native libraries
echo "Downloading dependencies"
echo "Downloading appimagetool"
if command -v curl >/dev/null 2>&1; then
curl -s -L -O https://github.com/OpenRA/AppImageSupport/releases/download/${DEPENDENCIES_TAG}/mono.tar.bz2 || exit 3
curl -s -L -O https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage || exit 3
else
wget -cq https://github.com/OpenRA/AppImageSupport/releases/download/${DEPENDENCIES_TAG}/mono.tar.bz2 || exit 3
wget -cq https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage || exit 3
fi

# travis-ci doesn't support mounting FUSE filesystems so extract and run the contents manually
chmod a+x appimagetool-x86_64.AppImage
./appimagetool-x86_64.AppImage --appimage-extract

echo "Building AppImage"
mkdir "${BUILTDIR}"
tar xf mono.tar.bz2 -C "${BUILTDIR}"
chmod 0755 "${BUILTDIR}/usr/bin/mono"
chmod 0644 "${BUILTDIR}/etc/mono/config"
chmod 0644 "${BUILTDIR}/etc/mono/4.5/machine.config"
chmod 0644 "${BUILTDIR}/usr/lib/mono/4.5/Facades/"*.dll
chmod 0644 "${BUILTDIR}/usr/lib/mono/4.5/"*.dll "${BUILTDIR}/usr/lib/mono/4.5/"*.exe
chmod 0755 "${BUILTDIR}/usr/lib/"*.so

rm -rf mono.tar.bz2
echo "Building AppImages"

build_appimage() {
MOD_ID=${1}
Expand All @@ -75,14 +60,12 @@ build_appimage() {
APPDIR="$(pwd)/${MOD_ID}.appdir"
APPIMAGE="OpenRA-$(echo "${DISPLAY_NAME}" | sed 's/ /-/g')${SUFFIX}-x86_64.AppImage"

cp -r "${BUILTDIR}" "${APPDIR}"

IS_D2K="False"
if [ "${MOD_ID}" = "d2k" ]; then
IS_D2K="True"
fi

install_assemblies_mono "${SRCDIR}" "${APPDIR}/usr/lib/openra" "linux-x64" "True" "True" "${IS_D2K}"
install_assemblies "${SRCDIR}" "${APPDIR}/usr/lib/openra" "linux-x64" "True" "True" "${IS_D2K}"
install_data "${SRCDIR}" "${APPDIR}/usr/lib/openra" "${MOD_ID}"
set_engine_version "${TAG}" "${APPDIR}/usr/lib/openra"
set_mod_version "${TAG}" "${APPDIR}/usr/lib/openra/mods/${MOD_ID}/mod.yaml" "${APPDIR}/usr/lib/openra/mods/modcontent/mod.yaml"
Expand Down Expand Up @@ -113,6 +96,7 @@ build_appimage() {
fi
done

mkdir -p "${APPDIR}/usr/bin"
sed "s/{MODID}/${MOD_ID}/g" openra.appimage.in | sed "s/{TAG}/${TAG}/g" | sed "s/{MODNAME}/${DISPLAY_NAME}/g" > "${APPDIR}/usr/bin/openra-${MOD_ID}"
chmod 0755 "${APPDIR}/usr/bin/openra-${MOD_ID}"

Expand All @@ -123,14 +107,13 @@ build_appimage() {
chmod 0755 "${APPDIR}/usr/bin/openra-${MOD_ID}-utility"

install -m 0755 gtk-dialog.py "${APPDIR}/usr/bin/gtk-dialog.py"
install -m 0755 restore-environment.sh "${APPDIR}/usr/bin/restore-environment.sh"

# Embed update metadata if (and only if) compiled on GitHub Actions
if [ -n "${GITHUB_REPOSITORY}" ]; then
ARCH=x86_64 ./squashfs-root/AppRun --no-appstream -u "zsync|https://master.openra.net/appimagecheck?mod=${MOD_ID}&channel=${UPDATE_CHANNEL}" "${APPDIR}" "${OUTPUTDIR}/${APPIMAGE}"
ARCH=x86_64 ./appimagetool-x86_64.AppImage --no-appstream -u "zsync|https://master.openra.net/appimagecheck?mod=${MOD_ID}&channel=${UPDATE_CHANNEL}" "${APPDIR}" "${OUTPUTDIR}/${APPIMAGE}"
zsyncmake -u "https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}/${APPIMAGE}" -o "${OUTPUTDIR}/${APPIMAGE}.zsync" "${OUTPUTDIR}/${APPIMAGE}"
else
ARCH=x86_64 ./squashfs-root/AppRun --no-appstream "${APPDIR}" "${OUTPUTDIR}/${APPIMAGE}"
ARCH=x86_64 ./appimagetool-x86_64.AppImage --no-appstream "${APPDIR}" "${OUTPUTDIR}/${APPIMAGE}"
fi

rm -rf "${APPDIR}"
Expand All @@ -141,4 +124,4 @@ build_appimage "cnc" "Tiberian Dawn" "699223250181292033"
build_appimage "d2k" "Dune 2000" "712711732770111550"

# Clean up
rm -rf appimagetool-x86_64.AppImage squashfs-root "${BUILTDIR}"
rm -rf appimagetool-x86_64.AppImage "${BUILTDIR}"
2 changes: 1 addition & 1 deletion packaging/linux/openra-server.appimage.in
Expand Up @@ -2,4 +2,4 @@
HERE="$(dirname "$(readlink -f "${0}")")"
cd "${HERE}/../lib/openra" || exit 1

mono --debug OpenRA.Server.dll Game.Mod="{MODID}" "$@"
./OpenRA.Server Game.Mod="{MODID}" "$@"
2 changes: 1 addition & 1 deletion packaging/linux/openra-utility.appimage.in
Expand Up @@ -2,4 +2,4 @@

# OpenRA.Utility relies on keeping the original working directory, so don't change directory
HERE="$(dirname "$(readlink -f "${0}")")"
mono --debug "${HERE}/../lib/openra/OpenRA.Utility.dll" {MODID} "$@"
"${HERE}/../lib/openra/OpenRA.Utility" {MODID} "$@"
2 changes: 1 addition & 1 deletion packaging/linux/openra.appimage.in
Expand Up @@ -35,7 +35,7 @@ fi

# Run the game
export SDL_VIDEO_X11_WMCLASS="openra-{MODID}-{TAG}"
mono --debug OpenRA.dll Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" Engine.LaunchWrapper="${HERE}/restore-environment.sh" "${JOIN_SERVER}" "$@"
./OpenRA Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" "${JOIN_SERVER}" "$@"

# Show a crash dialog if something went wrong
if [ $? != 0 ] && [ $? != 1 ]; then
Expand Down