ninxsoft / mist-cli

A Mac command-line tool that automatically downloads macOS Firmwares / Installers.
MIT License
615 stars 29 forks source link

Building ISOs for macOS 10.15 Catalina and older fails on Apple Silicon (M1) #62

Closed argumemnon closed 2 years ago

argumemnon commented 2 years ago

When issuing the command sudo mist download "10.13.6" --iso, I receive the error

Invalid Exit Status Code: '9', Message: Error: invalidExitStatus(code: 9, message: "")

when creating the bootable disk image.

Output:

SEARCH │
└────────┘
  ├─ Searching for macOS download '10.13.6'...
  ├─ Found [041-91758] macOS High Sierra 10.13.6 (17G66) [2019-10-19]
┌───────┐
│ SETUP │
└───────┘
  ├─ Deleting old temporary directory '/private/tmp/041-91758'...
  ├─ Creating new temporary directory '/private/tmp/041-91758'...
┌──────────┐
│ DOWNLOAD │
└──────────┘
  ├─ [ 01 / 12 ] 041-91758.English.dist........ [ 08.81 KB / 08.81 KB (100.0%) ]
  ├─ [ 02 / 12 ] AppleDiagnostics.chunklist...... [ 00.00 B / 00.00 B (100.0%) ]
  ├─ [ 03 / 12 ] AppleDiagnostics.dmg.......... [ 02.87 MB / 02.87 MB (100.0%) ]
  ├─ [ 04 / 12 ] BaseSystem.chunklist.......... [ 01.98 KB / 01.98 KB (100.0%) ]
  ├─ [ 05 / 12 ] BaseSystem.dmg.............. [ 486.28 MB / 486.28 MB (100.0%) ]
  ├─ [ 06 / 12 ] InstallAssistantAuto.pkg...... [ 11.83 MB / 11.83 MB (100.0%) ]
  ├─ [ 07 / 12 ] InstallESDDmg.chunklist....... [ 16.53 KB / 16.53 KB (100.0%) ]
  ├─ [ 08 / 12 ] InstallESDDmg.pkg............. [ 04.72 GB / 04.72 GB (100.0%) ]
  ├─ [ 09 / 12 ] InstallInfo.plist............. [ 01.58 KB / 01.58 KB (100.0%) ]
  ├─ [ 10 / 12 ] MajorOSInfo.pkg............... [ 02.52 MB / 02.52 MB (100.0%) ]
  ├─ [ 11 / 12 ] OSInstall.mpkg.............. [ 684.04 KB / 684.04 KB (100.0%) ]
  ├─ [ 12 / 12 ] RecoveryHDMetaDmg.pkg....... [ 487.84 MB / 487.84 MB (100.0%) ]
┌─────────┐
│ INSTALL │
└─────────┘
  ├─ Deleting old installer '/Applications/Install macOS High Sierra.app'...
  ├─ Creating new installer '/Applications/Install macOS High Sierra.app'...
  ├─ Deleting temporary directory '/private/tmp/041-91758'...
  ├─ Created new installer '/Applications/Install macOS High Sierra.app'
┌─────────────────────┐
│ BOOTABLE DISK IMAGE │
└─────────────────────┘
  ├─ Creating new temporary directory '/private/tmp/041-91758'...
  ├─ Creating disk image '/private/tmp/041-91758/041-91758.dmg'...
  ├─ Mounting disk image at mount point '/Volumes/Install macOS High Sierra'...
  ├─ Creating install media at mount point '/Volumes/Install macOS High Sierra'...
  └─ Invalid Exit Status Code: '9', Message: 
Error: invalidExitStatus(code: 9, message: "")
➜  ~ 

diskutil list reports:

/dev/disk5 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        +7.5 GB     disk5
   1:        Apple_partition_map ⁨⁩                        32.3 KB    disk5s1
   2:                  Apple_HFS ⁨untitled⁩                7.5 GB     disk5s2

So it looks like it's trying, but fails somehow.

ninxsoft commented 2 years ago

Just ran through building a High Sierra ISO, output looks good:

➜ ~ sudo mist download "10.13.6" --iso --force
┌──────────────────┐
│ INPUT VALIDATION │
└──────────────────┘
  ├─ User is 'root'...
  ├─ Download search string will be '10.13.6'...
  ├─ Kind will be 'installer'...
  ├─ Include betas in search results will be 'false'...
  ├─ Output directory will be '/Users/Shared/Mist'...
  ├─ Temporary directory will be '/private/tmp'...
  ├─ Force flag set, existing files will be overwritten...
  ├─ Valid download type(s) specified...
  ├─ Bootable Disk Image name will be 'Install %NAME% %VERSION%-%BUILD%.iso'...
┌────────┐
│ SEARCH │
└────────┘
  ├─ Searching for macOS download '10.13.6'...
  ├─ Found [041-91758] macOS High Sierra 10.13.6 (17G66) [2019-10-20]
┌───────┐
│ SETUP │
└───────┘
  ├─ Creating new temporary directory '/private/tmp/041-91758'...
