diff --git a/ldnp/abstractpackager.py b/ldnp/abstractpackager.py index f632f34..88d2a34 100644 --- a/ldnp/abstractpackager.py +++ b/ldnp/abstractpackager.py @@ -158,7 +158,14 @@ def create_binary_script(script_path: str | os.PathLike, target_binary: str | os "", "set -e", "", - f'script_dir="{shlex.quote(str(self.appdir_installed_path))}/apprun-hooks"', + "# might be used by some AppRun scripts, e.g., craft runenv hook", + f"this_dir={shlex.quote(str(self.appdir_installed_path))}", + "", + "# might be used by some other scripts, generally a good idea to set it", + 'APPDIR="this_dir"', + "export APPDIR", + "", + f'script_dir="$APPDIR/apprun-hooks"', f'if [ -d "$script_dir" ]; then', ' for script in "$script_dir"/*; do', ' . "$script"',