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] When --ffi argument is used, script terminates after not being able to find installer information - macOS 14.3 #479

Closed carlashley closed 6 months ago

carlashley commented 7 months ago

Describe the bug When using the --ffi/--fetch-full-installer argument, erase-install exits with this error message:

2024-01-30 07:08:20 | v32.0 | [run_fetch_full_installer] Could not obtain installer information using softwareupdate --list-full-installers. Cannot continue.

Running softwareupdate --list-full-installers immediately after results in:

Finding available software
Software Update found the following full installers:
* Title: macOS Sonoma, Version: 14.3, Size: 13073941KiB, Build: 23D56, Deferred: NO
* Title: macOS Sonoma, Version: 14.2.1, Size: 13066225KiB, Build: 23C71, Deferred: NO
* Title: macOS Sonoma, Version: 14.2, Size: 13066238KiB, Build: 23C64, Deferred: NO
* Title: macOS Sonoma, Version: 14.1.2, Size: 12604083KiB, Build: 23B92, Deferred: NO
* Title: macOS Sonoma, Version: 14.1.1, Size: 12604952KiB, Build: 23B81, Deferred: NO
* Title: macOS Sonoma, Version: 14.1, Size: 12603757KiB, Build: 23B74, Deferred: NO
* Title: macOS Ventura, Version: 13.6.4, Size: 11912664KiB, Build: 22G513, Deferred: NO
* Title: macOS Ventura, Version: 13.6.3, Size: 11915962KiB, Build: 22G436, Deferred: NO
* Title: macOS Ventura, Version: 13.6.1, Size: 11662168KiB, Build: 22G313, Deferred: NO
* Title: macOS Monterey, Version: 12.7.3, Size: 12109975KiB, Build: 21H1015, Deferred: NO
* Title: macOS Monterey, Version: 12.7.2, Size: 12116623KiB, Build: 21G1974, Deferred: NO
* Title: macOS Monterey, Version: 12.7.1, Size: 12110635KiB, Build: 21G920, Deferred: NO
* Title: macOS Big Sur, Version: 11.7.10, Size: 12125478KiB, Build: 20G1427, Deferred: NO

To Reproduce This has been tested on macOS 14.3 (23D56) with erase-install v32.0. This occurs in GUI login + Terminal.app, as well as when executed via ssh (with someone in a GUI login).

Expected behavior erase-install parsing the results of softwareupdate --list-full-installers and matching version data.

Code/log output Log file after running: /Library/Management/erase-install/erase-install.sh --version 14.3 --ffi --caching-server http://10.0.0.63:50690 --pkg

2024-01-30 07:22:56 | v32.0 | [log_rotate] Finished rotating logs in /Library/Management/erase-install/log

2024-01-30 07:22:56 | v32.0 | [erase-install] v32.0 script execution started: Tue 30 Jan 2024 07:22:56 AEST

2024-01-30 07:22:56 | v32.0 | [erase-install] Arguments provided: --version 14.3 --ffi --caching-server http://redacted.org:port --pkg
2024-01-30 07:22:56 | v32.0 | [erase-install] System version: 14.3 (Build: 23D56)
2024-01-30 07:22:57 | v32.0 | [check_for_swiftdialog_app] swiftDialog v2.2.1.4591 is installed (/Library/Application Support/Dialog/Dialog.app)
2024-01-30 07:22:57 | v32.0 | [check_for_swiftdialog_app] Creating dialog log (/var/tmp/dialog.ifk)...
2024-01-30 07:22:57 | v32.0 | [erase-install] Caffeinating this script (pid=9676)
2024-01-30 07:22:57 | v32.0 | [erase-install] Looking for existing installer app or pkg
2024-01-30 07:22:57 | v32.0 | [find_existing_installer] No valid installer found.
2024-01-30 07:22:57 | v32.0 | [erase-install] Running on architecture arm64
2024-01-30 07:22:57 | v32.0 | [run_fetch_full_installer] Could not obtain installer information using softwareupdate --list-full-installers. Cannot continue.

2024-01-30 07:22:57 | v32.0 | [erase-install] attempting to terminate the 'caffeinate' process - Termination message indicates success

2024-01-30 07:22:57 | v32.0 | [finish] sending quit message to dialog (/var/tmp/dialog.ifk)
2024-01-30 07:22:58 | v32.0 | [finish] Script exit code: 1
/Library/Management/erase-install/log/erase-install.log (END)

Screenshots Screen_Shot_2024-01-30-071406-460660

Environment (please complete the following information):

carlashley commented 7 months ago

Some info after modifying erase-install.sh with set -x, I've removed a large chunk of the output and copied it from after the point the script picks up that this is run on arm64.

