From 53b2c20b8beb7862381a8f8764f836d55e86904c Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 9 Mar 2022 23:29:37 -0500 Subject: [PATCH] Fix More AppImage Bugs --- launcher/CMakeLists.txt | 7 +++++++ launcher/src/bootstrap.c | 17 ++++++++++++----- launcher/src/bootstrap.h | 1 + launcher/src/client/launcher.cpp | 3 +++ launcher/src/server/launcher.c | 3 +++ scripts/generate-appimage-builder-yaml.js | 2 +- scripts/install-dependencies.sh | 3 ++- 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index c55226f9..d6dbe358 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -14,5 +14,12 @@ if(BUILD_NATIVE_COMPONENTS) install_symlink("../${MCPI_INSTALL_DIR}/launcher" "bin/${MCPI_VARIANT_NAME}") if(NOT MCPI_SERVER_MODE) install(DIRECTORY "client-data/" DESTINATION ".") + else() + set(ICON_PATH "share/icons/hicolor/scalable/apps") + install( + FILES "client-data/${ICON_PATH}/com.thebrokenrail.MCPIReborn.png" + DESTINATION "${ICON_PATH}" + RENAME "com.thebrokenrail.MCPIRebornServer.png" + ) endif() endif() diff --git a/launcher/src/bootstrap.c b/launcher/src/bootstrap.c index 257eec0b..0a92fa38 100644 --- a/launcher/src/bootstrap.c +++ b/launcher/src/bootstrap.c @@ -139,16 +139,20 @@ static void load(char **ld_preload, char *folder) { #define MCPI_BINARY "minecraft-pi" #define QEMU_BINARY "qemu-arm" -// Bootstrap -void bootstrap(int argc, char *argv[]) { - INFO("%s", "Configuring Game..."); - +// Pre-Bootstrap +void pre_bootstrap() { // AppImage #ifdef MCPI_IS_APPIMAGE_BUILD - if (chdir(getenv("OWD")) != 0) { + char *owd = getenv("OWD"); + if (owd != NULL && chdir(owd) != 0) { ERR("AppImage: Unable To Fix Current Directory: %s", strerror(errno)); } #endif +} + +// Bootstrap +void bootstrap(int argc, char *argv[]) { + INFO("%s", "Configuring Game..."); // Get Binary Directory char *binary_directory = get_binary_directory(); @@ -156,6 +160,9 @@ void bootstrap(int argc, char *argv[]) { // Handle AppImage #ifdef MCPI_IS_APPIMAGE_BUILD char *usr_prefix = getenv("APPDIR"); + if (usr_prefix == NULL) { + usr_prefix = ""; + } #else char *usr_prefix = ""; #endif diff --git a/launcher/src/bootstrap.h b/launcher/src/bootstrap.h index dfc8de35..14c60fc5 100644 --- a/launcher/src/bootstrap.h +++ b/launcher/src/bootstrap.h @@ -6,6 +6,7 @@ extern "C" { void set_and_print_env(const char *name, char *value); +void pre_bootstrap(); void bootstrap(int argc, char *argv[]); #ifdef __cplusplus diff --git a/launcher/src/client/launcher.cpp b/launcher/src/client/launcher.cpp index 556b5a7c..67e7b107 100644 --- a/launcher/src/client/launcher.cpp +++ b/launcher/src/client/launcher.cpp @@ -121,6 +121,9 @@ static void run_zenity_and_set_env(const char *env_name, std::vector