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

Script grabbing macOS 12 when run on macOS 13 M1 device #331

Closed Rorzzer closed 1 year ago

Rorzzer commented 1 year ago

Hi Graham,

I'm having trouble getting the script to cache Ventura when run from an M1 device currently running 13.0.

Using the following command the script is grabbing Monterey instead of Ventura? Library/Management/erase-install/erase-install.sh --os=13 --update --move --current-user --fetch-full-installer --cleanup-after-use

Logs below, appreciate the help.

`

Executing Policy Cache macOS Ventura 13 M1 debugging

Downloading erase-install-depnotify-27.1.pkg... Downloading https://apse2-jcds.services.jamfcloud.com//download/fbef3a7a309849f885e3bb31e41434c1/erase-install-depnotify-27.1.pkg?token=0a6694c94f654b89bb1b79cb84fe380462q45ycdcrb72dvc3kc8vwxx40j97dwn... Verifying package integrity... Installing erase-install-depnotify-27.1.pkg... Successfully installed erase-install-depnotify-27.1.pkg. Running command /Library/Management/erase-install/erase-install.sh --os=13 --update --move --current-user --fetch-full-installer --cleanup-after-use... Result of command:[erase-install] v27.1 script execution started: Wed 11 Jan 2023 10:41:57 AEDT [erase-install] Caffeinating this script (pid=14135) [erase-install] Looking for existing installer app or pkg [find_existing_installer] No valid installer found. [erase-install] Existing installer does not match requested OS, so replacing... [overwrite_existing_installer] Overwrite option selected. Deleting existing version. [erase-install] Running on architecture arm64 [erase-install] OS version is 13.0 so can run with --fetch-full-installer option [swu_fetch_full_installer] Could not obtain installer information using softwareupdate. Defaulting to no specific version, which should obtain the latest but is not as reliable. [swu_fetch_full_installer] Running /usr/sbin/softwareupdate --fetch-full-installer Scanning for installer Installing: 1.0% Installing: 2.0% ... Installing: 88.0% Installing: 89.0% Install finished successfully /Applications/Install macOS Monterey.app [erase-install] Closing jamfHelper download message (language=en) [erase-install] Cleaning working directory '/Library/Management/erase-install/content' [erase-install] attempting to terminate the 'caffeinate' process - Termination message indicates success /Library/Management/erase-install/erase-install.sh: line 1046: 14150 Terminated: 15 /usr/bin/caffeinate -dimsu -w $ [finish] Script exit code: 0

`

Rorzzer commented 1 year ago

Issue persists even when removing the --fetch-full-installer flag.

/Library/Management/erase-install/erase-install.sh --os=13 --update --move --current-user --cleanup-after-use

Screenshot 2023-01-17 at 12 32 55 pm
Rorzzer commented 1 year ago

Will update to 27.2 and try again...

Rorzzer commented 1 year ago

Same result, still grabbing the wrong OS

27.2 /Library/Management/erase-install/erase-install.sh --os=13 --update --move --current-user --cleanup-after-use

Screenshot 2023-01-17 at 12 40 54 pm
Rorzzer commented 1 year ago

Same result with --os=13.1

27.2 /Library/Management/erase-install/erase-install.sh --os=13.1 --update --move --current-user --cleanup-after-use

Screenshot 2023-01-17 at 12 53 15 pm
Rorzzer commented 1 year ago

Trying with --version=13.1 different result but still not downloading the correct version.

27.2 /Library/Management/erase-install/erase-install.sh --version=13.1 --update --move --current-user --cleanup-after-use

Screenshot 2023-01-17 at 12 56 59 pm
Rorzzer commented 1 year ago

Spoke to soon on this one... /Library/Management/erase-install/erase-install.sh --version=13.1 --update --move --current-user --cleanup-after-use

using the --version=13.1 flag it seems to have downloaded the correct installer. Will try with --fetch-full-installer now as well

