refactor: Improve Solaar path resolution in macOS helper scripts
This change improves the robustness of the macOS helper scripts by ensuring the Solaar executable is found before proceeding. Previously, `create-macos-launchagent.sh` would only issue a warning and continue with a potentially invalid path if the `solaar` command was not found. `create-macos-app.sh` had a typo (`SOLAR_PATH`) and lacked a check altogether. Now, both scripts (`create-macos-app.sh` and `create-macos-launchagent.sh`) will: - Correctly check if the `solaar` executable exists in the system's `PATH`. - Use the resolved, absolute path to the executable to avoid ambiguity. - Exit with an error if the executable cannot be found, preventing the creation of a broken app bundle or launch agent.
This commit is contained in:
parent
335109c800
commit
436639ea91
|
|
@ -3,7 +3,12 @@
|
|||
set -euo pipefail
|
||||
|
||||
APP_ROOT=${1:-/Applications/Solaar.app}
|
||||
SOLAR_PATH=${SOLAR_PATH:-solaar}
|
||||
SOLAAR_PATH=${SOLAAR_PATH:-solaar}
|
||||
SOLAAR_RESOLVED_PATH=$(command -v "${SOLAAR_PATH}" 2>/dev/null || echo "")
|
||||
if [ -z "${SOLAAR_RESOLVED_PATH}" ]; then
|
||||
echo "Error: '${SOLAAR_PATH}' not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
ICON_SOURCE=${ICON_SOURCE:-share/solaar/icons/solaar.svg}
|
||||
|
||||
case "${APP_ROOT}" in
|
||||
|
|
@ -26,7 +31,7 @@ WRAPPER="${MACOS_DIR}/solaar-wrapper"
|
|||
cat > "${WRAPPER}" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
exec "${SOLAR_PATH}" --window=hide "\$@"
|
||||
exec "${SOLAAR_RESOLVED_PATH}" "\$@"
|
||||
EOF
|
||||
chmod +x "${WRAPPER}"
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ set -euo pipefail
|
|||
SOLAAR_PATH=${SOLAAR_PATH:-solaar}
|
||||
SOLAAR_RESOLVED_PATH=$(command -v "${SOLAAR_PATH}" 2>/dev/null || echo "")
|
||||
if [ -z "${SOLAAR_RESOLVED_PATH}" ]; then
|
||||
echo "Warning: '${SOLAAR_PATH}' not found" >&2
|
||||
SOLAAR_RESOLVED_PATH="${SOLAAR_PATH}"
|
||||
echo "Error: '${SOLAAR_PATH}' not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LAUNCH_AGENT_DIR="${HOME}/Library/LaunchAgents"
|
||||
|
|
|
|||
Loading…
Reference in New Issue