Closed sphen13 closed 2 years ago
Can you explain the commands you used that were causing the installer to be downloaded repeatedly?
morning.
here is some quick output illustrating the issue. For clarity in my case most machines already have the installer in their applications folder. I think if it was cached in the sparsebundle it may work correctly - which is probably how most use this script.
/Library/Management/erase-install/erase-install.sh --reinstall --build 21F79 --current-user --depnotify --no-fs --check-power --power-wait-limit 180 --cleanup-after-use --test-run
[erase-install] v26.1 script execution started: Thu Jul 21 05:03:29 PDT 2022
[erase-install] Caffeinating this script (pid=7661)
*** TEST-RUN ONLY! ***
* This script will perform all tasks up to the point of erase or reinstall,
* but will not actually erase or reinstall.
* Remove the --test-run argument to perform the erase or reinstall.
**********************
[check_free_space] OK - 61 GB free/purgeable disk space detected
[check_power_status] OK - AC power detected
[erase-install] Looking for existing installer app or pkg
[find_existing_installer] Installer found at /Applications/Install macOS Monterey.app.
[check_installer_is_valid] Checking validity of /Applications/Install macOS Monterey.app.
[check_installer_is_valid] Mounting /Applications/Install macOS Monterey.app/Contents/SharedSupport/SharedSupport.dmg
[check_installer_is_valid] Using Build value from com_apple_MobileAsset_MacSoftwareUpdate.xml
Volume Shared Support on disk2s2 force-unmounted
[compare_build_versions] Comparing (1) 21D62 with (2) 21F79
[check_installer_is_valid] Installer: 21F79 >= System: 21D62 : valid build.
DEBUG: prechosen_build = 21F79; builds_match = no
[erase-install] Existing installer does not match requested build, so replacing...
[overwrite_existing_installer] Overwrite option selected. Deleting existing version.
DEBUG: exiting before overwrite
you can see that the only time compare_build_versions
is called is to compare the system build and the installer build. the installer build is valid and does match what we are requesting but the script as it is wants to overwrite. adding the code in this PR allows the script to run compare_build_versions
with the requested build and installer build.
I wonder if you had already checked out branch v26.2-rc? I made what I think is the same change already. I just pushed it as a tag so you can compare: https://github.com/grahampugh/erase-install/releases/tag/v26.2
aha! at first glance - yes you have put in this fix in 26.2-rc :)
this needs some checking and extra help - but i was finding in my environment, erase-install was downloading the installer over and over again even if the installer present was valid and matched what i wanted. I tracked things down and it seems the
compare_build_versions
function is only called to compare the system version to the installer. I threw in a test to see if we are specifying a build version and called the function again to compare the found installer to what we are choosing.i think this is valid and will work correctly and it does in my test. more logic would have to be put in for version check of a found installer as well.