`Executing Policy Cache macOS Ventura 13 M1 debugging Downloading erase-install-depnotify-27.2.pkg... Downloading https://apse2-jcds.services.jamfcloud.com//download/fbef3a7a309849f885e3bb31e41434c1/erase-install-depnotify-27.2.pkg?token=937af75768464387acca23ba147973a046yh8li4s74jvcoz7clgy4qlad4c0pwk... Verifying package integrity... Installing erase-install-depnotify-27.2.pkg... Successfully installed erase-install-depnotify-27.2.pkg. Running command /Library/Management/erase-install/erase-install.sh --version=13.1 --update --move --current-user --cleanup-after-use... Result of command: [erase-install] v27.2 script execution started: Tue 17 Jan 2023 12:56:18 AEDT [erase-install] Caffeinating this script (pid=4421) [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 disk4s2 force-unmounted [compare_build_versions] Comparing (1) 22A380 with (2) 21G320 [compare_build_versions] 22A380 > 21G320 [check_installer_is_valid] Installer: 21G320 < System: 22A380 : invalid build. [overwrite_existing_installer] Deleting existing cached installer(s). [erase-install] Running on architecture arm64 [check_installinstallmacos] installinstallmacos.py is in /Library/Management/erase-install [check_python] Relocatable Python is installed in /Library/Management/erase-install [run_installinstallmacos] Checking that selected version 13.1 is available

[run_installinstallmacos] This command is now being run:

installinstallmacos.py --workdir /Library/Management/erase-install --ignore-cache --raw --version 13.1 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 11.3G 100 11.3G 0 0 5958k 0 0:33:22 0:33:22 --:--:-- 5633k % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5041 100 5041 0 0 57345 0 --:--:-- --:--:-- --:--:-- 63012 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3379k 100 3379k 0 0 5329k 0 --:--:-- --:--:-- --:--:-- 5424k % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 181 100 181 0 0 1794 0 --:--:-- --:--:-- --:--:-- 1989 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1303k 100 1303k 0 0 4382k 0 --:--:-- --:--:-- --:--:-- 4510k % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3276k 100 3276k 0 0 4479k 0 --:--:-- --:--:-- --:--:-- 4519k installer: Package name is macOS Ventura installer: Installing at base path /private/tmp/dmg.sZezC0 installer: The install was successful.

installinstallmacos.py - get macOS installers from the Apple software catalog

This Mac: Model Identifier : MacBookPro18,1

Device ID : J316sAP OS Version : 13.0 Build ID : 22A380

ProductID Version Build Post Date Title

1 061-26578 10.14.5 18F2059 2019-10-14 macOS Mojave
2 061-26589 10.14.6 18G103 2019-10-14 macOS Mojave
3 041-91758 10.13.6 17G66 2019-10-19 macOS High Sierra
4 041-88800 10.14.4 18E2034 2019-10-23 macOS Mojave
5 041-90855 10.13.5 17F66a 2019-10-23 Install macOS High Sierra Beta 6 061-86291 10.15.3 19D2064 2020-03-23 macOS Catalina
7 001-04366 10.15.4 19E2269 2020-05-04 macOS Catalina
8 001-15219 10.15.5 19F2200 2020-06-15 macOS Catalina
9 001-36735 10.15.6 19G2006 2020-08-06 macOS Catalina
10 001-36801 10.15.6 19G2021 2020-08-12 macOS Catalina
11 001-51042 10.15.7 19H2 2020-09-24 macOS Catalina
12 001-57224 10.15.7 19H4 2020-10-27 macOS Catalina
13 001-68446 10.15.7 19H15 2020-11-11 macOS Catalina
14 071-78704 11.5.2 20G95 2021-08-18 macOS Big Sur
15 002-23589 11.6.1 20G224 2021-12-01 macOS Big Sur
16 002-42341 11.6.2 20G314 2022-01-14 macOS Big Sur
17 002-57023 11.6.3 20G415 2022-01-26 macOS Big Sur
18 002-65695 11.6.4 20G417 2022-02-17 macOS Big Sur
19 002-77154 11.6.5 20G527 2022-04-11 macOS Big Sur
20 012-08272 11.6.6 20G624 2022-05-24 macOS Big Sur
21 012-40494 12.6 21G115 2022-09-20 macOS Monterey
22 012-38280 11.7 20G817 2022-09-20 macOS Big Sur
23 012-92138 13.0 22A380 2022-10-24 macOS Ventura
24 012-90254 12.6.1 21G217 2022-10-24 macOS Monterey
25 012-90253 11.7.1 20G918 2022-10-24 macOS Big Sur
26 012-93766 13.0.1 22A400 2022-11-09 macOS Ventura
27 012-60271 13.1 22C65 2023-01-11 macOS Ventura
28 032-12843 12.6.2 21G320 2023-01-11 macOS Monterey
29 032-12833 11.7.2 20G1020 2023-01-11 macOS Big Sur

Build 22C65 selected. Downloading #27...

Making empty sparseimage...


Working around a very dumb Apple bug in a package postinstall script that fails to correctly target the Install macOS.app when installed to a volume other than the current boot volume. Please file feedback with Apple!


Product downloaded and installed to /Library/Management/erase-install/Install_macOS_13.1-22C65.sparseimage [run_installinstallmacos] Mounting sparse disk image to identify installer app. [erase-install] Installer is at: /Volumes/Install_macOS_13.1-22C65/Applications/Install macOS Ventura.app [erase-install] Invoking --move option [move_to_applications_folder] Moving installer to /Applications folder [move_to_applications_folder] Mounted installer will be unmounted: /Volumes/Install_macOS_13.1-22C65/Applications/Install macOS Ventura.app Volume Install_macOS_13.1-22C65 on disk5s2 force-unmounted [move_to_applications_folder] Installer moved to /Applications folder [erase-install] Closing jamfHelper download message (language=en)

[erase-install] Cleaning working directory '/Library/Management/erase-install/content'

[erase-install] attempting to terminate the 'caffeinate' process - Termination message indicates success /Library/Management/erase-install/erase-install.sh: line 1046: 4436 Terminated: 15 /usr/bin/caffeinate -dimsu -w $$

[finish] Script exit code: 0 `

