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
845 stars 132 forks source link

--update will not use a cached installer with --os option #287

Closed dnikles closed 2 years ago

dnikles commented 2 years ago

Describe the bug When the --os option is used, and a valid installer is already on the system, it will not be used and instead a new installer is downloaded. This happens because the build of the current system is compared to the build of the cached installer, instead of comparing the build of the latest available installer to the build of the cached installer.

To Reproduce On a computer that is not yet on OS12, run sudo /Library/Management/erase-install/erase-install.sh --os=12 --update and it will download a new installer. Run it again and a new installer will be downloaded, instead of using the one that was just cached.

Expected behavior A new installer should not be downloaded if the cached installer is valid.

Code/log output

 [find_existing_installer] Installer sparse image found at /Library/Management/erase-install/Install_macOS_12.6-21G115.sparseimage.
   [check_installer_is_valid] Checking validity of /Volumes/Install_macOS_12.6-21G115/Applications/Install macOS Monterey.app.
   [check_installer_is_valid] Mounting /Volumes/Install_macOS_12.6-21G115/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 disk8s2 force-unmounted
   [compare_build_versions] Comparing (1) 18G103 with (2) 21G115
   [check_installer_is_valid] Installer: 21G115 >= System: 18G103 : valid build.
   [erase-install] Existing installer does not match requested version, so replacing...

Screenshots

Environment (please complete the following information):

Additional context This bug does not exist when --build is used. It looks like with --os, it cannot pass this line successfully elif [[ "$prechosen_os" != "" && "$os_matches" != "yes" ]]

grahampugh commented 2 years ago

I believe this may have been addressed in my latest commit. Please try the latest pre-release package for v27.0 or the latest script in the v27.0 branch.

dnikles commented 2 years ago

Fixed in my testing of latest v27