5 Commits
Author SHA1 Message Date
CarloandAllen Houchins 0594f653dd Propagate errors in macOS FMA install scripts (#50198)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #50056

## Summary

macOS FMA install scripts never checked the exit code of the install
command (`installer -pkg` / `cp -R`) — the script's last statement is
always `relaunch_application`, which exits 0 — so a failed install
exited 0 and Fleet reported it installed.

**Generated scripts.** The generator now propagates failure: both
`installer -pkg` variants end with `|| exit $?`, and the `cp -R` path
exits non-zero on a failed copy, removes the partial copy (so a failed
fresh install isn't inventoried as the new version), and restores the
app it moved aside. Regenerated `outputs/` for non-frozen generated apps
are produced by the `ingest-maintained-apps` job, so they aren't
committed here.

**Custom scripts.** 9 of the 18 custom input scripts had the same bug
and are fixed with the same pattern: Google Chrome, Zoom, Microsoft
Edge, GitHub Desktop, Webex, Cycling '74 Max, Pd, Grammarly Desktop, and
P4V. The DMG-based ones also now fail before removing/moving the
existing app when the mount or staging copy fails, so a bad download
can't leave a host with nothing. Their `outputs/*/darwin.json` are
updated in the same commit (script content + recomputed 8-char sha256
ref, versions untouched), following the precedent of #49033. Docker
Desktop (`set -euo pipefail`), 1Password/Slack/LogiTune (installer is
the last statement), and the rest already propagated errors.

**Frozen apps.** The ingest job never rewrites frozen outputs, so the 10
frozen apps with generated scripts (adobe-acrobat-pro, comet, evernote,
firealpaca, keeper-password-manager, nvidia-geforce-now, pritunl,
vnc-viewer, wins, worksheet-crafter) had the fix applied directly to
their published `darwin.json` scripts — the exact text the current
generator would emit, with pinned versions/URLs/hashes untouched. The
11th frozen app (logi-options+) uses a custom script that was already
correct and in sync.

# Checklist for submitter

- [x] Changes file added for user-visible changes in `changes/`
(`changes/50056-fma-install-scripts-ignore-errors`).
- [x] Untrusted data interpolated into shell scripts is validated
against shell metacharacters. (No new untrusted interpolation: the guard
reuses the same curated cask-derived name the adjacent lines already
interpolate.)

## Testing

- [x] Added/updated automated tests (three generator tests: pkg,
pkg-with-choices, cp-R restore — the last now pins the exact emitted
block).
- [x] All 19 updated output manifests validated: embedded scripts pass
`bash -n`, refs match `sha256(script)[:8]`, refs map stays key-sorted
like Go's encoder.
- [x] QA'd all new/changed functionality manually.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* macOS Fleet-maintained app installations now fail fast when
installers, DMG extraction/mounting, or app copy steps error.
* If an upgrade fails, the system removes any partial app and restores
the previously installed version when available.
* Improved robustness during app staging/copying, including safer
handling of paths with spaces or special characters.
* **Tests**
* Added unit coverage to verify installer failure propagation and
rollback behavior.
* **Documentation**
* Clarified that the install-script error handling applies to both
generated and custom scripts, including already-published frozen apps.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Allen Houchins <allenhouchins@mac.com>
2026-07-30 14:22:02 -05:00
Allen Houchins 598f425b66 Sync GitHub Desktop FMA install script with current quit/relaunch helpers (#49030)
**Related issue:** Resolves #48639

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements), JS
inline code is prevented especially for url redirects, and untrusted
data interpolated into shell scripts/commands is validated against shell
metacharacters.
- [x] Timeouts are implemented and retries are limited to avoid infinite
loops

## Testing

- [x] QA'd all new/changed functionality manually

## Details

The GitHub Desktop FMA uses a custom install script
(`ee/maintained-apps/inputs/homebrew/scripts/github-desktop-install.sh`)
that embeds its own copies of `quit_and_track_application` and
`relaunch_application`. Those copies were frozen before two fixes landed
in the generated helpers in
`ee/maintained-apps/ingesters/homebrew/scripts.go`:

- #42951 — check osascript **output** instead of exit status. `osascript
-e '... is running'` exits 0 whether it prints `true` or `false`, so the
stale `if ! osascript ...` guard never fired. The app was marked
`APP_WAS_RUNNING=1` on **every** install with a GUI user logged in and
relaunched after every patch — even from a fully-quit state. This is the
root cause of #48639.
- #43842 — relaunch via `launchctl asuser ... open -b` as the console
user instead of `osascript ... to activate` (which is unreliable from a
root context), plus the updated empty/root/loginwindow console-user
guards.

This PR replaces both embedded functions with the current scripts.go
constants (verified byte-for-byte identical) and regenerates
`ee/maintained-apps/outputs/github/darwin.json` via `go run
./cmd/maintained-apps -slug github`. The manifest diff is
script-ref-only (`98ab6ed8` → `c91ea2b5`); version and uninstall script
are unchanged. The other five custom scripts (Docker Desktop, OpenVPN
Connect, Webex, Max, Pd) already carry the updated helpers — GitHub
Desktop was the only one missed.

## Manual QA

Tested the updated `quit_and_track_application` / `relaunch_application`
functions on macOS against GitHub Desktop itself
(`com.github.GitHubClient`):

- **Fully quit (the bug scenario):** verified `is running` returns
`false` and zero `GitHub Desktop.app` processes. Fixed functions set
`APP_WAS_RUNNING=0` and the app stays closed. Running the old shipped
check (`if ! osascript ...`) against the same state misclassifies the
app as running (osascript exits 0 with output `false`) and would have
relaunched it.
- **Running:** quit succeeds, `APP_WAS_RUNNING=1`, app relaunches
successfully afterward.
- `bash -n` passes on the updated script.

Note: hosts where the FMA was already added keep the baked `98ab6ed8`
script until their instance refreshes the manifest. The by-design
behavior "app running with dock icon but no visible window → relaunched
with a window" is unchanged; window-aware relaunching would be a
separate enhancement.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved GitHub Desktop installation behavior on macOS so the app is
more reliably closed and reopened after install.
* Better handles login/session edge cases, helping ensure the app
relaunches in the correct user’s desktop session.
* Reduces failed or missed relaunches when the installer is run with
elevated permissions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-09 09:36:51 -05:00
Allen Houchins 26a8345c05 Switch scripts to bash and update refs (#44853)
Replace /bin/sh shebangs with /bin/bash across numerous Homebrew input
scripts to support bash-specific constructs (local, arrays, [[ ]],
etc.). Update darwin.json refs for multiple apps (notably 1password,
adobe-acrobat-pro, adobe-creative-cloud) to point to new
install/uninstall script refs and replace inline script bodies with bash
variants. Also remove ee/maintained-apps/outputs/docker/darwin.json.
Changes affect ee/maintained-apps/inputs/homebrew/scripts/* and
corresponding ee/maintained-apps/outputs/* darwin.json entries.
2026-05-06 12:21:11 -05:00
Allen Houchins 3270c9f9a4 Quote $INSTALLER_PATH when computing TMPDIR (#44396)
Wrap $INSTALLER_PATH in quotes when calling realpath to compute TMPDIR
to avoid word-splitting for paths containing spaces. Updated the
homebrew script builder and multiple installer scripts (dbeaver
variants, evernote, github-desktop, grammarly, logi-options-plus,
microsoft-edge, omnigraffle, royal-tsx) and bumped the install script
refs in firefox and firefox@esr darwin outputs to the updated script.


<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #43712

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Enhanced Homebrew installation scripts for multiple applications to
properly handle installer paths containing spaces and special
characters. Affected applications include DBEaver Enterprise, DBEaver
Lite, DBEaver Ultimate, Evernote, GitHub Desktop, Grammarly Desktop,
Logi Options+, Microsoft Edge, OmniGraffle, Royal TSX, and Firefox.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-29 13:01:32 -05:00
Allen Houchins 3fbaa2c5b7 Add custom install script for GitHub Desktop (#39132)
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
2026-02-01 21:51:34 -06:00