Rorzzer commented 1 year ago

No luck with the --fetch-full-installer flag, the script ran with no error but did not download anything...

27.2 /Library/Management/erase-install/erase-install.sh --version=13.1 --update --move --fetch-full-installer --current-user --cleanup-after-use

Screenshot 2023-01-17 at 2 47 31 pm
grahampugh commented 1 year ago

If you read the log you will see that it was unable to get details of a specific installer from softwareupdate. In that case, when using the --fetch-full-installer option, it has to rely on what Apple decides is the current version. This is not very reliable.

I would recommend that you remove the --fetch-full-installer parameter if it's not proving reliable in your environment. Try the --pkg option instead.

EDIT: your last post indicated that the 13.1 installer was successfully downloaded.

Rorzzer commented 1 year ago

If you read the log you will see that it was unable to get details of a specific installer from softwareupdate. In that case, when using the --fetch-full-installer option, it has to rely on what Apple decides is the current version. This is not very reliable.

I would recommend that you remove the --fetch-full-installer parameter if it's not proving reliable in your environment. Try the --pkg option instead.

EDIT: your last post indicated that the 13.1 installer was successfully downloaded.

Thanks Graham, is there any reason why the --os=13 flag does not work for me? I have tried it with and without the --fetch-full-installer flag and it grabs the wrong OS regardless.

/Library/Management/erase-install/erase-install.sh --os=13 --update --move --current-user --cleanup-after-use Grabbed Big Sur

Library/Management/erase-install/erase-install.sh --os=13 --update --move --current-user --fetch-full-installer --cleanup-after-use Grabbed Monterey

dvasquezavant commented 1 year ago

I find using the build option works well for us. --build=22C65 Screenshot 2023-01-17 at 6 23 42 PM

Maybe that will help.

grahampugh commented 1 year ago

@Rorzzer what macOS version is running on the system are you running this on? Something really old? Try running erase-install.sh --list and see what installers are available to you.

PS don't use --cleanup-after-use when caching. That flag is specifically for use with --reinstall to remove the erase-install folder and cached installer after an upgrade.

Rorzzer commented 1 year ago

Hey @grahampugh all of the above test were from a 2021 M1 Pro MBP running macOS 13.0. Noted the tip on --cleanup-after-use cheers!

Results of erase-install.sh --list below,

