grahampugh / erase-install

A script that automates downloading macOS installers, and optionally erasing or upgrading macOS in a single process. Watch the video!
https://grahamrpugh.com/2023/05/14/macaduk-presentation-eraseinstall.html
Apache License 2.0
834 stars 131 forks source link

[BUG] --update parameter doesn't replace installer cached by legacy script #480

Closed rknauer7 closed 7 months ago

rknauer7 commented 7 months ago

Describe the bug Using a legacy version of the erase-install script may lead to invalid-installer errors after utilizing a more recent version of the erase-install script. The cause seems to be a cached sparseimage that doesn't get replaced despite --overwrite or --update parameters being used.

To Reproduce

Expected behavior --update command was expected to overwrite any older or outdated packages.

Code/log output

Script result: 2024-01-31 09:41:21 | v31.0 | [log_rotate] Finished rotating logs in /Library/Management/erase-install/log

2024-01-31 09:41:21 | v31.0 | [erase-install] v31.0 script execution started: Wed Jan 31 09:41:21 EST 2024

2024-01-31 09:41:21 | v31.0 | [erase-install] Arguments provided: / <redacted> --reinstall --update --os=14 --no-fs --check-power   
2024-01-31 09:41:21 | v31.0 | [erase-install] System version: 13.4.1 (Build: 22F82)
2024-01-31 09:41:22 | v31.0 | [erase-install] A newer version of this script is available. Visit https://github.com/grahampugh/erase-install/releases/tag/v32.0 to obtain the latest version.
2024-01-31 09:41:23 | v31.0 | [check_for_swiftdialog_app] swiftDialog v2.3.2.4726 is installed (/Library/Application Support/Dialog/Dialog.app)
2024-01-31 09:41:23 | v31.0 | [check_for_swiftdialog_app] Creating dialog log (/var/tmp/dialog.mfk)...
2024-01-31 09:41:23 | v31.0 | [erase-install] Caffeinating this script (pid=6965)
2024-01-31 09:41:23 | v31.0 | [check_free_space] OK - 363 GB free/purgeable disk space detected
2024-01-31 09:41:23 | v31.0 | [erase-install] Looking for existing installer app or pkg
2024-01-31 09:41:23 | v31.0 | [find_existing_installer] Installer sparse image found at /Library/Management/erase-install/Install_macOS_12.7-21G816.sparseimage.
2024-01-31 09:41:23 | v31.0 | [check_installer_is_valid] Checking validity of /Volumes/Install_macOS_12.7-21G816/Applications/Install macOS Monterey.app.
2024-01-31 09:41:23 | v31.0 | [check_installer_is_valid] Mounting /Volumes/Install_macOS_12.7-21G816/Applications/Install macOS Monterey.app/Contents/SharedSupport/SharedSupport.dmg
2024-01-31 09:41:24 | v31.0 | [check_installer_is_valid] Using Build value from com_apple_MobileAsset_MacSoftwareUpdate.xml
Volume Shared Support on disk3s2 force-unmounted
2024-01-31 09:41:26 | v31.0 | [compare_build_versions] Comparing (1) 22F82 with (2) 21G816
2024-01-31 09:41:26 | v31.0 | [compare_build_versions] 22F82 > 21G816
2024-01-31 09:41:26 | v31.0 | [check_installer_is_valid] Installer: 21G816 < System: 22F82 : invalid build.
2024-01-31 09:41:26 | v31.0 | [erase-install] Existing installer OS version does not match requested OS (14).
2024-01-31 09:41:26 | v31.0 | [erase-install] Checking for newer installer
2024-01-31 09:41:26 | v31.0 | [check_for_mist] mist is installed (/usr/local/bin/mist)
2024-01-31 09:41:26 | v31.0 | [check_newer_available] Restricting to selected OS '14'
┌──────────────────┐
│ INPUT VALIDATION │
└──────────────────┘
  ├─ List search string will be 'Sonoma'...
  ├─ 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

[0;0m┌────────────┬──────────────┬─────────┬───────┬──────────┬────────────┬────────────┐
│ IDENTIFIER │ NAME         │ VERSION │ BUILD │ SIZE     │ DATE       │ COMPATIBLE │
├────────────┼──────────────┼─────────┼───────┼──────────┼────────────┼────────────┤
[0;0m[0;0m│ [0;0m042-78233 [0;0m │ [0;0mmacOS Sonoma[0;0m │ [0;0m14.3   [0;0m │ [0;0m23D56[0;0m │ [0;0m13.40 GB[0;0m │ [0;0m2024-01-22[0;0m │ [0;0mTrue      [0;0m │
[0;0m[0;0m└────────────┴──────────────┴─────────┴───────┴──────────┴────────────┴────────────┘
[0;0m
Comparing latest build found (23D56) with cached installer build (21G816)
2024-01-31 09:41:30 | v31.0 | [compare_build_versions] Comparing (1) 23D56 with (2) 21G816
2024-01-31 09:41:30 | v31.0 | [compare_build_versions] 23D56 > 21G816
2024-01-31 09:41:30 | v31.0 | [erase-install] Newer installer found.
2024-01-31 09:41:30 | v31.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-01-31 09:41:30 | v31.0 | [erase-install] attempting to terminate the 'caffeinate' process - Termination message indicates success

2024-01-31 09:41:30 | v31.0 | [finish] sending quit message to dialog (/var/tmp/dialog.mfk)
2024-01-31 09:41:30 | v31.0 | [finish] Script exit code: 1

Environment (please complete the following information):

grahampugh commented 7 months ago

Hopefully this fixes your issue: https://github.com/grahampugh/erase-install/releases/tag/v33.0

rknauer7 commented 7 months ago

I'll give it a shot tomorrow and report back, thanks!

rknauer7 commented 7 months ago

Worked like a charm. Thanks, Graham, amazing work as always!