┌──────────┐
│ DOWNLOAD │
└──────────┘
  ├─ [ 01 / 12 ] 041-91758.English.dist........ [ 08.81 KB / 08.81 KB (100.0%) ]
  ├─ [ 02 / 12 ] AppleDiagnostics.chunklist...... [ 00.00 B / 00.00 B (100.0%) ]
  ├─ [ 03 / 12 ] AppleDiagnostics.dmg.......... [ 02.87 MB / 02.87 MB (100.0%) ]
  ├─ [ 04 / 12 ] BaseSystem.chunklist.......... [ 01.98 KB / 01.98 KB (100.0%) ]
  ├─ [ 05 / 12 ] BaseSystem.dmg.............. [ 486.28 MB / 486.28 MB (100.0%) ]
  ├─ [ 06 / 12 ] InstallAssistantAuto.pkg...... [ 11.83 MB / 11.83 MB (100.0%) ]
  ├─ [ 07 / 12 ] InstallESDDmg.chunklist....... [ 16.53 KB / 16.53 KB (100.0%) ]
  ├─ [ 08 / 12 ] InstallESDDmg.pkg............. [ 04.72 GB / 04.72 GB (100.0%) ]
  ├─ [ 09 / 12 ] InstallInfo.plist............. [ 01.58 KB / 01.58 KB (100.0%) ]
  ├─ [ 10 / 12 ] MajorOSInfo.pkg............... [ 02.52 MB / 02.52 MB (100.0%) ]
  ├─ [ 11 / 12 ] OSInstall.mpkg.............. [ 684.04 KB / 684.04 KB (100.0%) ]
  ├─ [ 12 / 12 ] RecoveryHDMetaDmg.pkg....... [ 487.84 MB / 487.84 MB (100.0%) ]
┌─────────┐
│ INSTALL │
└─────────┘
  ├─ Creating new installer '/Applications/Install macOS High Sierra.app'...
  ├─ Deleting temporary directory '/private/tmp/041-91758'...
  ├─ Created new installer '/Applications/Install macOS High Sierra.app'
┌─────────────────────┐
│ BOOTABLE DISK IMAGE │
└─────────────────────┘
  ├─ Creating new temporary directory '/private/tmp/041-91758'...
  ├─ Creating disk image '/private/tmp/041-91758/041-91758.dmg'...
  ├─ Mounting disk image at mount point '/Volumes/Install macOS High Sierra'...
  ├─ Creating install media at mount point '/Volumes/Install macOS High Sierra'...
  ├─ Unmounting disk image at mount point '/Volumes/Install macOS High Sierra'...
  ├─ Deleting old image '/Users/Shared/Mist/Install macOS High Sierra 10.13.6-17G66.iso'...
  ├─ Converting disk image '/private/tmp/041-91758/041-91758.cdr'...
  ├─ Moving '/private/tmp/041-91758/041-91758.cdr' to '/Users/Shared/Mist/Install macOS High Sierra 10.13.6-17G66.iso'...
  ├─ Deleting temporary directory '/private/tmp/041-91758'...
  ├─ Created bootable disk image '/Users/Shared/Mist/Install macOS High Sierra 10.13.6-17G66.iso'
┌──────────┐
│ TEARDOWN │
└──────────┘
  └─ Deleting installer '/Applications/Install macOS High Sierra.app'...

The last command to run in your output is /Applications/Install macOS High Sierra.app/Contents/Resources/createinstallmedia, which is exiting with error code 9. Error code 9 could be referring to a SIGKILL signal, which might explain why mist is terminating early.

ninxsoft commented 2 years ago

I am also getting the same results as you on my Apple Silicon (M1) Mac!

I suspect it is failing as the High Sierra createinstallmedia binary has not been rebuilt to run natively on Apple Silicon (M1) hardware.

Will dig deeper to see if there's a clever way around this 👍

argumemnon commented 2 years ago

Yes, sorry I should have included that information. I am attempting this on a MacBookPro18,3 with the M1 Pro chip.

ninxsoft commented 2 years ago

I have added the following message to the help output:

https://github.com/ninxsoft/Mist/blob/e7fc2895e411a1aa31bbc8ad6393467323542446/Mist/Commands/Download/DownloadInstallerOptions.swift#L35-L43

➜ mist download installer --help
OVERVIEW: Download a macOS Installer.
* macOS Installers for macOS Catalina 10.15 and older are for Intel based Macs only.
* macOS Installers for macOS Big Sur 11 and newer are Universal - for both Apple Silicon and Intel based Macs.

USAGE: mist download installer [<options>] <search-string> [<output-type> ...]

ARGUMENTS:
  <search-string>         Specify a macOS name, version or build to download:
                          * macOS Monterey
                          * macOS Big Sur
                          * macOS Catalina
                          * macOS Mojave
                          * macOS High Sierra
                          * 12.x (macOS Monterey)
                          * 11.x (macOS Big Sur)
                          * 10.15.x (macOS Catalina)
                          * 10.14.x (macOS Mojave)
                          * 10.13.x (macOS High Sierra)
                          * 21F (macOS Monterey 12.4.x)
                          * 20G (macOS Big Sur 11.6.x)
                          * 19H (macOS Catalina 10.15.7)
                          * 18G (macOS Mojave 10.14.6)
                          * 17G (macOS High Sierra 10.13.6)
                          Note: Specifying a macOS name will assume the latest version and build of that particular macOS.
                          Note: Specifying a macOS version will assume the latest build of that particular macOS.
  <output-type>           Specify the requested output type(s):
                          * application to generate a macOS Installer Application Bundle (.app).
                          * image to generate a macOS Disk Image (.dmg).
                          * iso to generate a Bootable macOS Disk Image (.iso), for use with virtualization software (ie. Parallels Desktop, VMware Fusion, VirtualBox).
                          Note: This option will fail when targeting macOS Catalina 10.15 and older on Apple Silicon (M1) Macs.
                          * package to generate a macOS Installer Package (.pkg).

OPTIONS:
[...]

Not perfect, but a step in the right direction. I can also look into doing some checks and balances once a valid installer has been found, but considering we are so close to WWDC I am leaning towards holding off and seeing how everything shakes out.

Will revisit post-WWDC if required 👍