`% sudo ./erase-install.sh --list

[erase-install] v27.2 script execution started: Thu 19 Jan 2023 11:14:42 AEDT [erase-install] Caffeinating this script (pid=62826) [erase-install] Looking for existing installer app or pkg [find_existing_installer] Installer found at /Applications/Install macOS Ventura.app. [check_installer_is_valid] Checking validity of /Applications/Install macOS Ventura.app. [check_installer_is_valid] Mounting SharedSupport.dmg failed [check_installer_is_valid] Build of existing installer could not be found, so it is assumed to be invalid. [erase-install] ERROR: Invalid installer is present. --skip-validation was set so we will continue, but failure is highly likely! [erase-install] Running on architecture arm64 [check_installinstallmacos] installinstallmacos.py is in /Library/Management/erase-install [check_python] Relocatable Python is installed in /Library/Management/erase-install [run_installinstallmacos] List only mode chosen

[run_installinstallmacos] This command is now being run:

installinstallmacos.py --workdir /Library/Management/erase-install --list --warnings --raw

installinstallmacos.py - get macOS installers from the Apple software catalog

This Mac: Model Identifier : MacBookPro18,1

Device ID : J316sAP OS Version : 13.0 Build ID : 22A380

ProductID Version Build Post Date Title Notes/Warnings

1 061-26578 10.14.5 18F2059 2019-10-14 macOS Mojave Unsupported macOS version 2 061-26589 10.14.6 18G103 2019-10-14 macOS Mojave Unsupported macOS version 3 041-91758 10.13.6 17G66 2019-10-19 macOS High Sierra Unsupported macOS version 4 041-88800 10.14.4 18E2034 2019-10-23 macOS Mojave Unsupported macOS version 5 041-90855 10.13.5 17F66a 2019-10-23 Install macOS High Sierra Beta Unsupported macOS version 6 061-86291 10.15.3 19D2064 2020-03-23 macOS Catalina Unsupported macOS version 7 001-04366 10.15.4 19E2269 2020-05-04 macOS Catalina Unsupported macOS version 8 001-15219 10.15.5 19F2200 2020-06-15 macOS Catalina Unsupported macOS version 9 001-36735 10.15.6 19G2006 2020-08-06 macOS Catalina Unsupported macOS version 10 001-36801 10.15.6 19G2021 2020-08-12 macOS Catalina Unsupported macOS version 11 001-51042 10.15.7 19H2 2020-09-24 macOS Catalina Unsupported macOS version 12 001-57224 10.15.7 19H4 2020-10-27 macOS Catalina Unsupported macOS version 13 001-68446 10.15.7 19H15 2020-11-11 macOS Catalina Unsupported macOS version 14 071-78704 11.5.2 20G95 2021-08-18 macOS Big Sur Unsupported macOS version 15 002-23589 11.6.1 20G224 2021-12-01 macOS Big Sur Unsupported macOS version 16 002-42341 11.6.2 20G314 2022-01-14 macOS Big Sur Unsupported macOS version 17 002-57023 11.6.3 20G415 2022-01-26 macOS Big Sur Unsupported macOS version 18 002-65695 11.6.4 20G417 2022-02-17 macOS Big Sur Unsupported macOS version 19 002-77154 11.6.5 20G527 2022-04-11 macOS Big Sur Unsupported macOS version 20 012-08272 11.6.6 20G624 2022-05-24 macOS Big Sur Unsupported macOS version 21 012-40494 12.6 21G115 2022-09-20 macOS Monterey Unsupported macOS version 22 012-38280 11.7 20G817 2022-09-20 macOS Big Sur Unsupported macOS version 23 012-92138 13.0 22A380 2022-10-24 macOS Ventura
24 012-90254 12.6.1 21G217 2022-10-24 macOS Monterey Unsupported macOS version 25 012-90253 11.7.1 20G918 2022-10-24 macOS Big Sur Unsupported macOS version 26 012-93766 13.0.1 22A400 2022-11-09 macOS Ventura
27 012-60271 13.1 22C65 2023-01-11 macOS Ventura
28 032-12843 12.6.2 21G320 2023-01-11 macOS Monterey Unsupported macOS version 29 032-12833 11.7.2 20G1020 2023-01-11 macOS Big Sur Unsupported macOS version

Valid seeding programs are: CustomerSeed, DeveloperSeed, PublicSeed

[erase-install] attempting to terminate the 'caffeinate' process - Termination message indicates success ./erase-install.sh: line 1046: 62838 Terminated: 15 /usr/bin/caffeinate -dimsu -w $$

[finish] Script exit code: 0`

grahampugh commented 1 year ago

@Rorzzer you appear to have something preventing DMGs from mounting:

[check_installer_is_valid] Mounting SharedSupport.dmg failed

Maybe you have some software that blocks mounting disk images.

grahampugh commented 1 year ago

Close due to lack of response from original requester.