Describe the bug
When using erase-install with the --update --sameos switch combination, invalid installers are not successfully removed if they are a different OS version than the current OS version.
For testing purposes, I manually installed the .pkg and then set up a Jamf Pro Policy to run the command using the Files and Processes policy payload. This was run on a macOS Ventura Mac Mini, where a Monterey installer was already present in the /Applications folder.
Expected behavior
The Monterey installer should have been removed from /Applications and replaced with the latest Ventura installer.
Code/log output
2024-02-08 10:20:13 | v32.0 | [log_rotate] Finished rotating logs in /Library/Management/erase-install/log
2024-02-08 10:20:13 | v32.0 | [erase-install] v32.0 script execution started: Thu Feb 8 10:20:13 GMT 2024
2024-02-08 10:20:13 | v32.0 | [erase-install] Arguments provided: --reinstall --update --sameos --credentials [REDACTED] --very-insecure-mode
2024-02-08 10:20:13 | v32.0 | [erase-install] System version: 13.4.1 (Build: 22F82)
id: loginwindow: no such user
no user logged in
2024-02-08 10:20:14 | v32.0 | [check_for_swiftdialog_app] swiftDialog v is installed (/Library/Application Support/Dialog/Dialog.app)
2024-02-08 10:20:14 | v32.0 | [check_for_swiftdialog_app] Creating dialog log (/var/tmp/dialog.VRG)...
2024-02-08 10:20:14 | v32.0 | [erase-install] Caffeinating this script (pid=14775)
2024-02-08 10:20:14 | v32.0 | [check_free_space] OK - 285 GB free/purgeable disk space detected
2024-02-08 10:20:14 | v32.0 | [erase-install] Looking for existing installer app or pkg
2024-02-08 10:20:14 | v32.0 | [find_existing_installer] Installer found at /Applications/Install macOS Monterey.app.
2024-02-08 10:20:14 | v32.0 | [check_installer_is_valid] Checking validity of /Applications/Install macOS Monterey.app.
2024-02-08 10:20:14 | v32.0 | [check_installer_is_valid] Mounting /Applications/Install macOS Monterey.app/Contents/SharedSupport/SharedSupport.dmg
2024-02-08 10:20:15 | v32.0 | [check_installer_is_valid] Using Build value from com_apple_MobileAsset_MacSoftwareUpdate.xml
2024-02-08 10:20:15 | v32.0 | [check_installer_is_valid] Installer is compatible with system
Volume Shared Support on disk4s2 force-unmounted
2024-02-08 10:20:16 | v32.0 | [compare_build_versions] Comparing (1) 22F82 with (2) 21G725
2024-02-08 10:20:16 | v32.0 | [compare_build_versions] 22F82 > 21G725
2024-02-08 10:20:16 | v32.0 | [check_installer_is_valid] Installer: 21G725 < System: 22F82 : invalid build.
2024-02-08 10:20:16 | v32.0 | [erase-install] Checking for newer installer
2024-02-08 10:20:16 | v32.0 | [check_for_mist] mist is installed (/usr/local/bin/mist)
2024-02-08 10:20:16 | v32.0 | [check_newer_available] Restricting to selected OS '13'
┌──────────────────┐
│ INPUT VALIDATION │
└──────────────────┘
├─ List search string will be 'Ventura'...
├─ Search only for latest (first) result will be 'true'...
├─ Include betas in search results will be 'false'...
├─ Only include compatible installers will be 'true'...
├─ Export path will be '/Library/Management/erase-install/mist-list.json'...
├─ Export path file extension is valid...
├─ Output type will be 'ascii'...
┌────────┐
│ SEARCH │
└────────┘
├─ Searching for macOS Installer versions...
├─ Exported list as JSON: '/Library/Management/erase-install/mist-list.json'
└─ Found 1 macOS Installer(s) available for download
┌────────────┬───────────────┬─────────┬────────┬──────────┬────────────┬────────────┐
│ IDENTIFIER │ NAME │ VERSION │ BUILD │ SIZE │ DATE │ COMPATIBLE │
├────────────┼───────────────┼─────────┼────────┼──────────┼────────────┼────────────┤
│ 052-33049 │ macOS Ventura │ 13.6.4 │ 22G513 │ 12.21 GB │ 2024-01-22 │ True │
└────────────┴───────────────┴─────────┴────────┴──────────┴────────────┴────────────┘
Comparing latest build found (22G513) with cached installer build (21G725)
2024-02-08 10:20:18 | v32.0 | [compare_build_versions] Comparing (1) 22G513 with (2) 21G725
2024-02-08 10:20:18 | v32.0 | [compare_build_versions] 22G513 > 21G725
2024-02-08 10:20:18 | v32.0 | [erase-install] Newer installer found.
2024-02-08 10:20:18 | v32.0 | [erase-install] ERROR: Invalid installer is present. Run with --overwrite, --update or --replace-invalid option to ensure that a valid installer is obtained.
2024-02-08 10:20:18 | v32.0 | [erase-install] attempting to terminate the 'caffeinate' process - Termination message indicates success
2024-02-08 10:20:18 | v32.0 | [finish] sending quit message to dialog (/var/tmp/dialog.VRG)
2024-02-08 10:20:18 | v32.0 | [finish] Script exit code: 1
Screenshots
Not applicable as this was run via policy while not logged in
Environment
OS version - macOS Ventura 13.4.1 (Build: 22F82)
erase-install version - v32.0 (latest stable release)
Describe the bug When using erase-install with the
--update --sameos
switch combination, invalid installers are not successfully removed if they are a different OS version than the current OS version.To Reproduce
/Library/Management/erase-install/erase-install.sh --reinstall --update --sameos --credentials [REDACTED] --very-insecure-mode
Expected behavior The Monterey installer should have been removed from /Applications and replaced with the latest Ventura installer.
Code/log output
Screenshots Not applicable as this was run via policy while not logged in
Environment