2024-01-30 07:37:22 | v32.0 | [erase-install] Running on architecture arm64
+./erase-install.sh:3175> [[ arm64 == arm64 && no == yes || no == yes ]]
+./erase-install.sh:3180> [[ '' == yes ]]
+./erase-install.sh:3183> [[ '' == yes ]]
+./erase-install.sh:3185> [[ ! -d '' && ! -f '' ]]
+./erase-install.sh:3186> [[ ! -n '' ]]
+./erase-install.sh:3188> [[ no == yes || no == yes || '' == yes ]]
+./erase-install.sh:3218> [[ -n yes ]]
+./erase-install.sh:3225> [[ -n yes ]]
+./erase-install.sh:3226> run_fetch_full_installer
+run_fetch_full_installer:1> softwareupdate_args=( ) 
+run_fetch_full_installer:2> run_list_full_installers
+run_list_full_installers:1> [[ 14 -lt 13 || 14 -eq 13 ]]
+run_list_full_installers:25> [[ '' == yes ]]
+run_fetch_full_installer:3> [[ -f /Library/Management/erase-install/ffi-list-full-installers.txt ]]
+./erase-install.sh:3219> dialog_progress fetch-full-installer
+run_fetch_full_installer:59> writelog '[run_fetch_full_installer] Could not obtain installer information using softwareupdate --list-full-installers. Cannot continue.'
+writelog:1> DATE=+writelog:1> date '+%Y-%m-%d %H:%M:%S'
+writelog:1> DATE='2024-01-30 07:37:22' 
+writelog:2> echo '2024-01-30 07:37:22 | v32.0 | [run_fetch_full_installer] Could not obtain installer information using softwareupdate --list-full-installers. Cannot continue.'
2024-01-30 07:37:22 | v32.0 | [run_fetch_full_installer] Could not obtain installer information using softwareupdate --list-full-installers. Cannot continue.
+run_fetch_full_installer:60> echo

+run_fetch_full_installer:61> exit 1
+./erase-install.sh:3226> finish
+finish:1> local exit_code=1
+finish:3> [[ -n '' ]]
+finish:9> [[ -e '' ]]
+finish:10> [[ -e '' ]]
+finish:13> kill_process caffeinate
+kill_process:1> process=caffeinate 
+kill_process:2> echo

+kill_process:3> process_pid=+kill_process:3> /usr/bin/pgrep -a caffeinate
+kill_process:3> process_pid=19591 
+kill_process:4> writelog '[erase-install] attempting to terminate the '\''caffeinate'\'' process - Termination message indicates success'
+writelog:1> DATE=+writelog:1> date '+%Y-%m-%d %H:%M:%S'
+writelog:1> DATE='2024-01-30 07:37:22' 
+writelog:2> echo '2024-01-30 07:37:22 | v32.0 | [erase-install] attempting to terminate the '\''caffeinate'\'' process - Termination message indicates success'
2024-01-30 07:37:22 | v32.0 | [erase-install] attempting to terminate the 'caffeinate' process - Termination message indicates success
+kill_process:5> kill 19591
+kill_process:6> /usr/bin/pgrep -a caffeinate
+kill_process:9> echo

+finish:16> [[ '' == yes || 1 -gt 0 ]]
+finish:17> writelog '[finish] sending quit message to dialog (/var/tmp/dialog.qrt)'
+writelog:1> DATE=+writelog:1> date '+%Y-%m-%d %H:%M:%S'
+writelog:1> DATE='2024-01-30 07:37:22' 
+writelog:2> echo '2024-01-30 07:37:22 | v32.0 | [finish] sending quit message to dialog (/var/tmp/dialog.qrt)'
2024-01-30 07:37:22 | v32.0 | [finish] sending quit message to dialog (/var/tmp/dialog.qrt)
+finish:18> /bin/echo quit:
+finish:20> sleep 0.5
+finish:25> writelog '[finish] Script exit code: 1'
+writelog:1> DATE=+writelog:1> date '+%Y-%m-%d %H:%M:%S'
+writelog:1> DATE='2024-01-30 07:37:23' 
+writelog:2> echo '2024-01-30 07:37:23 | v32.0 | [finish] Script exit code: 1'
2024-01-30 07:37:23 | v32.0 | [finish] Script exit code: 1
+finish:26> exit 1
grahampugh commented 7 months ago

I can reproduce the bug, but just to let you know, the --caching-server option is not applicable to the --fetch-full-installer workflows. It's only used in conjunction with mist-cli. But I do believe that --ffi will automatically use a caching server without specifying anything.

You also can't use --pkg with --fetch-full-installer, because you can't get a pkg from softwareupdate.

grahampugh commented 6 months ago

Should be fixed in https://github.com/grahampugh/erase-install/releases/tag/v33.0