From 8c43e966b1a4ed2262b75708aef67e4cdcbb135d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 12 Feb 2020 10:06:51 +0300 Subject: [PATCH] Allow environment variable to set the Lua executable For some distros (e.g. Arch Linux) packaging binaries compiled elsewhere is a big no-no, and the more so when they are duplicates of something the system has anyway. The current Arch Linux packaging for example has to remove the generated binaries from the installation, then patch this wrapper script to use the system Lua executable. This change will make that process easier. First it will be possible to run with a different Lua executable by setting an environment variable: LUA_EXECUTABLE=/usr/bin/lua zbstudio Second, the coding style in the script will make it much easier to patch to make the that choice stick. --- zbstudio/zbstudio.in | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/zbstudio/zbstudio.in b/zbstudio/zbstudio.in index b6150aa68..959e4a170 100644 --- a/zbstudio/zbstudio.in +++ b/zbstudio/zbstudio.in @@ -1,7 +1,17 @@ #!/usr/bin/env sh -if [[ "$(uname -m)" == "x86_64" ]]; then ARCH="x64"; else ARCH="x86"; fi -CWD="$PWD" # save the current directory, as it's going to change +# Stash the current PWD so we can pass it to the IDE, the +# IDE itself will be launched from it's own location +CWD="$PWD" + +# Figure out which architecture binary is approprate for the host system +case $(uname -m) in + *64) ARCH="x64" ;; + *) ARCH="x86" ;; +esac + +# Lua executable to run, can be overridden with ENV variable +: ${LUA_EXECUTABLE:="bin/linux/$ARCH/lua"} cd "@IDE_DATADIR@" -exec bin/linux/$ARCH/lua src/main.lua zbstudio -cwd "$CWD" "$@" +exec "$LUA_EXECUTABLE" src/main.lua zbstudio -cwd "$CWD" "$@"