From e18fc9fc637fb7fffc857afdfa67ccd0308caaf6 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sat, 23 Apr 2022 21:10:44 -0400 Subject: [PATCH] Simplify --- launcher/src/bootstrap.c | 6 ------ launcher/src/patchelf.c | 16 +++++++++++++++- scripts/generate-appimage-builder-yaml.js | 3 ++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/launcher/src/bootstrap.c b/launcher/src/bootstrap.c index f5ece47..b86e08c 100644 --- a/launcher/src/bootstrap.c +++ b/launcher/src/bootstrap.c @@ -254,12 +254,6 @@ void bootstrap(int argc, char *argv[]) { } } - // AppImage -#ifdef MCPI_IS_APPIMAGE_BUILD - // Mark Patched MCPI As Part Of AppImage - set_and_print_env("APPDIR_MODULE_DIR", getenv("MCPI_EXECUTABLE_PATH")); -#endif - // Configure LD_LIBRARY_PATH { // Log diff --git a/launcher/src/patchelf.c b/launcher/src/patchelf.c index 6711f23..d930a09 100644 --- a/launcher/src/patchelf.c +++ b/launcher/src/patchelf.c @@ -8,12 +8,26 @@ #include "patchelf.h" // Duplicate MCPI Executable Into /tmp +#define TMP_DIR "/tmp/.minecraft-pi-tmp" static void duplicate_mcpi_executable() { // Get Original Path const char *original_path = getenv("MCPI_EXECUTABLE_PATH"); + // Ensure Temporary Directory + { + // Check If It Exists + struct stat tmp_stat; + int exists = stat(TMP_DIR, &tmp_stat) != 0 ? 0 : S_ISDIR(tmp_stat.st_mode); + if (!exists) { + // Doesn't Exist + if (mkdir(TMP_DIR, S_IRUSR | S_IWUSR | S_IXUSR) != 0) { + ERR("Unable To Create Temporary Folder: %s", strerror(errno)); + } + } + } + // Generate New File - char new_path[] = "/tmp/.minecraft-pi-XXXXXX"; + char new_path[] = TMP_DIR "/XXXXXX"; int new_file_fd = mkstemp(new_path); if (new_file_fd == -1) { ERR("Unable To Create Temporary File: %s", strerror(errno)); diff --git a/scripts/generate-appimage-builder-yaml.js b/scripts/generate-appimage-builder-yaml.js index 2b92f0a..756a3ba 100755 --- a/scripts/generate-appimage-builder-yaml.js +++ b/scripts/generate-appimage-builder-yaml.js @@ -122,7 +122,8 @@ const runtime = { GTK_DATA_PREFIX: '${APPDIR}', GTK_THEME: 'Default', XDG_DATA_DIRS: '${APPDIR}/share:${APPDIR}/usr/share', - APPDIR_LIBRARY_PATH: `\${APPDIR}/usr/lib/${triplet}:\${APPDIR}/usr/${triplet}/lib:\${APPDIR}/lib/${triplet}:\${APPDIR}/usr/lib:\${APPDIR}/usr/lib/${triplet}/gdk-pixbuf-2.0/2.10.0/loaders` + APPDIR_LIBRARY_PATH: `\${APPDIR}/usr/lib/${triplet}:\${APPDIR}/usr/${triplet}/lib:\${APPDIR}/lib/${triplet}:\${APPDIR}/usr/lib:\${APPDIR}/usr/lib/${triplet}/gdk-pixbuf-2.0/2.10.0/loaders`, + APPDIR_MODULE_DIR: '/tmp/.minecraft-pi-tmp' } : undefined, preserve: arch !== 'armhf' ? [ // On non-ARM32 systems, an ARM32 linker is embedded, this