mirror of
https://github.com/fleetdm/fleet
synced 2026-05-01 18:37:37 +00:00
This pull request updates the installation process for the GitHub Desktop application on macOS. The main improvement is switching the extraction method in the install script from `unzip` to `ditto` with the `--noqtn` flag, which prevents the app bundle from being quarantined after installation. This change is reflected in both the input configuration and the generated output files. **Install script improvements:** - The install script for GitHub Desktop (`github-desktop-install.sh`) now uses `ditto -xk --noqtn` instead of `unzip` to extract the application, ensuring the app is not marked as quarantined by macOS after installation. - The script logic and structure have been slightly refactored for clarity, but the core install and relaunch logic remains the same. **Configuration and reference updates:** - The `install_script_path` property was added to the Homebrew input JSON for GitHub Desktop, pointing to the new install script. - The output configuration (`darwin.json`) updates the install script reference to the new version and includes the updated script content. [[1]](diffhunk://#diff-d9d687547de8380c36144e69b184a84cbfa749eae965cab3cb313e2ff88eff20L9-R9) [[2]](diffhunk://#diff-d9d687547de8380c36144e69b184a84cbfa749eae965cab3cb313e2ff88eff20L18-R18) **Related issue:** Resolves #38679
94 lines
2.7 KiB
Bash
94 lines
2.7 KiB
Bash
#!/bin/sh
|
|
|
|
# variables
|
|
APPDIR="/Applications/"
|
|
TMPDIR=$(dirname "$(realpath $INSTALLER_PATH)")
|
|
|
|
# functions
|
|
|
|
quit_and_track_application() {
|
|
local bundle_id="$1"
|
|
local var_name="APP_WAS_RUNNING_$(echo "$bundle_id" | tr '.-' '__')"
|
|
local timeout_duration=10
|
|
|
|
# check if the application is running
|
|
if ! osascript -e "application id \"$bundle_id\" is running" 2>/dev/null; then
|
|
eval "export $var_name=0"
|
|
return
|
|
fi
|
|
|
|
local console_user
|
|
console_user=$(stat -f "%Su" /dev/console)
|
|
if [[ $EUID -eq 0 && "$console_user" == "root" ]]; then
|
|
echo "Not logged into a non-root GUI; skipping quitting application ID '$bundle_id'."
|
|
eval "export $var_name=0"
|
|
return
|
|
fi
|
|
|
|
# App was running, mark it for relaunch
|
|
eval "export $var_name=1"
|
|
echo "Application '$bundle_id' was running; will relaunch after installation."
|
|
|
|
echo "Quitting application '$bundle_id'..."
|
|
|
|
# try to quit the application within the timeout period
|
|
local quit_success=false
|
|
SECONDS=0
|
|
while (( SECONDS < timeout_duration )); do
|
|
if osascript -e "tell application id \"$bundle_id\" to quit" >/dev/null 2>&1; then
|
|
if ! pgrep -f "$bundle_id" >/dev/null 2>&1; then
|
|
echo "Application '$bundle_id' quit successfully."
|
|
quit_success=true
|
|
break
|
|
fi
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
if [[ "$quit_success" = false ]]; then
|
|
echo "Application '$bundle_id' did not quit."
|
|
fi
|
|
}
|
|
|
|
relaunch_application() {
|
|
local bundle_id="$1"
|
|
local var_name="APP_WAS_RUNNING_$(echo "$bundle_id" | tr '.-' '__')"
|
|
local was_running
|
|
|
|
# Check if the app was running before installation
|
|
eval "was_running=\$$var_name"
|
|
if [[ "$was_running" != "1" ]]; then
|
|
return
|
|
fi
|
|
|
|
local console_user
|
|
console_user=$(stat -f "%Su" /dev/console)
|
|
if [[ $EUID -eq 0 && "$console_user" == "root" ]]; then
|
|
echo "Not logged into a non-root GUI; skipping relaunching application ID '$bundle_id'."
|
|
return
|
|
fi
|
|
|
|
echo "Relaunching application '$bundle_id'..."
|
|
|
|
# Try to launch the application
|
|
if osascript -e "tell application id \"$bundle_id\" to activate" >/dev/null 2>&1; then
|
|
echo "Application '$bundle_id' relaunched successfully."
|
|
else
|
|
echo "Failed to relaunch application '$bundle_id'."
|
|
fi
|
|
}
|
|
|
|
# Extract with ditto and --noqtn so extracted files do NOT get quarantine.
|
|
ditto -xk --noqtn "$INSTALLER_PATH" "$TMPDIR"
|
|
|
|
# copy to the applications folder (do not modify the app bundle after extraction)
|
|
quit_and_track_application 'com.github.GitHubClient'
|
|
if [ -d "$APPDIR/GitHub Desktop.app" ]; then
|
|
sudo mv "$APPDIR/GitHub Desktop.app" "$TMPDIR/GitHub Desktop.app.bkp"
|
|
fi
|
|
sudo cp -R "$TMPDIR/GitHub Desktop.app" "$APPDIR"
|
|
|
|
relaunch_application 'com.github.GitHubClient'
|
|
|
|
mkdir -p .
|
|
/bin/ln -h -f -s -- "$APPDIR/GitHub Desktop.app/Contents/Resources/app/static/github.sh" "github"
|