From 7aa9a441024c1e542c2e3ad88b846c1b9dd0bd35 Mon Sep 17 00:00:00 2001 From: mcarans Date: Sat, 13 Jun 2026 11:40:58 +1200 Subject: [PATCH 01/11] post build step instead of install --- Makefile | 2 +- ShellScripts/common/post_build.sh | 9 ++++++--- meson.build | 25 +++---------------------- src/Core/ResourceManager.m | 26 ++++++++++++++++++++------ src/meson.build | 26 ++++++++++++++++++++++++++ src/meson/linux/meson.build | 1 - 6 files changed, 56 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 54c74d32b..ebc1bb7bd 100755 --- a/Makefile +++ b/Makefile @@ -17,8 +17,8 @@ help: ## Show this help message define meson_build meson setup build/meson_$(2) $(1) --native-file $(NATIVE_FILE) --reconfigure 2>/dev/null || meson setup build/meson_$(2) $(1) --native-file $(NATIVE_FILE) meson compile -C build/meson_$(2) - meson install -C build/meson_$(2) endef +# meson install -C build/meson_$(2) # Helper macro for syncing OXP files cleanly define sync_debug_oxp diff --git a/ShellScripts/common/post_build.sh b/ShellScripts/common/post_build.sh index 1e14bc510..cb1e33abf 100755 --- a/ShellScripts/common/post_build.sh +++ b/ShellScripts/common/post_build.sh @@ -8,11 +8,14 @@ run_script() { cd ../.. set -x - PROGDIR="$(dirname "$PROGPATH")" + ORIGPROGPATH="$PROGPATH" + APPNAME=$(basename "$ORIGPROGPATH") + PROGDIR="$(dirname "$ORIGPROGPATH")/../oolite.app" + PROGPATH="$PROGDIR/$APPNAME" mkdir -p "$PROGDIR/Resources" + cp -fu "$ORIGPROGPATH" "$PROGPATH" ShellScripts/common/mkmanifest.sh > "$PROGDIR/Resources/manifest.plist" - cp -fu src/Cocoa/Info-Oolite.plist "$PROGDIR/Resources/Info-gnustep.plist" # Voice Data @@ -59,7 +62,7 @@ run_script() { strip "$PROGPATH" else # Linux - DEBUGPATH="$PROGDIR/$(basename "$PROGPATH").debug" + DEBUGPATH="$PROGDIR/$APPNAME.debug" # Extract symbols to file objcopy --only-keep-debug "$PROGPATH" "$DEBUGPATH" # Compress the debug sections in the symbol file diff --git a/meson.build b/meson.build index 6adcd604b..9de4fcdcd 100644 --- a/meson.build +++ b/meson.build @@ -8,9 +8,9 @@ project( check: true, ).stdout().strip(), default_options: [ - 'prefix=' + meson.current_build_dir() / 'oolite.app', - 'bindir=', - 'datadir=', + 'prefix=/usr', + 'bindir=bin', + 'datadir=share/oolite', 'optimization=2', ], ) @@ -88,22 +88,3 @@ endif gnustep_folder = '' # Not needed for Windows # dependencies, compiler/linker flags and build subdir('src') - -install_env_args = [ - 'PROGPATH=' + join_paths( - meson.global_build_root() / 'oolite.app', - get_option('bindir'), - 'oolite', - ), - 'HOST_OS=' + host_os, - 'DEBUG=' + (get_option('debug') ? 'yes' : 'no'), - 'DEPLOYMENT_RELEASE_CONFIGURATION=' + ( - get_option('deployment_release_configuration') ? 'yes' : 'no' - ), - 'ESPEAK=' + (get_option('espeak') ? 'yes' : 'no'), - 'STRIP_BIN=' + (get_option('strip_bin') ? 'yes' : 'no'), - 'VER_FULL=' + version_string, - 'GNUSTEP_FOLDER=' + gnustep_folder, -] -post_build_script = find_program('ShellScripts/common/post_build.sh') -meson.add_install_script('env', install_env_args, post_build_script.full_path()) diff --git a/src/Core/ResourceManager.m b/src/Core/ResourceManager.m index e6cb1c988..596013859 100644 --- a/src/Core/ResourceManager.m +++ b/src/Core/ResourceManager.m @@ -202,16 +202,30 @@ + (NSArray *)userRootPaths + (NSString *)builtInPath { + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSString *startingDir = nil; + #if OOLITE_WINDOWS - /* [[NSBundle mainBundle] resourcePath] causes complaints under Windows, - because we don't have a properly-built bundle. - */ - return @"Resources"; + // Windows: Start from the forced working directory + startingDir = [@"./" stringByStandardizingPath]; +#elif defined(__APPLE__) + // macOS: Use resourcePath directly and return it immediately. + return [[NSBundle mainBundle] resourcePath]; #else - return [[NSBundle mainBundle] resourcePath]; + // Linux/GNUstep: Use bundlePath directly to manage local vs system layouts + startingDir = [[NSBundle mainBundle] bundlePath]; #endif -} + // Look for a "Resources" folder (Windows & Linux) + NSString *primaryResourcesPath = [startingDir stringByAppendingPathComponent:@"Resources"]; + BOOL isDir = NO; + if ([fileManager fileExistsAtPath:primaryResourcesPath isDirectory:&isDir] && isDir) { + return primaryResourcesPath; + } + // Fallback: Look in startingDir / ../shared/oolite (Linux FHS System Install) + NSString *fallbackPath = [[startingDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"shared/oolite"]; + return [fallbackPath stringByStandardizingPath]; +} + (NSArray *)pathsWithAddOns { diff --git a/src/meson.build b/src/meson.build index 5b6fe4ed4..78010aeff 100644 --- a/src/meson.build +++ b/src/meson.build @@ -33,3 +33,29 @@ oolite_bin = executable( install_rpath: '$ORIGIN', install: true, ) + +install_env_args = [ + 'PROGPATH=' + meson.current_build_dir() / 'oolite', + 'HOST_OS=' + host_os, + 'DEBUG=' + (get_option('debug') ? 'yes' : 'no'), + 'DEPLOYMENT_RELEASE_CONFIGURATION=' + ( + get_option('deployment_release_configuration') ? 'yes' : 'no' + ), + 'ESPEAK=' + (get_option('espeak') ? 'yes' : 'no'), + 'STRIP_BIN=' + (get_option('strip_bin') ? 'yes' : 'no'), + 'VER_FULL=' + version_string, + 'GNUSTEP_FOLDER=' + gnustep_folder, +] +post_build_script = find_program('../ShellScripts/common/post_build.sh') +oolite_app_bundle = custom_target('post_build', + input: oolite_bin, + output: '.oolite_bundle.stamp', + command: [ + 'env', + install_env_args, + post_build_script.full_path(), + '&&', 'touch', '@OUTPUT@' + ], + build_by_default: true, + install: false, +) diff --git a/src/meson/linux/meson.build b/src/meson/linux/meson.build index 2f1ea2f30..31f435142 100644 --- a/src/meson/linux/meson.build +++ b/src/meson/linux/meson.build @@ -77,4 +77,3 @@ oolite_dependencies += declare_dependency( dependencies: [js_lib, gs_lib, objc_lib], include_directories: inc_dir, ) - From dd80f05a76ceabc4b50d4795aec3ce7213f968dc Mon Sep 17 00:00:00 2001 From: mcarans Date: Mon, 15 Jun 2026 08:53:17 +1200 Subject: [PATCH 02/11] Get Resources from share (GNUstep though seems to look in the wrong place) lowercase local variables --- Documentation/build_documentation.sh | 4 +- Documentation/build_doxygen.sh | 4 +- Documentation/build_doxygen_fn.sh | 4 +- Documentation/build_referencesheet.sh | 4 +- Documentation/build_referencesheet_fn.sh | 4 +- ShellScripts/Linux/build_gnustep.sh | 10 +- ShellScripts/Linux/dep_location_fn.sh | 4 +- ShellScripts/Linux/install_freedesktop_fn.sh | 38 ++--- ShellScripts/Linux/install_mozilla_js.sh | 18 +-- ShellScripts/Linux/install_package_fn.sh | 140 +++++++++---------- ShellScripts/Linux/install_packages_root.sh | 4 +- ShellScripts/Linux/run_oolite.sh | 46 +++--- ShellScripts/Windows/install_deps.sh | 4 +- ShellScripts/common/build_oolite.sh | 15 +- ShellScripts/common/install.sh | 61 ++++++++ ShellScripts/common/post_build.sh | 56 ++++---- installers/appimage/create_appimage.sh | 72 +++++----- installers/flatpak/create_flatpak.sh | 52 +++---- installers/win32/create_nsis.sh | 18 +-- meson.build | 3 - src/Core/ResourceManager.m | 25 +++- src/SDL/MyOpenGLView.m | 2 +- src/meson.build | 25 +++- tests/run_test.sh | 4 +- 24 files changed, 361 insertions(+), 256 deletions(-) create mode 100755 ShellScripts/common/install.sh diff --git a/Documentation/build_documentation.sh b/Documentation/build_documentation.sh index 38f89ee6d..d243cc7c3 100755 --- a/Documentation/build_documentation.sh +++ b/Documentation/build_documentation.sh @@ -1,8 +1,8 @@ #!/bin/bash run_script() { - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" rm -rf ../build/documentation source ./build_doxygen_fn.sh diff --git a/Documentation/build_doxygen.sh b/Documentation/build_doxygen.sh index f6c12d7f3..70cb996ca 100755 --- a/Documentation/build_doxygen.sh +++ b/Documentation/build_doxygen.sh @@ -1,8 +1,8 @@ #!/bin/bash run_script() { - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" rm -rf ../build/documentation source ./build_doxygen_fn.sh diff --git a/Documentation/build_doxygen_fn.sh b/Documentation/build_doxygen_fn.sh index 794f0bb14..3bce393a3 100644 --- a/Documentation/build_doxygen_fn.sh +++ b/Documentation/build_doxygen_fn.sh @@ -1,8 +1,8 @@ #!/bin/bash build_doxygen() { - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" PKG_OK=$(command -v doxygen) if [ "" = "$PKG_OK" ]; then diff --git a/Documentation/build_referencesheet.sh b/Documentation/build_referencesheet.sh index da8dc8fbc..599559106 100755 --- a/Documentation/build_referencesheet.sh +++ b/Documentation/build_referencesheet.sh @@ -1,8 +1,8 @@ #!/bin/bash run_script() { - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" source ./build_referencesheet_fn.sh diff --git a/Documentation/build_referencesheet_fn.sh b/Documentation/build_referencesheet_fn.sh index a1308cda2..0e8284fd3 100644 --- a/Documentation/build_referencesheet_fn.sh +++ b/Documentation/build_referencesheet_fn.sh @@ -1,8 +1,8 @@ #!/bin/bash build_referencesheet() { - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" PKG_OK=$(command -v soffice) if [ "" = "$PKG_OK" ]; then diff --git a/ShellScripts/Linux/build_gnustep.sh b/ShellScripts/Linux/build_gnustep.sh index 143d12219..d98b1457f 100755 --- a/ShellScripts/Linux/build_gnustep.sh +++ b/ShellScripts/Linux/build_gnustep.sh @@ -3,8 +3,8 @@ # Parameter two: Escalate command (defaults to sudo for 'system'). run_script() { - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" echo "Building GNUStep libraries" @@ -67,9 +67,9 @@ run_script() { cd tools-make make clean - local LIB_DIR="$TARGET/$LIB_SUBDIR" + local lib_dir="$TARGET/$LIB_SUBDIR" export CPPFLAGS="-I$TARGET/include" - export LDFLAGS="-L$LIB_DIR" + export LDFLAGS="-L$lib_dir" if ! ./configure --prefix="$TARGET" --with-library-combo=ng-gnu-gnu --with-runtime-abi=gnustep-2.2 "--with-libdir=$LIB_SUBDIR"; then echo "❌ tools-make configure failed!" >&2 @@ -82,7 +82,7 @@ run_script() { cd libs-base make clean - export LD_LIBRARY_PATH="$LIB_DIR:$LD_LIBRARY_PATH" + export LD_LIBRARY_PATH="$lib_dir:$LD_LIBRARY_PATH" source "$TARGET/share/GNUstep/Makefiles/GNUstep.sh" if ! ./configure; then echo "❌ libs-base configure failed!" >&2 diff --git a/ShellScripts/Linux/dep_location_fn.sh b/ShellScripts/Linux/dep_location_fn.sh index ac2278cce..3d12d23ef 100644 --- a/ShellScripts/Linux/dep_location_fn.sh +++ b/ShellScripts/Linux/dep_location_fn.sh @@ -18,9 +18,9 @@ dep_location() { local _escalate_cmd="${6:-sudo}" # Get the directory where the script is located - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - source "$SCRIPT_DIR/os_detection.sh" + source "$script_dir/os_detection.sh" cd ../../ # Logic for LIB_SUBDIR diff --git a/ShellScripts/Linux/install_freedesktop_fn.sh b/ShellScripts/Linux/install_freedesktop_fn.sh index a7d4f1b8f..24be048b9 100644 --- a/ShellScripts/Linux/install_freedesktop_fn.sh +++ b/ShellScripts/Linux/install_freedesktop_fn.sh @@ -19,51 +19,51 @@ install_freedesktop() { local err_msg="❌ Error: Failed to" - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" source ../common/get_version.sh echo "Installing metainfo to to $2" - local APPBIN="$2/bin" - local APPSHR="$2/share" + local appbin="$2/bin" + local appshr="$2/share" # Install binaries and scripts - install -D "$1/oolite" "$APPBIN/oolite" || { echo "$err_msg install oolite binary" >&2; return 1; } + install -D "$1/oolite" "$appbin/oolite" || { echo "$err_msg install oolite binary" >&2; return 1; } if [[ -f "$1/oolite.debug" ]]; then install -D "$1/oolite.debug" "$2/$3/oolite.debug" || { echo "$err_msg install oolite debug symbols" >&2; return 1; } fi - install -D "$1/run_oolite.sh" "$APPBIN/run_oolite.sh" || { echo "$err_msg install run_oolite.sh" >&2; return 1; } + install -D "$1/run_oolite.sh" "$appbin/run_oolite.sh" || { echo "$err_msg install run_oolite.sh" >&2; return 1; } # Resources copy - mkdir -p "$APPBIN/Resources" - cp -rf "$1/Resources/." "$APPBIN/Resources/" || { echo "$err_msg copy Resources folder" >&2; return 1; } + mkdir -p "$appbin/Resources" + cp -rf "$1/Resources/." "$appbin/Resources/" || { echo "$err_msg copy Resources folder" >&2; return 1; } # AddOns copy if folder exists in oolite.app if [ -d "$1/AddOns" ]; then - mkdir -p "$APPBIN/AddOns" - cp -rf "$1/AddOns/." "$APPBIN/AddOns/" || { echo "$err_msg copy AddOns folder" >&2; return 1; } + mkdir -p "$appbin/AddOns" + cp -rf "$1/AddOns/." "$appbin/AddOns/" || { echo "$err_msg copy AddOns folder" >&2; return 1; } fi - rm -f "$APPBIN/Resources/GNUstep.conf.orig" - install -D "GNUstep.conf.template" "$APPBIN/Resources/GNUstep.conf.template" || { echo "$err_msg GNUstep template" >&2; return 1; } + rm -f "$appbin/Resources/GNUstep.conf.orig" + install -D "GNUstep.conf.template" "$appbin/Resources/GNUstep.conf.template" || { echo "$err_msg GNUstep template" >&2; return 1; } - APP_METAINFO="$APPSHR/metainfo/space.oolite.Oolite.$4.xml" - install -D ../../installers/FreeDesktop/space.oolite.Oolite.metainfo.xml.template "$APP_METAINFO" || { echo "$err_msg metainfo template" >&2; return 1; } + local app_metainfo="$appshr/metainfo/space.oolite.Oolite.$4.xml" + install -D ../../installers/FreeDesktop/space.oolite.Oolite.metainfo.xml.template "$app_metainfo" || { echo "$err_msg metainfo template" >&2; return 1; } - sed -i "s/@VER@/${VERSION}/g" "$APP_METAINFO" - sed -i "s/@DATE@/${APP_DATE}/g" "$APP_METAINFO" + sed -i "s/@VER@/${VERSION}/g" "$app_metainfo" + sed -i "s/@DATE@/${APP_DATE}/g" "$app_metainfo" echo =========================================== echo Our manifest looks like this: - cat "$APP_METAINFO" + cat "$app_metainfo" echo =========================================== # Desktop and Icon - install -D ../../installers/FreeDesktop/space.oolite.Oolite.desktop "$APPSHR/applications/space.oolite.Oolite.desktop" || { echo "$err_msg desktop file" >&2; return 1; } + install -D ../../installers/FreeDesktop/space.oolite.Oolite.desktop "$appshr/applications/space.oolite.Oolite.desktop" || { echo "$err_msg desktop file" >&2; return 1; } - install -D "$1/Resources/Textures/oolite-logo1.png" "$APPSHR/icons/hicolor/256x256/apps/space.oolite.Oolite.png" || { echo "$err_msg icon file" >&2; return 1; } + install -D "$1/Resources/Textures/oolite-logo1.png" "$appshr/icons/hicolor/256x256/apps/space.oolite.Oolite.png" || { echo "$err_msg icon file" >&2; return 1; } popd } \ No newline at end of file diff --git a/ShellScripts/Linux/install_mozilla_js.sh b/ShellScripts/Linux/install_mozilla_js.sh index a7a8045b1..be51a2dea 100755 --- a/ShellScripts/Linux/install_mozilla_js.sh +++ b/ShellScripts/Linux/install_mozilla_js.sh @@ -4,13 +4,13 @@ run_script() { # Get the directory where the script is located - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - source "$SCRIPT_DIR/dep_location_fn.sh" + source "$script_dir/dep_location_fn.sh" dep_location LIB_SUBDIR TARGET ESCALATE "mozilla_js" $1 $2 # The URL to your specific GitHub release asset - local RELEASE_URL="https://github.com/OoliteProject/mozillajs-linux/releases/download/0.0.1/mozilla-js-static-lib.tar.gz" + local release_url="https://github.com/OoliteProject/mozillajs-linux/releases/download/0.0.1/mozilla-js-static-lib.tar.gz" echo "Installing Mozilla JS static library to $TARGET" [[ -n "$ESCALATE" ]] && echo "Using escalation: $ESCALATE" @@ -18,26 +18,26 @@ run_script() { # Download and extract # Curl downloads as current user, Tar extracts using escalation - local TEMP_STAGING=$(mktemp -d) - trap 'rm -rf "$TEMP_STAGING"' EXIT + local temp_staging=$(mktemp -d) + trap 'rm -rf "$temp_staging"' EXIT - if ! curl -L "$RELEASE_URL" | tar -xz -C "$TEMP_STAGING"; then + if ! curl -L "$release_url" | tar -xz -C "$temp_staging"; then echo "❌ Mozilla JS library download or extract failed!" >&2 return 1 fi - if ! [[ -d "$TEMP_STAGING/include" ]]; then + if ! [[ -d "$temp_staging/include" ]]; then echo "❌ Mozilla JS library extract empty!" >&2 return 1 fi # Move headers to include - if ! $ESCALATE cp -r "$TEMP_STAGING/include/"* "$TARGET/include/"; then + if ! $ESCALATE cp -r "$temp_staging/include/"* "$TARGET/include/"; then echo "❌ Mozilla JS library header install failed!" >&2 return 1 fi # Move libs from 'lib' in tarball to 'lib64' on system - if ! $ESCALATE cp -r "$TEMP_STAGING/lib/"* "$TARGET/$LIB_SUBDIR/"; then + if ! $ESCALATE cp -r "$temp_staging/lib/"* "$TARGET/$LIB_SUBDIR/"; then echo "❌ Mozilla JS library lib install failed!" >&2 return 1 fi diff --git a/ShellScripts/Linux/install_package_fn.sh b/ShellScripts/Linux/install_package_fn.sh index 1bbf3be44..af9a570f3 100644 --- a/ShellScripts/Linux/install_package_fn.sh +++ b/ShellScripts/Linux/install_package_fn.sh @@ -1,166 +1,166 @@ #!/bin/bash install_package() { - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - source $SCRIPT_DIR/os_detection.sh + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + source $script_dir/os_detection.sh - local GENERIC_NAME=$1 - local PKG_NAME="" + local generic_name=$1 + local pkg_name="" # This CASE statement is the dictionary. # Add your packages here. - case "$GENERIC_NAME" in - "git") PKG_NAME="git" ;; + case "$generic_name" in + "git") pkg_name="git" ;; "base-devel") case "$CURRENT_DISTRO" in - debian) PKG_NAME="build-essential" ;; - redhat) PKG_NAME="gcc gcc-c++ make" ;; - arch) PKG_NAME="base-devel" ;; + debian) pkg_name="build-essential" ;; + redhat) pkg_name="gcc gcc-c++ make" ;; + arch) pkg_name="base-devel" ;; esac ;; - "clang") PKG_NAME="clang lld lldb" ;; + "clang") pkg_name="clang lld lldb" ;; - "cmake") PKG_NAME="cmake" ;; + "cmake") pkg_name="cmake" ;; "meson") case "$CURRENT_DISTRO" in - debian) PKG_NAME="meson ninja-build" ;; - redhat) PKG_NAME="meson ninja-build" ;; - arch) PKG_NAME="meson ninja" ;; + debian) pkg_name="meson ninja-build" ;; + redhat) pkg_name="meson ninja-build" ;; + arch) pkg_name="meson ninja" ;; esac ;; "gnutls-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libgnutls28-dev" ;; - redhat) PKG_NAME="gnutls-devel" ;; - arch) PKG_NAME="gnutls" ;; + debian) pkg_name="libgnutls28-dev" ;; + redhat) pkg_name="gnutls-devel" ;; + arch) pkg_name="gnutls" ;; esac ;; "python") case "$CURRENT_DISTRO" in - debian) PKG_NAME="python3-pip" ;; - redhat) PKG_NAME="python3-pip" ;; - arch) PKG_NAME="python-pip" ;; + debian) pkg_name="python3-pip" ;; + redhat) pkg_name="python3-pip" ;; + arch) pkg_name="python-pip" ;; esac ;; "icu-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libicu-dev" ;; - redhat) PKG_NAME="libicu-devel" ;; - arch) PKG_NAME="icu" ;; + debian) pkg_name="libicu-dev" ;; + redhat) pkg_name="libicu-devel" ;; + arch) pkg_name="icu" ;; esac ;; "ffi-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libffi-dev" ;; - redhat) PKG_NAME="libffi-devel" ;; - arch) PKG_NAME="libffi" ;; + debian) pkg_name="libffi-dev" ;; + redhat) pkg_name="libffi-devel" ;; + arch) pkg_name="libffi" ;; esac ;; "xslt-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libxml2-dev libxslt1-dev" ;; - redhat) PKG_NAME="libxml2-devel libxslt-devel" ;; - arch) PKG_NAME="libxml2 libxslt" ;; + debian) pkg_name="libxml2-dev libxslt1-dev" ;; + redhat) pkg_name="libxml2-devel libxslt-devel" ;; + arch) pkg_name="libxml2 libxslt" ;; esac ;; "png-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libpng-dev" ;; - redhat) PKG_NAME="libpng-devel" ;; - arch) PKG_NAME="libpng" ;; + debian) pkg_name="libpng-dev" ;; + redhat) pkg_name="libpng-devel" ;; + arch) pkg_name="libpng" ;; esac ;; "zlib-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="zlib1g-dev" ;; - redhat) PKG_NAME="zlib-devel" ;; - arch) PKG_NAME="zlib" ;; + debian) pkg_name="zlib1g-dev" ;; + redhat) pkg_name="zlib-devel" ;; + arch) pkg_name="zlib" ;; esac ;; "nspr-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libnspr4-dev" ;; - redhat) PKG_NAME="nspr-devel" ;; - arch) PKG_NAME="nspr" ;; + debian) pkg_name="libnspr4-dev" ;; + redhat) pkg_name="nspr-devel" ;; + arch) pkg_name="nspr" ;; esac ;; "espeak-ng-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libespeak-ng-dev" ;; - redhat) PKG_NAME="espeak-ng-devel" ;; - arch) PKG_NAME="espeak-ng" ;; + debian) pkg_name="libespeak-ng-dev" ;; + redhat) pkg_name="espeak-ng-devel" ;; + arch) pkg_name="espeak-ng" ;; esac ;; "vorbis-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libvorbis-dev" ;; - redhat) PKG_NAME="libvorbis-devel" ;; - arch) PKG_NAME="libvorbis" ;; + debian) pkg_name="libvorbis-dev" ;; + redhat) pkg_name="libvorbis-devel" ;; + arch) pkg_name="libvorbis" ;; esac ;; "openal-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libopenal-dev" ;; - redhat) PKG_NAME="openal-soft-devel" ;; - arch) PKG_NAME="openal" ;; + debian) pkg_name="libopenal-dev" ;; + redhat) pkg_name="openal-soft-devel" ;; + arch) pkg_name="openal" ;; esac ;; "opengl-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libgl-dev" ;; - redhat) PKG_NAME="mesa-libGL-devel" ;; - arch) PKG_NAME="libglvnd" ;; + debian) pkg_name="libgl-dev" ;; + redhat) pkg_name="mesa-libGL-devel" ;; + arch) pkg_name="libglvnd" ;; esac ;; "glu-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libglu1-mesa-dev" ;; - redhat) PKG_NAME="mesa-libGLU-devel" ;; - arch) PKG_NAME="glu" ;; + debian) pkg_name="libglu1-mesa-dev" ;; + redhat) pkg_name="mesa-libGLU-devel" ;; + arch) pkg_name="glu" ;; esac ;; "sdl3") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libsdl3-dev" ;; - redhat) PKG_NAME="SDL3-devel" ;; - arch) PKG_NAME="sdl3"; + debian) pkg_name="libsdl3-dev" ;; + redhat) pkg_name="SDL3-devel" ;; + arch) pkg_name="sdl3"; esac ;; "x11-dev") case "$CURRENT_DISTRO" in - debian) PKG_NAME="libx11-dev" ;; - redhat) PKG_NAME="libX11-devel" ;; - arch) PKG_NAME="libx11" ;; + debian) pkg_name="libx11-dev" ;; + redhat) pkg_name="libX11-devel" ;; + arch) pkg_name="libx11" ;; esac ;; "appimage") case "$CURRENT_DISTRO" in - debian) PKG_NAME="file fuse3" ;; - redhat) PKG_NAME="file fuse3 desktop-file-utils which zsync" ;; - arch) PKG_NAME="file fuse3 desktop-file-utils zsync" ;; + debian) pkg_name="file fuse3" ;; + redhat) pkg_name="file fuse3 desktop-file-utils which zsync" ;; + arch) pkg_name="file fuse3 desktop-file-utils zsync" ;; esac ;; - "flatpak") PKG_NAME="flatpak flatpak-builder" ;; + "flatpak") pkg_name="flatpak flatpak-builder" ;; *) - echo "❌ Could not translate '$GENERIC_NAME' for $CURRENT_DISTRO!" >&2 + echo "❌ Could not translate '$generic_name' for $CURRENT_DISTRO!" >&2 return 1 ;; esac # Perform the Installation - if [[ -z "$PKG_NAME" ]]; then - echo "❌ Could not determine package name for $GENERIC_NAME!" >&2 + if [[ -z "$pkg_name" ]]; then + echo "❌ Could not determine package name for $generic_name!" >&2 return 1 - elif [[ "$PKG_NAME" == "NONE" ]]; then + elif [[ "$pkg_name" == "NONE" ]]; then echo "⏭️ PKGNAME is set to NONE. Skipping install." return 0 else - echo "--> Installing $GENERIC_NAME ($PKG_NAME)..." - if ! "${INSTALL_CMD[@]}" $PKG_NAME; then - echo "❌ Could not install $GENERIC_NAME ($PKG_NAME)!" >&2 + echo "--> Installing $generic_name ($pkg_name)..." + if ! "${INSTALL_CMD[@]}" $pkg_name; then + echo "❌ Could not install $generic_name ($pkg_name)!" >&2 return 1 fi fi diff --git a/ShellScripts/Linux/install_packages_root.sh b/ShellScripts/Linux/install_packages_root.sh index 7f7230574..2b0bb714d 100755 --- a/ShellScripts/Linux/install_packages_root.sh +++ b/ShellScripts/Linux/install_packages_root.sh @@ -11,8 +11,8 @@ run_script() { fi - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" source ./install_package_fn.sh diff --git a/ShellScripts/Linux/run_oolite.sh b/ShellScripts/Linux/run_oolite.sh index 00bbf9bd1..e5f2dc49f 100755 --- a/ShellScripts/Linux/run_oolite.sh +++ b/ShellScripts/Linux/run_oolite.sh @@ -23,29 +23,31 @@ for arg in "$@"; do done notify_failure() { + # First parameter is exit code + local msg if [[ -n "$FLATPAK_ID" ]]; then - local MSG="$FLATPAK_ID failed to start!\n\nExit Code: $EXIT_CODE" + msg="$FLATPAK_ID failed to start!\n\nExit Code: $1" gdbus call --session \ --dest org.freedesktop.portal.Desktop \ --object-path /org/freedesktop/portal/desktop \ --method org.freedesktop.portal.Notification.AddNotification \ "oolite_launch" \ - "{'title': <'Application Error'>, 'body': <'$MSG'>}" + "{'title': <'Application Error'>, 'body': <'$msg'>}" else - local APP_NAME="${ARGV0:-Application}" - local MSG="$APP_NAME failed to start!\n\nExit Code: $EXIT_CODE\n\nRun from terminal to see details." + local app_name="${ARGV0:-Application}" + msg="$app_name failed to start!\n\nExit Code: $1\n\nRun from terminal to see details." if command -v notify-send > /dev/null; then notify-send \ --urgency=critical \ - --app-name="$APP_NAME" \ + --app-name="$app_name" \ --icon=dialog-error \ "Application Error" \ - "$MSG" + "$msg" else # Fallback to Console (stderr) if libnotify is missing echo "------------------------------------------------" >&2 - echo "ERROR: $APP_NAME exited with code $EXIT_CODE" >&2 + echo "ERROR: $app_name exited with code $1" >&2 echo "------------------------------------------------" >&2 fi fi @@ -53,7 +55,7 @@ notify_failure() { launch_guarded() { if [[ "$PACKAGEINFO" == true ]]; then - cat "$OO_EXEDIR/Resources/manifest.plist" + cat "$OO_RESOURCESDIR/manifest.plist" exit 0 fi if [[ "$DEBUG" == true ]]; then @@ -105,34 +107,42 @@ launch_guarded() { echo "" fi "$OO_EXEDIR/oolite" "$@" - local EXIT_CODE=$? + local exit_code=$? - if [ $EXIT_CODE -eq 0 ]; then + if [ $exit_code -eq 0 ]; then exit 0 fi - notify_failure - exit $EXIT_CODE + notify_failure "$exit_code" + exit $exit_code } -find_exedir() { +find_exe_resources_dirs() { if [[ -z "$OO_EXEDIR" ]]; then OO_EXEDIR="$HERE" if [[ ! -f "$OO_EXEDIR/oolite" ]]; then OO_EXEDIR="$HERE/oolite.app" fi fi + if [[ -z "$OO_RESOURCESDIR" ]]; then + OO_RESOURCESDIR="$OO_EXEDIR/Resources" + if [[ ! -d "$OO_RESOURCESDIR" ]]; then + OO_RESOURCESDIR="$OO_EXEDIR/../share/oolite/Resources" + fi + fi } + make_gnustepconf_template() { export GNUSTEP_CONFIG_FILE=$(mktemp -t oolite_gnustep_XXXX --suffix=.conf) - sed -e "s|@BASEDIR@|$BASEDIR|g" "$OO_EXEDIR/Resources/GNUstep.conf.template" > "$GNUSTEP_CONFIG_FILE" + sed -e "s|@BASEDIR@|$BASEDIR|g" "$OO_RESOURCESDIR/GNUstep.conf.template" > "$GNUSTEP_CONFIG_FILE" } # Check if we are running inside a Flatpak if [[ -n "$FLATPAK_ID" ]]; then BASEDIR="/app" OO_EXEDIR="$BASEDIR/bin" + OO_RESOURCESDIR="$BASEDIR/share/oolite/Resources" GAME_DATA="$HOME/.var/app/$FLATPAK_ID" make_gnustepconf_template @@ -140,6 +150,7 @@ if [[ -n "$FLATPAK_ID" ]]; then elif [[ -n "$APPIMAGE" ]]; then BASEDIR="$APPDIR" OO_EXEDIR="$BASEDIR/bin" + OO_RESOURCESDIR="$BASEDIR/share/oolite/Resources" DEBUG_OXP=$(grep "debug_functionality_support" "$OO_EXEDIR/Resources/manifest.plist") if [[ "$DEBUG_OXP" == *"yes"* ]]; then @@ -165,16 +176,16 @@ else if [[ "${OO_DIRTYPE,,}" == "xdg" ]]; then GAME_DATA="$HOME/.local/share/Oolite" elif [[ "${OO_DIRTYPE,,}" == "legacy" ]]; then - find_exedir + find_exe_resources_dirs launch_guarded "$@" fi else # Use script directory GAME_DATA="$HERE/GameData" fi - + find_exe_resources_dirs export GNUSTEP_CONFIG_FILE=$(mktemp -t oolite_gnustep_XXXX --suffix=.conf) - cp "$HERE/Resources/GNUstep.conf.orig" "$GNUSTEP_CONFIG_FILE" + cp "$OO_RESOURCESDIR/GNUstep.conf.orig" "$GNUSTEP_CONFIG_FILE" fi mkdir -p "$GAME_DATA" @@ -221,6 +232,5 @@ echo "GNUSTEP_USER_DIR_DOC_MAN=$OO_GNUSTEPDIR/Library/Documentation/man" >> "$GN echo "GNUSTEP_USER_DIR_DOC_INFO=$OO_GNUSTEPDIR/Library/Documentation/info" >> "$GNUSTEP_CONFIG_FILE" echo "GNUSTEP_USER_DEFAULTS_DIR=$OO_GNUSTEPDEFAULTSDIR" >> "$GNUSTEP_CONFIG_FILE" -find_exedir launch_guarded "$@" rm "$GNUSTEP_CONFIG_FILE" diff --git a/ShellScripts/Windows/install_deps.sh b/ShellScripts/Windows/install_deps.sh index c353f9884..1767adc82 100755 --- a/ShellScripts/Windows/install_deps.sh +++ b/ShellScripts/Windows/install_deps.sh @@ -32,8 +32,8 @@ install() { } run_script() { - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" local oolite_deps_url="https://api.github.com/repos/OoliteProject/oolite_windeps_build/releases/latest" diff --git a/ShellScripts/common/build_oolite.sh b/ShellScripts/common/build_oolite.sh index eedece906..b68fc19bc 100755 --- a/ShellScripts/common/build_oolite.sh +++ b/ShellScripts/common/build_oolite.sh @@ -3,20 +3,20 @@ # One parameter: build target run_script() { - # First optional parameter is build target. Default target is release. - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" cd ../.. + local target if [[ -z "$1" ]]; then - TARGET=release + target=release else - TARGET=$1 + target=$1 fi make clean - if ! make $TARGET; then + if ! make $target; then echo "❌ Oolite build failed!" >&2 return 1 fi @@ -32,5 +32,4 @@ status=$? # Exit only if not sourced if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then exit $status -fi - +fi \ No newline at end of file diff --git a/ShellScripts/common/install.sh b/ShellScripts/common/install.sh new file mode 100755 index 000000000..2b1dd59b6 --- /dev/null +++ b/ShellScripts/common/install.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Processes Oolite data files after compilation + +run_script() { + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" > /dev/null + + cd ../.. + + set -x + local appname=$(basename "$STAGEPROGPATH") + local progdir=$(dirname "$STAGEPROGPATH") + local installdir="${INSTALLDIR:-$MESON_INSTALL_DESTDIR_PREFIX}" + local fullbindir="$installdir/$BINDIR" + local fulldatadir="$installdir/$DATADIR/oolite" # don't use appname here as Obj-C has oolite specifically + local progpath="$fullbindir/$appname" + if ! mkdir -p "$fullbindir"; then + echo "❌ Failed to create folder '$fullbindir'!" >&2 + return 1 + fi + if ! mkdir -p "$fulldatadir"; then + echo "❌ Failed to create folder '$fulldatadir'!" >&2 + return 1 + fi + if ! cp -fu "$STAGEPROGPATH" "$progpath"; then + echo "❌ Failed to copy '$STAGEPROGPATH' to '$progpath'!" >&2 + return 1 + fi + if [[ "$HOST_OS" == "linux" ]]; then + local run_oolite_src="$progdir/run_oolite.sh" + local run_oolite_dst="$fullbindir/run_oolite.sh" + if ! cp -fu "$run_oolite_src" "$run_oolite_dst"; then + echo "❌ Failed to copy '$run_oolite_src' to '$run_oolite_dst'!" >&2 + return 1 + fi + fi + local resources_src="$progdir/Resources/." + local resources_dst="$fulldatadir/Resources" + if ! cp -rfu "$resources_src" "$resources_dst"; then + echo "❌ Failed to copy '$resources_src' to '$resources_dst'!" >&2 + return 1 + fi + if [[ -d "$progdir/AddOns" ]]; then + local addons_src="$progdir/AddOns/." + local addons_dst="$fulldatadir/AddOns" + if ! cp -rfu "$addons_src" "$addons_dst"; then + echo "❌ Failed to copy '$addons_src' to '$addons_dst'!" >&2 + return 1 + fi + fi + echo "✅ Oolite install completed successfully" + popd > /dev/null +} + +run_script "$@" +status=$? + +# Exit only if not sourced +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + exit $status +fi \ No newline at end of file diff --git a/ShellScripts/common/post_build.sh b/ShellScripts/common/post_build.sh index cb1e33abf..82478579d 100755 --- a/ShellScripts/common/post_build.sh +++ b/ShellScripts/common/post_build.sh @@ -2,19 +2,26 @@ # Processes Oolite data files after compilation run_script() { - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" > /dev/null + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" > /dev/null cd ../.. set -x - ORIGPROGPATH="$PROGPATH" - APPNAME=$(basename "$ORIGPROGPATH") - PROGDIR="$(dirname "$ORIGPROGPATH")/../oolite.app" - PROGPATH="$PROGDIR/$APPNAME" + local appname=$(basename "$ORIGPROGPATH") + local appdir=$(dirname "$ORIGPROGPATH") + local progpath="$PROGDIR/$appname" mkdir -p "$PROGDIR/Resources" - cp -fu "$ORIGPROGPATH" "$PROGPATH" + if [[ ! -f "$ORIGPROGPATH" ]]; then + echo "❌ 'Oolite binary at '$ORIGPROGPATH' does not exist!" >&2 + return 1 + fi + if ! cp -fu "$ORIGPROGPATH" "$progpath"; then + echo "❌ Failed to copy '$ORIGPROGPATH' to '$progpath'!" >&2 + return 1 + fi + cp -fu "$ORIGPROGPATH" "$progpath" ShellScripts/common/mkmanifest.sh > "$PROGDIR/Resources/manifest.plist" cp -fu src/Cocoa/Info-Oolite.plist "$PROGDIR/Resources/Info-gnustep.plist" @@ -31,17 +38,17 @@ run_script() { "/usr/share/espeak-ng-data" "/app/share/espeak-ng-data" ) - local FOUND_DATA=false + local found_data=false local path for path in "${SEARCH_PATHS[@]}"; do if [[ -d "$path" ]]; then cp -rfu "$path" "$PROGDIR/Resources" - FOUND_DATA=true + found_data=true break fi done - if [[ "$FOUND_DATA" == false ]]; then + if [[ "$found_data" == false ]]; then echo "❌ espeak-ng-data not found in any known location!" >&2 return 1 fi @@ -59,39 +66,39 @@ run_script() { if [[ "$STRIP_BIN" == "yes" ]]; then if [[ "$HOST_OS" == "windows" ]]; then # Windows: Standard GNU strip is safest for PE/COFF - strip "$PROGPATH" + strip "$progpath" else # Linux - DEBUGPATH="$PROGDIR/$APPNAME.debug" + local debugpath="$PROGDIR/$appname.debug" # Extract symbols to file - objcopy --only-keep-debug "$PROGPATH" "$DEBUGPATH" + objcopy --only-keep-debug "$progpath" "$debugpath" # Compress the debug sections in the symbol file - objcopy --compress-debug-sections=zlib-gnu "$DEBUGPATH" + objcopy --compress-debug-sections=zlib-gnu "$debugpath" # strip the binary - strip -R .comment "$PROGPATH" + strip -R .comment "$progpath" # Add the debug link - objcopy --add-gnu-debuglink="$DEBUGPATH" "$PROGPATH" + objcopy --add-gnu-debuglink="$debugpath" "$progpath" fi elif [[ "$HOST_OS" == "linux" ]]; then # Compress the debug sections in the binary - objcopy --compress-debug-sections=zlib-gnu "$PROGPATH" + objcopy --compress-debug-sections=zlib-gnu "$progpath" fi if [[ "$HOST_OS" == "windows" ]]; then # Determine and copy DLL dependencies - UNIX_PREFIX=$(cygpath -u "$MINGW_PREFIX") - ldd "$PROGPATH" | grep "$UNIX_PREFIX" | awk '{print $3}' | xargs -I {} cp -rfu {} "$PROGDIR" + local unix_prefix=$(cygpath -u "$MINGW_PREFIX") + ldd "$progpath" | grep "$unix_prefix" | awk '{print $3}' | xargs -I {} cp -rfu {} "$PROGDIR" else # Copy Linux-specific wrapper script cp -fu ShellScripts/Linux/run_oolite.sh "$PROGDIR" - local GNUSTEP_CONF="$GNUSTEP_FOLDER/etc/GNUstep/GNUstep.conf" - if [ ! -f "$GNUSTEP_CONF" ] && [ "$GNUSTEP_FOLDER" = "/usr" ] && [ -f "/etc/GNUstep/GNUstep.conf" ]; then - GNUSTEP_CONF="/etc/GNUstep/GNUstep.conf" + local gnustep_conf="$GNUSTEP_FOLDER/etc/GNUstep/GNUstep.conf" + if [ ! -f "$gnustep_conf" ] && [ "$GNUSTEP_FOLDER" = "/usr" ] && [ -f "/etc/GNUstep/GNUstep.conf" ]; then + gnustep_conf="/etc/GNUstep/GNUstep.conf" fi - install -D "$GNUSTEP_CONF" "$PROGDIR/Resources/GNUstep.conf.orig" || { echo "$err_msg GNUstep config" >&2; return 1; } + install -D "$gnustep_conf" "$PROGDIR/Resources/GNUstep.conf.orig" || { echo "$err_msg GNUstep config" >&2; return 1; } # If we're using GNUstep libraries that aren't in a system folder copy them - ldd "$PROGPATH" | \ + ldd "$progpath" | \ grep -E "libgnustep-base|libobjc\.so\." | \ grep -vE "^[[:space:]]*.*=>[[:space:]]*/(usr/(local/)?|lib(64)?/)" | \ awk '{print $3}' | \ @@ -99,6 +106,7 @@ run_script() { fi echo "✅ Oolite post-build completed successfully" + touch "$appdir/$STAMP_FILE" popd > /dev/null } diff --git a/installers/appimage/create_appimage.sh b/installers/appimage/create_appimage.sh index 99a2dd2a3..6e947cd53 100755 --- a/installers/appimage/create_appimage.sh +++ b/installers/appimage/create_appimage.sh @@ -8,8 +8,8 @@ echo I am $0 $@ run_script() { # First parameter is a suffix for the build type eg. test, dev - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" mkdir -p ../../build cd ../../build @@ -17,39 +17,39 @@ run_script() { source ../ShellScripts/common/get_version.sh source ../ShellScripts/Linux/install_freedesktop_fn.sh - local ARCH=$(uname -m) - local APPDIR="./oolite.AppDir" - export APPDIR - local APPBIN="$APPDIR/bin" - local APPSHR="$APPDIR/share" - rm -rf "$APPDIR" + local arch=$(uname -m) + local appdir="./oolite.AppDir" + export appdir + local appbin="$appdir/bin" + local appshr="$appdir/share" + rm -rf "$appdir" - local ABS_OOLITEDIR=$(realpath -m "$1") - local ABS_APPDIR=$(realpath -m "$APPDIR") - if ! install_freedesktop "$ABS_OOLITEDIR" "$ABS_APPDIR" bin appdata; then + local abs_oolitedir=$(realpath -m "$1") + local abs_appdir=$(realpath -m "$appdir") + if ! install_freedesktop "$abs_oolitedir" "$abs_appdir" bin appdata; then return 1 fi - local SHARUN_BIN="./quick-sharun" - if [[ ! -x "$SHARUN_BIN" ]]; then + local sharun_bin="./quick-sharun" + if [[ ! -x "$sharun_bin" ]]; then echo "📥 quick-sharun not found or not executable. Downloading..." - curl -o "$SHARUN_BIN" -L https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/refs/heads/main/useful-tools/quick-sharun.sh || { echo "❌ Download failed" >&2; exit 1; } - chmod +x "$SHARUN_BIN" + curl -o "$sharun_bin" -L https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/refs/heads/main/useful-tools/quick-sharun.sh || { echo "❌ Download failed" >&2; exit 1; } + chmod +x "$sharun_bin" fi - local ICON_FILENAME="space.oolite.Oolite.png" - local ICON_SUBPATH="icons/hicolor/256x256/apps/$ICON_FILENAME" - local ICON="$APPSHR/$ICON_SUBPATH" + local icon_filename="space.oolite.Oolite.png" + local icon_subpath="icons/hicolor/256x256/apps/$icon_filename" + local ICON="$appshr/$icon_subpath" export ICON - local DESKTOP="$APPSHR/applications/space.oolite.Oolite.desktop" + local DESKTOP="$appshr/applications/space.oolite.Oolite.desktop" export DESKTOP - local SUFFIX + local suffix if (( $# == 2 )); then - SUFFIX="_${2}-${VER_FULL}" + suffix="_${2}-${VER_FULL}" else - SUFFIX="-$VER_FULL" + suffix="-$VER_FULL" fi - local OUTNAME="oolite${SUFFIX}-${ARCH}.AppImage" + local OUTNAME="oolite${suffix}-${arch}.AppImage" export OUTNAME echo "Building AppDir for AppImage..." @@ -65,36 +65,36 @@ run_script() { # install_metadatainfo_fn already put the files in the parameters below in the right place, # but no harm putting again here - if ! $SHARUN_BIN "$APPBIN/oolite"; then + if ! $sharun_bin "$appbin/oolite"; then echo "❌ AppDir generation failed!" >&2 return 1 fi - local LINTER_BIN="./appdir-lint.sh" - local EXCLUDE_LIST="./excludelist" + local linter_bin="./appdir-lint.sh" + local exclude_list="./excludelist" - if [[ ! -x "$LINTER_BIN" ]] || [[ ! -f "$EXCLUDE_LIST" ]]; then + if [[ ! -x "$linter_bin" ]] || [[ ! -f "$exclude_list" ]]; then echo "📥 Downloading AppDir linter and excludelist..." - curl -o "$LINTER_BIN" -L https://raw.githubusercontent.com/AppImage/AppImages/master/appdir-lint.sh || { echo "❌ Linter download failed" >&2; return 1; } - curl -o "$EXCLUDE_LIST" -L https://raw.githubusercontent.com/AppImage/AppImages/master/excludelist || { echo "❌ Excludelist download failed" >&2; return 1; } - chmod +x "$LINTER_BIN" + curl -o "$linter_bin" -L https://raw.githubusercontent.com/AppImage/AppImages/master/appdir-lint.sh || { echo "❌ Linter download failed" >&2; return 1; } + curl -o "$exclude_list" -L https://raw.githubusercontent.com/AppImage/AppImages/master/excludelist || { echo "❌ Excludelist download failed" >&2; return 1; } + chmod +x "$linter_bin" fi echo "🔍 Running AppDir linter..." - if ! "$LINTER_BIN" "$APPDIR"; then + if ! "$linter_bin" "$appdir"; then echo "❌ AppDir linting failed!" >&2 return 1 fi - APPIMAGETOOL_BIN="./appimagetool" - if [ ! -x "$APPIMAGETOOL_BIN" ]; then + appimagetool_bin="./appimagetool" + if [ ! -x "$appimagetool_bin" ]; then echo "📥 appimagetool not found. Downloading..." - curl -o "$APPIMAGETOOL_BIN" -L https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$ARCH.AppImage || { echo "❌ appimagetool download failed" >&2; return 1; } - chmod +x "$APPIMAGETOOL_BIN" + curl -o "$appimagetool_bin" -L https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$arch.AppImage || { echo "❌ appimagetool download failed" >&2; return 1; } + chmod +x "$appimagetool_bin" fi echo "Creating AppImage $OUTNAME..." - if ! $APPIMAGETOOL_BIN "$ABS_APPDIR" "$OUTNAME"; then + if ! $appimagetool_bin "$abs_appdir" "$OUTNAME"; then echo "❌ AppImage creation failed!" >&2 return 1 fi diff --git a/installers/flatpak/create_flatpak.sh b/installers/flatpak/create_flatpak.sh index 94fed54d5..426cbb0c8 100755 --- a/installers/flatpak/create_flatpak.sh +++ b/installers/flatpak/create_flatpak.sh @@ -4,8 +4,8 @@ echo "I am $0 $@" run_script() { # First parameter is a suffix for the build type eg. test, dev - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" cd ../.. # Deleting these prevents odd linking errors @@ -23,42 +23,42 @@ run_script() { return 1 fi - local MANIFEST="space.oolite.Oolite.yaml" + local manifest="space.oolite.Oolite.yaml" if [ -n "${SEMVER}" ] && [ -n "${PROJECTNAME}" ]; then - ENV_BLOCK="env:\n SEMVER: \"$SEMVER\"\n PROJECTNAME: \"$PROJECTNAME\"\n VERSION: \"$SEMVER\"" + local env_block="env:\n SEMVER: \"$SEMVER\"\n PROJECTNAME: \"$PROJECTNAME\"\n VERSION: \"$SEMVER\"" # Swap the comment - sed -i "s|#[[:space:]]*CI builds add an env block here|$ENV_BLOCK|g" "$MANIFEST" || return 1 + sed -i "s|#[[:space:]]*CI builds add an env block here|$env_block|g" "$manifest" || return 1 fi # check manifest - LINT_EXCEPTIONS=$(mktemp /tmp/oolite-lint-XXXXXX.json) - cat < "$LINT_EXCEPTIONS" + local lint_exceptions=$(mktemp /tmp/oolite-lint-XXXXXX.json) + cat < "$lint_exceptions" { "space.oolite.Oolite": [ "finish-args-has-dev-input" ] } EOF - trap 'rm -f "$LINT_EXCEPTIONS"' RETURN EXIT + trap 'rm -f "$lint_exceptions"' RETURN EXIT if command -v flatpak-builder-lint >/dev/null 2>&1; then - if ! flatpak-builder-lint manifest "$MANIFEST" --exceptions --user-exceptions="$LINT_EXCEPTIONS"; then + if ! flatpak-builder-lint manifest "$manifest" --exceptions --user-exceptions="$lint_exceptions"; then echo "❌ Flatpak manifest lint failed!" >&2 - cat "$MANIFEST" + cat "$manifest" echo "❌ Flatpak manifest lint failed!" >&2 return 1 fi else echo "Native linter not found. Falling back to Flatpak container..." - if ! flatpak run --filesystem="$LINT_EXCEPTIONS" --command=flatpak-builder-lint org.flatpak.Builder manifest "$MANIFEST" --exceptions --user-exceptions="$LINT_EXCEPTIONS"; then + if ! flatpak run --filesystem="$lint_exceptions" --command=flatpak-builder-lint org.flatpak.Builder manifest "$manifest" --exceptions --user-exceptions="$lint_exceptions"; then echo "❌ Flatpak manifest lint failed!" >&2 return 1 fi fi # 3. Clean up - rm -f "$LINT_EXCEPTIONS" + rm -f "$lint_exceptions" trap - RETURN EXIT echo "Creating Flatpak..." @@ -70,16 +70,16 @@ EOF return 1 fi - local TOTAL_LINES=$(wc -l < $MANIFEST) - local START_LINE=$((TOTAL_LINES - 3)) - sed -i "${START_LINE},\$d" $MANIFEST - cat <> $MANIFEST + local total_lines=$(wc -l < $manifest) + local start_line=$((total_lines - 3)) + sed -i "${start_line},\$d" $manifest + cat <> $manifest - type: dir path: ../ EOF # show effective manifest - flatpak-builder --show-manifest $MANIFEST + flatpak-builder --show-manifest $manifest if ! flatpak-builder \ --user \ @@ -88,32 +88,32 @@ EOF --install-deps-from=flathub \ --disable-rofiles-fuse \ build-dir \ - $MANIFEST; then + $manifest; then echo "❌ Flatpak build failed!" >&2 return 1 fi - local SUFFIX + local suffix if (( $# == 1 )); then - SUFFIX="_${1}-${VER_FULL}" + suffix="_${1}-${VER_FULL}" else - SUFFIX="-$VER_FULL" + suffix="-$VER_FULL" fi local ARCH=$(uname -m) - FILENAME="space.oolite.Oolite${SUFFIX}-${ARCH}.flatpak" - echo "Creating Flatpak $FILENAME..." + local filename="space.oolite.Oolite${suffix}-${ARCH}.flatpak" + echo "Creating Flatpak $filename..." if ! flatpak build-bundle \ repo \ - "$FILENAME" \ + "$filename" \ space.oolite.Oolite; then echo "❌ Flatpak bundle creation failed!" >&2 return 1 fi - DEBUGLNAME="space.oolite.Oolite.Debug${SUFFIX}-${ARCH}.flatpak" + local debugname="space.oolite.Oolite.Debug${suffix}-${ARCH}.flatpak" if ! flatpak build-bundle \ --runtime \ repo \ - "$DEBUGLNAME" \ + "$debugname" \ space.oolite.Oolite.Debug; then echo "❌ Flatpak bundle creation failed!" >&2 return 1 diff --git a/installers/win32/create_nsis.sh b/installers/win32/create_nsis.sh index 01b700879..3a4441f95 100644 --- a/installers/win32/create_nsis.sh +++ b/installers/win32/create_nsis.sh @@ -12,8 +12,8 @@ echo I am $0 $@ run_script() { # First parameter is a suffix for the build type eg. test, dev - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" mkdir -p ../../build/nsis cd ../../build/nsis @@ -47,13 +47,13 @@ run_script() { export VER_NSIS=$VER_FULL; fi - local OOLITE_DIR="../$1" - OOLITE_DIR="${OOLITE_DIR//\//\\}" + local oolite_dir="../$1" + oolite_dir="${oolite_dir//\//\\}" # Passing arguments cause problems with some versions of NSIS. # Because of this, we generate them into a separate file and include them. echo "; Version Definitions for Oolite" > OoliteVersions.nsh echo "; NOTE - This file is auto-generated by the Makefile, any manual edits will be overwritten" >> OoliteVersions.nsh - echo "!define OOLITE_DIR ${OOLITE_DIR}" >> OoliteVersions.nsh + echo "!define oolite_dir ${oolite_dir}" >> OoliteVersions.nsh echo "!define VER_MAJ ${VER_MAJ}" >> OoliteVersions.nsh echo "!define VER_MIN ${VER_MIN}" >> OoliteVersions.nsh echo "!define VER_REV ${VER_REV}" >> OoliteVersions.nsh @@ -70,13 +70,13 @@ run_script() { echo "!define DEPLOYMENT 1" >> OoliteVersions.nsh fi - local NSIS + local nsis if [[ -n "$MINGW_PREFIX" ]]; then - NSIS=$MINGW_PREFIX/bin/makensis + nsis=$MINGW_PREFIX/bin/makensis else - NSIS=/nsis/makensis.exe + nsis=/nsis/makensis.exe fi - if ! $NSIS -DOUTDIR="../" OOlite.nsi; then + if ! $nsis -DOUTDIR="../" OOlite.nsi; then echo "❌ NSIS creation failed!" >&2 return 1 fi diff --git a/meson.build b/meson.build index 9de4fcdcd..d368138ac 100644 --- a/meson.build +++ b/meson.build @@ -8,9 +8,6 @@ project( check: true, ).stdout().strip(), default_options: [ - 'prefix=/usr', - 'bindir=bin', - 'datadir=share/oolite', 'optimization=2', ], ) diff --git a/src/Core/ResourceManager.m b/src/Core/ResourceManager.m index 596013859..f3a092323 100644 --- a/src/Core/ResourceManager.m +++ b/src/Core/ResourceManager.m @@ -181,7 +181,11 @@ + (NSArray *)userRootPaths { // the paths are now in order of preference as per yesterday's talk. -- Kaks 2010-05-05 NSArray *defaultAddOnsPaths = [NSArray arrayWithObjects: -#if OOLITE_MAC_OS_X +#if OOLITE_WINDOWS + [[[@"./" stringByStandardizingPath] + stringByDeletingLastPathComponent] + stringByAppendingPathComponent:@"share/oolite/AddOns"], +#elif OOLITE_MAC_OS_X [[[[NSHomeDirectory() stringByAppendingPathComponent:@"Library"] stringByAppendingPathComponent:@"Application Support"] stringByAppendingPathComponent:@"Oolite"] @@ -189,6 +193,11 @@ + (NSArray *)userRootPaths [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"AddOns"], +#else + [[[[[NSBundle mainBundle] executablePath] + stringByDeletingLastPathComponent] + stringByDeletingLastPathComponent] + stringByAppendingPathComponent:@"share/oolite/AddOns"], #endif @"AddOns", [[OOOXZManager sharedManager] extractAddOnsPath], @@ -208,12 +217,13 @@ + (NSString *)builtInPath #if OOLITE_WINDOWS // Windows: Start from the forced working directory startingDir = [@"./" stringByStandardizingPath]; -#elif defined(__APPLE__) +#elif OOLITE_MAC_OS_X // macOS: Use resourcePath directly and return it immediately. return [[NSBundle mainBundle] resourcePath]; #else // Linux/GNUstep: Use bundlePath directly to manage local vs system layouts - startingDir = [[NSBundle mainBundle] bundlePath]; + startingDir = [[[NSBundle mainBundle] executablePath] + stringByDeletingLastPathComponent]; #endif // Look for a "Resources" folder (Windows & Linux) @@ -222,8 +232,8 @@ + (NSString *)builtInPath if ([fileManager fileExistsAtPath:primaryResourcesPath isDirectory:&isDir] && isDir) { return primaryResourcesPath; } - // Fallback: Look in startingDir / ../shared/oolite (Linux FHS System Install) - NSString *fallbackPath = [[startingDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"shared/oolite"]; + // Fallback: Look in startingDir / ../share/oolite (Linux FHS System Install) + NSString *fallbackPath = [[startingDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"share/oolite/Resources"]; return [fallbackPath stringByStandardizingPath]; } @@ -270,6 +280,11 @@ + (NSArray *)pathsWithAddOns // validate default search paths DESTROY(sSearchPaths); sSearchPaths = [NSMutableArray new]; + NSString *builtIn = [self builtInPath]; + if (builtIn != nil) + { + [sSearchPaths addObject:builtIn]; + } foreach (path, existingRootPaths) { [self checkPotentialPath:path :sSearchPaths]; diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index c6cb2de0b..50d280582 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -838,7 +838,7 @@ - (void) initSplashScreen SDL_Surface *image=NULL; SDL_Rect dest; - NSString *imagesDir = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Images"]; + NSString *imagesDir = [[ResourceManager builtInPath] stringByAppendingPathComponent:@"Images"]; image = SDL_LoadBMP([[imagesDir stringByAppendingPathComponent:@"splash.bmp"] UTF8String]); diff --git a/src/meson.build b/src/meson.build index 78010aeff..314faa0ed 100644 --- a/src/meson.build +++ b/src/meson.build @@ -21,8 +21,9 @@ subdir('meson') subdir('Core') subdir('SDL') +appname = 'oolite' oolite_bin = executable( - 'oolite', + appname, oolite_sources, include_directories: oolite_includes, dependencies: oolite_dependencies, @@ -31,11 +32,14 @@ oolite_bin = executable( win_subsystem: 'windows', build_rpath: '$ORIGIN', install_rpath: '$ORIGIN', - install: true, + install: false, ) +prog_dir = meson.global_build_root() / appname + '.app' +stamp_file = '.oolite_bundle.stamp' install_env_args = [ - 'PROGPATH=' + meson.current_build_dir() / 'oolite', + 'ORIGPROGPATH=' + meson.current_build_dir() / appname, + 'PROGDIR=' + prog_dir, 'HOST_OS=' + host_os, 'DEBUG=' + (get_option('debug') ? 'yes' : 'no'), 'DEPLOYMENT_RELEASE_CONFIGURATION=' + ( @@ -45,17 +49,28 @@ install_env_args = [ 'STRIP_BIN=' + (get_option('strip_bin') ? 'yes' : 'no'), 'VER_FULL=' + version_string, 'GNUSTEP_FOLDER=' + gnustep_folder, + 'STAMP_FILE=' + stamp_file, ] post_build_script = find_program('../ShellScripts/common/post_build.sh') oolite_app_bundle = custom_target('post_build', input: oolite_bin, - output: '.oolite_bundle.stamp', + output: stamp_file, + depend_files: [post_build_script.full_path()], command: [ 'env', install_env_args, post_build_script.full_path(), - '&&', 'touch', '@OUTPUT@' ], build_by_default: true, install: false, ) +install_env_args = [ + 'STAGEPROGPATH=' + prog_dir / appname, + 'BINDIR=' + get_option('bindir'), + 'DATADIR=' + get_option('datadir'), + 'HOST_OS=' + host_os, + 'DEPLOYMENT_RELEASE_CONFIGURATION=' + ( + get_option('deployment_release_configuration') ? 'yes' : 'no'), +] +install_script = find_program('../ShellScripts/common/install.sh') +meson.add_install_script('env', install_env_args, install_script.full_path()) \ No newline at end of file diff --git a/tests/run_test.sh b/tests/run_test.sh index 61621b314..f345ab359 100755 --- a/tests/run_test.sh +++ b/tests/run_test.sh @@ -19,8 +19,8 @@ run_script() { return 1 fi - local SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$SCRIPT_DIR" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" local BUILD_TYPE="${1:-snapshot}" local TARGET_DIR=$(readlink -f "../build/meson_${BUILD_TYPE}/oolite.app") From 0d0d9d345393c4ccbd814d9edb8c453fedab77bd Mon Sep 17 00:00:00 2001 From: mcarans Date: Tue, 16 Jun 2026 18:59:09 +1200 Subject: [PATCH 03/11] Get Resources from share --- src/Core/NSBundle+Override.h | 20 ++++++++++ src/Core/NSBundle+Override.m | 76 ++++++++++++++++++++++++++++++++++++ src/Core/ResourceManager.m | 2 +- src/Core/meson.build | 7 ++++ 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 src/Core/NSBundle+Override.h create mode 100644 src/Core/NSBundle+Override.m diff --git a/src/Core/NSBundle+Override.h b/src/Core/NSBundle+Override.h new file mode 100644 index 000000000..6bdc3dc34 --- /dev/null +++ b/src/Core/NSBundle+Override.h @@ -0,0 +1,20 @@ +#import + +@interface NSBundle (Override) + +/** + * Overrides the standard -infoDictionary method via a category name-clash. + * Forces the bundle to manually load and return the contents of 'info-gnustep.plist'. + */ +- (NSDictionary *)infoDictionary; + +/** + * Locates the cross-platform built-in Oolite Resources directory. + * Resolves different structures across Windows local installs, macOS app bundles, + * and Linux/GNUstep global / local file hierarchies. + * + * @return A standardized absolute string path to the active 'Resources' directory. + */ ++ (NSString *)builtInPath; + +@end \ No newline at end of file diff --git a/src/Core/NSBundle+Override.m b/src/Core/NSBundle+Override.m new file mode 100644 index 000000000..34da80614 --- /dev/null +++ b/src/Core/NSBundle+Override.m @@ -0,0 +1,76 @@ +/* + * NSBundle+Override.m + * + * Oolite Core Framework Override + * Bypasses standard plist loading to manually locate and parse info-gnustep.plist + * across Windows, macOS, and Linux environments safely at boot. + */ + +#import "NSBundle+Override.h" +#import +#import +#import + +#if OOLITE_LINUX +#import +#import +#endif + +@implementation NSBundle (Override) + +- (NSDictionary *)infoDictionary { + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSString *startingDir = nil; + NSString *resourcesFolder = nil; + +#if OOLITE_WINDOWS + // Windows: Start from the forced local working directory + startingDir = [@"./" stringByStandardizingPath]; +#else + // Linux/GNUstep: Read from the kernel to avoid calling [[NSBundle mainBundle] executablePath], + // which would cause an infinite loop during early bundle initialization. + char result[PATH_MAX]; + ssize_t count = readlink("/proc/self/exe", result, PATH_MAX); + if (count != -1) { + NSString *exePath = [fileManager stringWithFileSystemRepresentation:result length:count]; + startingDir = [exePath stringByDeletingLastPathComponent]; + } else { + // Fallback to local directory if /proc is inaccessible + startingDir = [@"./" stringByStandardizingPath]; + } +#endif + + // If resourcesFolder wasn't explicitly assigned by the macOS branch, resolve it for Win/Linux + if (!resourcesFolder) { + NSString *primaryResourcesPath = [startingDir stringByAppendingPathComponent:@"Resources"]; + BOOL isDir = NO; + + if ([fileManager fileExistsAtPath:primaryResourcesPath isDirectory:&isDir] && isDir) { + resourcesFolder = primaryResourcesPath; + } else { + // Fallback: Look in startingDir / ../share/oolite/Resources (Standard Linux system layout) + NSString *fallbackPath = [[startingDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"share/oolite/Resources"]; + resourcesFolder = [fallbackPath stringByStandardizingPath]; + } + } + + // Append the target file name to the resolved path root + NSString *plistPath = [resourcesFolder stringByAppendingPathComponent:@"Info-gnustep.plist"]; + + // Load the target configuration file + NSDictionary *gnustepPlist = [NSDictionary dictionaryWithContentsOfFile:plistPath]; + NSMutableDictionary *workingDict = nil; + + if (gnustepPlist) { + workingDict = [gnustepPlist mutableCopy]; + } else { + // Fallback block prevents runtime crashes if files are missing during dev/build refactors + workingDict = [[NSMutableDictionary alloc] init]; + NSLog(@"[Oolite-Core] Warning: Failed to find info-gnustep.plist at calculated path: %@", plistPath); + } + + // Return the dictionary cleanly managed for memory (Pre-ARC environments) + return [workingDict autorelease]; +} + +@end \ No newline at end of file diff --git a/src/Core/ResourceManager.m b/src/Core/ResourceManager.m index f3a092323..7f870cf6e 100644 --- a/src/Core/ResourceManager.m +++ b/src/Core/ResourceManager.m @@ -232,7 +232,7 @@ + (NSString *)builtInPath if ([fileManager fileExistsAtPath:primaryResourcesPath isDirectory:&isDir] && isDir) { return primaryResourcesPath; } - // Fallback: Look in startingDir / ../share/oolite (Linux FHS System Install) + // Fallback: Look in startingDir / ../share/oolite/Resources NSString *fallbackPath = [[startingDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"share/oolite/Resources"]; return [fallbackPath stringByStandardizingPath]; } diff --git a/src/Core/meson.build b/src/Core/meson.build index 304373e63..b5536270f 100644 --- a/src/Core/meson.build +++ b/src/Core/meson.build @@ -103,6 +103,13 @@ oolite_sources += files( 'legacy_random.c', ) +if host_os != 'darwin' + oolite_sources += files( + 'NSBundle+Override.m', + 'NSUserDefaults+Override.m', + ) +endif + oolite_includes += include_directories('.') # Enter child subdirectories From 1d7ad39eb74293cd8310d931f9d1de5b7cc46cc2 Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 17 Jun 2026 09:45:31 +1200 Subject: [PATCH 04/11] Change working dir for Linux like Windows to simplify --- ShellScripts/Linux/run_oolite.sh | 42 ++++++++-------- src/Core/NSBundle+Override.m | 84 ++++++++++++-------------------- src/Core/ResourceManager.m | 47 +++++++----------- src/SDL/main.m | 14 +++++- 4 files changed, 83 insertions(+), 104 deletions(-) diff --git a/ShellScripts/Linux/run_oolite.sh b/ShellScripts/Linux/run_oolite.sh index e5f2dc49f..a9c829686 100755 --- a/ShellScripts/Linux/run_oolite.sh +++ b/ShellScripts/Linux/run_oolite.sh @@ -1,6 +1,5 @@ #!/bin/bash - HERE="$(dirname "$(readlink -f "$0")")" HELP=false @@ -124,16 +123,20 @@ find_exe_resources_dirs() { OO_EXEDIR="$HERE/oolite.app" fi fi + OO_EXEDIR="$(readlink -f "$OO_EXEDIR")" + if [[ -z "$OO_RESOURCESDIR" ]]; then OO_RESOURCESDIR="$OO_EXEDIR/Resources" if [[ ! -d "$OO_RESOURCESDIR" ]]; then OO_RESOURCESDIR="$OO_EXEDIR/../share/oolite/Resources" fi fi + OO_RESOURCESDIR="$(readlink -f "$OO_RESOURCESDIR")" } make_gnustepconf_template() { + BASEDIR="$(readlink -f "$BASEDIR")" export GNUSTEP_CONFIG_FILE=$(mktemp -t oolite_gnustep_XXXX --suffix=.conf) sed -e "s|@BASEDIR@|$BASEDIR|g" "$OO_RESOURCESDIR/GNUstep.conf.template" > "$GNUSTEP_CONFIG_FILE" } @@ -141,32 +144,31 @@ make_gnustepconf_template() { # Check if we are running inside a Flatpak if [[ -n "$FLATPAK_ID" ]]; then BASEDIR="/app" - OO_EXEDIR="$BASEDIR/bin" - OO_RESOURCESDIR="$BASEDIR/share/oolite/Resources" - GAME_DATA="$HOME/.var/app/$FLATPAK_ID" + OO_EXEDIR="$(readlink -f "$BASEDIR/bin")" + OO_RESOURCESDIR="$(readlink -f "$BASEDIR/share/oolite/Resources")" + GAME_DATA="$(readlink -f "$HOME/.var/app/$FLATPAK_ID")" make_gnustepconf_template # Check if we are running inside an AppImage elif [[ -n "$APPIMAGE" ]]; then BASEDIR="$APPDIR" - OO_EXEDIR="$BASEDIR/bin" - OO_RESOURCESDIR="$BASEDIR/share/oolite/Resources" + OO_EXEDIR="$(readlink -f "$BASEDIR/bin")" + OO_RESOURCESDIR="$(readlink -f "$BASEDIR/share/oolite/Resources")" DEBUG_OXP=$(grep "debug_functionality_support" "$OO_EXEDIR/Resources/manifest.plist") if [[ "$DEBUG_OXP" == *"yes"* ]]; then - INTERNAL_ADDONS="$OO_EXEDIR/AddOns" + INTERNAL_ADDONS="$(readlink -f "$OO_EXEDIR/AddOns")" export OO_ADDITIONALADDONSDIRS="${OO_ADDITIONALADDONSDIRS}${OO_ADDITIONALADDONSDIRS:+,}$INTERNAL_ADDONS" fi if [[ -n "$OO_DIRTYPE" ]]; then if [[ "${OO_DIRTYPE,,}" == "xdg" ]]; then - GAME_DATA="$HOME/.local/share/Oolite" + GAME_DATA="$(readlink -f "$HOME/.local/share/Oolite")" elif [[ "${OO_DIRTYPE,,}" == "legacy" ]]; then launch_guarded "$@" fi else - # Get the folder containing the AppImage file - HERE="$(dirname "$APPIMAGE")" + HERE="$(dirname "$(readlink -f "$APPIMAGE")")" GAME_DATA="$HERE/GameData" fi make_gnustepconf_template @@ -174,13 +176,12 @@ else # Check if OO_DIRTYPE set if [[ -n "$OO_DIRTYPE" ]]; then if [[ "${OO_DIRTYPE,,}" == "xdg" ]]; then - GAME_DATA="$HOME/.local/share/Oolite" + GAME_DATA="$(readlink -f "$HOME/.local/share/Oolite")" elif [[ "${OO_DIRTYPE,,}" == "legacy" ]]; then find_exe_resources_dirs launch_guarded "$@" fi else - # Use script directory GAME_DATA="$HERE/GameData" fi find_exe_resources_dirs @@ -190,18 +191,19 @@ fi mkdir -p "$GAME_DATA" -export OO_SAVEDIR="${OO_SAVEDIR:-$GAME_DATA/SavedGames}" +export OO_SAVEDIR="$(readlink -f "${OO_SAVEDIR:-$GAME_DATA/SavedGames}")" mkdir -p "$OO_SAVEDIR" -export OO_SNAPSHOTSDIR="${OO_SNAPSHOTSDIR:-$GAME_DATA/Snapshots}" +export OO_SNAPSHOTSDIR="$(readlink -f "${OO_SNAPSHOTSDIR:-$GAME_DATA/Snapshots}")" mkdir -p "$OO_SNAPSHOTSDIR" -export OO_LOGSDIR="${OO_LOGSDIR:-$GAME_DATA/.logs}" +export OO_LOGSDIR="$(readlink -f "${OO_LOGSDIR:-$GAME_DATA/.logs}")" mkdir -p "$OO_LOGSDIR" -export OO_MANAGEDADDONSDIR="${OO_MANAGEDADDONSDIR:-$GAME_DATA/.ManagedAddOns}" +export OO_MANAGEDADDONSDIR="$(readlink -f "${OO_MANAGEDADDONSDIR:-$GAME_DATA/.ManagedAddOns}")" mkdir -p "$OO_MANAGEDADDONSDIR" if [[ -z "$OO_ADDONSEXTRACTDIR" ]]; then - export OO_ADDONSEXTRACTDIR="${OO_USERADDONSDIR:-$GAME_DATA/AddOns}" + export OO_ADDONSEXTRACTDIR="$(readlink -f "${OO_USERADDONSDIR:-$GAME_DATA/AddOns}")" elif [[ -n "$OO_USERADDONSDIR" ]]; then + OO_USERADDONSDIR="$(readlink -f "$OO_USERADDONSDIR")" if [[ ",$OO_ADDITIONALADDONSDIRS," != *",$OO_USERADDONSDIR,"* ]]; then export OO_ADDITIONALADDONSDIRS="${OO_ADDITIONALADDONSDIRS}${OO_ADDITIONALADDONSDIRS:+,}$OO_USERADDONSDIR" fi @@ -212,9 +214,9 @@ if [ -n "$OO_ADDITIONALADDONSDIRS" ]; then (IFS=,; mkdir -p $OO_ADDITIONALADDONSDIRS) fi -OO_GNUSTEPDIR="${OO_GNUSTEPDIR:-$GAME_DATA/.GNUstep}" +OO_GNUSTEPDIR="$(readlink -f "${OO_GNUSTEPDIR:-$GAME_DATA/.GNUstep}")" mkdir -p "$OO_GNUSTEPDIR" -OO_GNUSTEPDEFAULTSDIR="${OO_GNUSTEPDEFAULTSDIR:-${GAME_DATA}}" +OO_GNUSTEPDEFAULTSDIR="$(readlink -f "${OO_GNUSTEPDEFAULTSDIR:-${GAME_DATA}}")" mkdir -p "$OO_GNUSTEPDEFAULTSDIR" echo "" >> "$GNUSTEP_CONFIG_FILE" @@ -233,4 +235,4 @@ echo "GNUSTEP_USER_DIR_DOC_INFO=$OO_GNUSTEPDIR/Library/Documentation/info" >> "$ echo "GNUSTEP_USER_DEFAULTS_DIR=$OO_GNUSTEPDEFAULTSDIR" >> "$GNUSTEP_CONFIG_FILE" launch_guarded "$@" -rm "$GNUSTEP_CONFIG_FILE" +rm "$GNUSTEP_CONFIG_FILE" \ No newline at end of file diff --git a/src/Core/NSBundle+Override.m b/src/Core/NSBundle+Override.m index 34da80614..bf9d7e909 100644 --- a/src/Core/NSBundle+Override.m +++ b/src/Core/NSBundle+Override.m @@ -19,58 +19,38 @@ @implementation NSBundle (Override) - (NSDictionary *)infoDictionary { - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSString *startingDir = nil; - NSString *resourcesFolder = nil; - -#if OOLITE_WINDOWS - // Windows: Start from the forced local working directory - startingDir = [@"./" stringByStandardizingPath]; -#else - // Linux/GNUstep: Read from the kernel to avoid calling [[NSBundle mainBundle] executablePath], - // which would cause an infinite loop during early bundle initialization. - char result[PATH_MAX]; - ssize_t count = readlink("/proc/self/exe", result, PATH_MAX); - if (count != -1) { - NSString *exePath = [fileManager stringWithFileSystemRepresentation:result length:count]; - startingDir = [exePath stringByDeletingLastPathComponent]; - } else { - // Fallback to local directory if /proc is inaccessible - startingDir = [@"./" stringByStandardizingPath]; - } -#endif - - // If resourcesFolder wasn't explicitly assigned by the macOS branch, resolve it for Win/Linux - if (!resourcesFolder) { - NSString *primaryResourcesPath = [startingDir stringByAppendingPathComponent:@"Resources"]; - BOOL isDir = NO; - - if ([fileManager fileExistsAtPath:primaryResourcesPath isDirectory:&isDir] && isDir) { - resourcesFolder = primaryResourcesPath; - } else { - // Fallback: Look in startingDir / ../share/oolite/Resources (Standard Linux system layout) - NSString *fallbackPath = [[startingDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"share/oolite/Resources"]; - resourcesFolder = [fallbackPath stringByStandardizingPath]; - } - } - - // Append the target file name to the resolved path root - NSString *plistPath = [resourcesFolder stringByAppendingPathComponent:@"Info-gnustep.plist"]; - - // Load the target configuration file - NSDictionary *gnustepPlist = [NSDictionary dictionaryWithContentsOfFile:plistPath]; - NSMutableDictionary *workingDict = nil; - - if (gnustepPlist) { - workingDict = [gnustepPlist mutableCopy]; - } else { - // Fallback block prevents runtime crashes if files are missing during dev/build refactors - workingDict = [[NSMutableDictionary alloc] init]; - NSLog(@"[Oolite-Core] Warning: Failed to find info-gnustep.plist at calculated path: %@", plistPath); - } - - // Return the dictionary cleanly managed for memory (Pre-ARC environments) - return [workingDict autorelease]; + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSString *startingDir = [fileManager currentDirectoryPath]; // Start from cwd + + NSString *primaryResourcesPath = [startingDir stringByAppendingPathComponent:@"Resources"]; + BOOL isDir = NO; + + NSString *resourcesFolder = nil; + if ([fileManager fileExistsAtPath:primaryResourcesPath isDirectory:&isDir] && isDir) { + resourcesFolder = primaryResourcesPath; + } else { + // Fallback: Look in startingDir / ../share/oolite/Resources (Standard Linux system layout) + NSString *fallbackPath = [[startingDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"share/oolite/Resources"]; + resourcesFolder = [fallbackPath stringByStandardizingPath]; + } + + // Append the target file name to the resolved path root + NSString *plistPath = [resourcesFolder stringByAppendingPathComponent:@"Info-gnustep.plist"]; + + // Load the target configuration file + NSDictionary *gnustepPlist = [NSDictionary dictionaryWithContentsOfFile:plistPath]; + NSMutableDictionary *workingDict = nil; + + if (gnustepPlist) { + workingDict = [gnustepPlist mutableCopy]; + } else { + // Fallback block prevents runtime crashes if files are missing during dev/build refactors + workingDict = [[NSMutableDictionary alloc] init]; + NSLog(@"[Oolite-Core] Warning: Failed to find info-gnustep.plist at calculated path: %@", plistPath); + } + + // Return the dictionary cleanly managed for memory + return [workingDict autorelease]; } @end \ No newline at end of file diff --git a/src/Core/ResourceManager.m b/src/Core/ResourceManager.m index 7f870cf6e..fe48fe948 100644 --- a/src/Core/ResourceManager.m +++ b/src/Core/ResourceManager.m @@ -179,13 +179,10 @@ + (NSArray *)userRootPaths if (sUserRootPaths == nil) { + NSString *cwd = [[NSFileManager defaultManager] currentDirectoryPath]; // the paths are now in order of preference as per yesterday's talk. -- Kaks 2010-05-05 NSArray *defaultAddOnsPaths = [NSArray arrayWithObjects: -#if OOLITE_WINDOWS - [[[@"./" stringByStandardizingPath] - stringByDeletingLastPathComponent] - stringByAppendingPathComponent:@"share/oolite/AddOns"], -#elif OOLITE_MAC_OS_X +#if OOLITE_MAC_OS_X [[[[NSHomeDirectory() stringByAppendingPathComponent:@"Library"] stringByAppendingPathComponent:@"Application Support"] stringByAppendingPathComponent:@"Oolite"] @@ -194,15 +191,13 @@ + (NSArray *)userRootPaths stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"AddOns"], #else - [[[[[NSBundle mainBundle] executablePath] - stringByDeletingLastPathComponent] - stringByDeletingLastPathComponent] + [[cwd stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"share/oolite/AddOns"], #endif - @"AddOns", + [cwd stringByAppendingPathComponent:@"AddOns"], [[OOOXZManager sharedManager] extractAddOnsPath], nil]; - sUserRootPaths = [[[[OOOXZManager sharedManager] additionalAddOnsPaths] arrayByAddingObjectsFromArray:defaultAddOnsPaths] retain]; + sUserRootPaths = [[[[OOOXZManager sharedManager] additionalAddOnsPaths] arrayByAddingObjectsFromArray:defaultAddOnsPaths] retain]; } OOLog(@"searchPaths.debug",@"%@",sUserRootPaths); return sUserRootPaths; @@ -211,30 +206,22 @@ + (NSArray *)userRootPaths + (NSString *)builtInPath { - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSString *startingDir = nil; + NSFileManager *fileManager = [NSFileManager defaultManager]; -#if OOLITE_WINDOWS - // Windows: Start from the forced working directory - startingDir = [@"./" stringByStandardizingPath]; -#elif OOLITE_MAC_OS_X - // macOS: Use resourcePath directly and return it immediately. - return [[NSBundle mainBundle] resourcePath]; +#if OOLITE_MAC_OS_X + return [[NSBundle mainBundle] resourcePath]; // Use resourcePath directly #else - // Linux/GNUstep: Use bundlePath directly to manage local vs system layouts - startingDir = [[[NSBundle mainBundle] executablePath] - stringByDeletingLastPathComponent]; + NSString *startingDir = [fileManager currentDirectoryPath]; // Start from cwd #endif - // Look for a "Resources" folder (Windows & Linux) - NSString *primaryResourcesPath = [startingDir stringByAppendingPathComponent:@"Resources"]; - BOOL isDir = NO; - if ([fileManager fileExistsAtPath:primaryResourcesPath isDirectory:&isDir] && isDir) { - return primaryResourcesPath; - } - // Fallback: Look in startingDir / ../share/oolite/Resources - NSString *fallbackPath = [[startingDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"share/oolite/Resources"]; - return [fallbackPath stringByStandardizingPath]; + NSString *primaryResourcesPath = [startingDir stringByAppendingPathComponent:@"Resources"]; + BOOL isDir = NO; + if ([fileManager fileExistsAtPath:primaryResourcesPath isDirectory:&isDir] && isDir) { + return primaryResourcesPath; + } + // Fallback: Look in startingDir/../share/oolite/Resources + NSString *fallbackPath = [[startingDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"share/oolite/Resources"]; + return [fallbackPath stringByStandardizingPath]; } + (NSArray *)pathsWithAddOns diff --git a/src/SDL/main.m b/src/SDL/main.m index 9a40c232a..439614942 100644 --- a/src/SDL/main.m +++ b/src/SDL/main.m @@ -125,13 +125,23 @@ int main(int argc, char *argv[]) free(finalPath); - /* Windows amibtiously starts apps with the C library locale set to the + /* Windows ambitiously starts apps with the C library locale set to the system locale rather than the "C" locale as per spec. Fixing here so numbers don't behave strangely. */ setlocale(LC_ALL, "C"); -#else // Linux +#else // Linux and Mac +#if OOLITE_LINUX + char result[PATH_MAX]; + ssize_t count = readlink("/proc/self/exe", result, PATH_MAX - 1); + result[count] = '\0'; + char *last_slash = strrchr(result, '/'); + if (last_slash != NULL) { + *last_slash = '\0'; // Chop off the executable name, leaving just the directory + } + chdir(result); +#endif #define OO_SHOW_MSG(ooMsg, ooTitle, ooFlags) fprintf(stdout, "%s", ooMsg) #define TABS1 "\t\t" #define TABS2 "\t\t\t" From 6ed0b98d2d127c6ecb5c4fe40d8bf65d3cdb304b Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 17 Jun 2026 09:58:11 +1200 Subject: [PATCH 05/11] Add missing include --- Makefile | 1 - src/SDL/main.m | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ebc1bb7bd..9f5f32e5e 100755 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ define meson_build meson setup build/meson_$(2) $(1) --native-file $(NATIVE_FILE) --reconfigure 2>/dev/null || meson setup build/meson_$(2) $(1) --native-file $(NATIVE_FILE) meson compile -C build/meson_$(2) endef -# meson install -C build/meson_$(2) # Helper macro for syncing OXP files cleanly define sync_debug_oxp diff --git a/src/SDL/main.m b/src/SDL/main.m index 439614942..02a1c7b34 100644 --- a/src/SDL/main.m +++ b/src/SDL/main.m @@ -40,6 +40,8 @@ // selected, if more than one are available __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; +#elif OOLITE_LINUX +#include #endif GameController* controller; From 48922ce58e4cbb36bf9ddb6291a46011e47fb898 Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 17 Jun 2026 10:36:20 +1200 Subject: [PATCH 06/11] Fix appimage --- ShellScripts/Linux/install_freedesktop_fn.sh | 14 ++++++++------ installers/appimage/create_appimage.sh | 14 +++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ShellScripts/Linux/install_freedesktop_fn.sh b/ShellScripts/Linux/install_freedesktop_fn.sh index 24be048b9..8b2901a9c 100644 --- a/ShellScripts/Linux/install_freedesktop_fn.sh +++ b/ShellScripts/Linux/install_freedesktop_fn.sh @@ -37,17 +37,19 @@ install_freedesktop() { install -D "$1/run_oolite.sh" "$appbin/run_oolite.sh" || { echo "$err_msg install run_oolite.sh" >&2; return 1; } # Resources copy - mkdir -p "$appbin/Resources" - cp -rf "$1/Resources/." "$appbin/Resources/" || { echo "$err_msg copy Resources folder" >&2; return 1; } + local resourcesdir="$appshr/oolite/Resources" + mkdir -p "$resourcesdir" + cp -rf "$1/Resources/." "$resourcesdir/" || { echo "$err_msg copy Resources folder" >&2; return 1; } # AddOns copy if folder exists in oolite.app if [ -d "$1/AddOns" ]; then - mkdir -p "$appbin/AddOns" - cp -rf "$1/AddOns/." "$appbin/AddOns/" || { echo "$err_msg copy AddOns folder" >&2; return 1; } + local addonsdir="$appshr/oolite/AddOns" + mkdir -p "$addonsdir" + cp -rf "$1/AddOns/." "$addonsdir/" || { echo "$err_msg copy AddOns folder" >&2; return 1; } fi - rm -f "$appbin/Resources/GNUstep.conf.orig" - install -D "GNUstep.conf.template" "$appbin/Resources/GNUstep.conf.template" || { echo "$err_msg GNUstep template" >&2; return 1; } + rm -f "$resourcesdir/GNUstep.conf.orig" + install -D "GNUstep.conf.template" "$resourcesdir/GNUstep.conf.template" || { echo "$err_msg GNUstep template" >&2; return 1; } local app_metainfo="$appshr/metainfo/space.oolite.Oolite.$4.xml" install -D ../../installers/FreeDesktop/space.oolite.Oolite.metainfo.xml.template "$app_metainfo" || { echo "$err_msg metainfo template" >&2; return 1; } diff --git a/installers/appimage/create_appimage.sh b/installers/appimage/create_appimage.sh index 6e947cd53..e81c99d75 100755 --- a/installers/appimage/create_appimage.sh +++ b/installers/appimage/create_appimage.sh @@ -18,14 +18,14 @@ run_script() { source ../ShellScripts/Linux/install_freedesktop_fn.sh local arch=$(uname -m) - local appdir="./oolite.AppDir" - export appdir - local appbin="$appdir/bin" - local appshr="$appdir/share" - rm -rf "$appdir" + local APPDIR="./oolite.AppDir" + export APPDIR + local appbin="$APPDIR/bin" + local appshr="$APPDIR/share" + rm -rf "$APPDIR" local abs_oolitedir=$(realpath -m "$1") - local abs_appdir=$(realpath -m "$appdir") + local abs_appdir=$(realpath -m "$APPDIR") if ! install_freedesktop "$abs_oolitedir" "$abs_appdir" bin appdata; then return 1 fi @@ -81,7 +81,7 @@ run_script() { fi echo "🔍 Running AppDir linter..." - if ! "$linter_bin" "$appdir"; then + if ! "$linter_bin" "$APPDIR"; then echo "❌ AppDir linting failed!" >&2 return 1 fi From 8aef3340101329c46a02cf15fdf425d582aa8a23 Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 17 Jun 2026 11:00:56 +1200 Subject: [PATCH 07/11] Fix appimage --- ShellScripts/Linux/run_oolite.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ShellScripts/Linux/run_oolite.sh b/ShellScripts/Linux/run_oolite.sh index a9c829686..c9be06aa9 100755 --- a/ShellScripts/Linux/run_oolite.sh +++ b/ShellScripts/Linux/run_oolite.sh @@ -155,9 +155,9 @@ elif [[ -n "$APPIMAGE" ]]; then OO_EXEDIR="$(readlink -f "$BASEDIR/bin")" OO_RESOURCESDIR="$(readlink -f "$BASEDIR/share/oolite/Resources")" - DEBUG_OXP=$(grep "debug_functionality_support" "$OO_EXEDIR/Resources/manifest.plist") + DEBUG_OXP=$(grep "debug_functionality_support" "$OO_RESOURCESDIR/manifest.plist") if [[ "$DEBUG_OXP" == *"yes"* ]]; then - INTERNAL_ADDONS="$(readlink -f "$OO_EXEDIR/AddOns")" + INTERNAL_ADDONS="$(readlink -f "$BASEDIR/share/oolite/AddOns")" export OO_ADDITIONALADDONSDIRS="${OO_ADDITIONALADDONSDIRS}${OO_ADDITIONALADDONSDIRS:+,}$INTERNAL_ADDONS" fi From 65443798137c4f7255afc163d7c42d4bba4712d0 Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 17 Jun 2026 13:21:08 +1200 Subject: [PATCH 08/11] AddOns folder handled in ObjC now --- ShellScripts/Linux/run_oolite.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ShellScripts/Linux/run_oolite.sh b/ShellScripts/Linux/run_oolite.sh index c9be06aa9..81e925223 100755 --- a/ShellScripts/Linux/run_oolite.sh +++ b/ShellScripts/Linux/run_oolite.sh @@ -155,12 +155,6 @@ elif [[ -n "$APPIMAGE" ]]; then OO_EXEDIR="$(readlink -f "$BASEDIR/bin")" OO_RESOURCESDIR="$(readlink -f "$BASEDIR/share/oolite/Resources")" - DEBUG_OXP=$(grep "debug_functionality_support" "$OO_RESOURCESDIR/manifest.plist") - if [[ "$DEBUG_OXP" == *"yes"* ]]; then - INTERNAL_ADDONS="$(readlink -f "$BASEDIR/share/oolite/AddOns")" - export OO_ADDITIONALADDONSDIRS="${OO_ADDITIONALADDONSDIRS}${OO_ADDITIONALADDONSDIRS:+,}$INTERNAL_ADDONS" - fi - if [[ -n "$OO_DIRTYPE" ]]; then if [[ "${OO_DIRTYPE,,}" == "xdg" ]]; then GAME_DATA="$(readlink -f "$HOME/.local/share/Oolite")" From 56bd147e06d3c351aaa3545917b04a61c65bba70 Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 17 Jun 2026 13:46:16 +1200 Subject: [PATCH 09/11] Fix duplication --- src/Core/ResourceManager.m | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Core/ResourceManager.m b/src/Core/ResourceManager.m index fe48fe948..eebd1e33f 100644 --- a/src/Core/ResourceManager.m +++ b/src/Core/ResourceManager.m @@ -267,11 +267,6 @@ + (NSArray *)pathsWithAddOns // validate default search paths DESTROY(sSearchPaths); sSearchPaths = [NSMutableArray new]; - NSString *builtIn = [self builtInPath]; - if (builtIn != nil) - { - [sSearchPaths addObject:builtIn]; - } foreach (path, existingRootPaths) { [self checkPotentialPath:path :sSearchPaths]; From c5d588cc4f4d0549ae2eeb77dc1431616483ec3b Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 17 Jun 2026 15:39:15 +1200 Subject: [PATCH 10/11] Fix override header --- src/Core/NSBundle+Override.h | 9 --------- src/Core/NSBundle+Override.m | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Core/NSBundle+Override.h b/src/Core/NSBundle+Override.h index 6bdc3dc34..1de4855cd 100644 --- a/src/Core/NSBundle+Override.h +++ b/src/Core/NSBundle+Override.h @@ -8,13 +8,4 @@ */ - (NSDictionary *)infoDictionary; -/** - * Locates the cross-platform built-in Oolite Resources directory. - * Resolves different structures across Windows local installs, macOS app bundles, - * and Linux/GNUstep global / local file hierarchies. - * - * @return A standardized absolute string path to the active 'Resources' directory. - */ -+ (NSString *)builtInPath; - @end \ No newline at end of file diff --git a/src/Core/NSBundle+Override.m b/src/Core/NSBundle+Override.m index bf9d7e909..531a7306a 100644 --- a/src/Core/NSBundle+Override.m +++ b/src/Core/NSBundle+Override.m @@ -3,7 +3,7 @@ * * Oolite Core Framework Override * Bypasses standard plist loading to manually locate and parse info-gnustep.plist - * across Windows, macOS, and Linux environments safely at boot. + * across Windows and Linux environments safely at boot. */ #import "NSBundle+Override.h" From 4bf44ff3e4706d396065599652a29f996c4748e1 Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 17 Jun 2026 15:41:16 +1200 Subject: [PATCH 11/11] Remove unneeded imports from override --- src/Core/NSBundle+Override.m | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Core/NSBundle+Override.m b/src/Core/NSBundle+Override.m index 531a7306a..f2d33dbcd 100644 --- a/src/Core/NSBundle+Override.m +++ b/src/Core/NSBundle+Override.m @@ -11,11 +11,6 @@ #import #import -#if OOLITE_LINUX -#import -#import -#endif - @implementation NSBundle (Override) - (NSDictionary *)infoDictionary {