ninxsoft / mist-cli

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

App Will Eat Itself #112

Closed grahampugh closed 1 year ago

grahampugh commented 2 years ago

It doesn't seem to be right that downloading an installer to /Applications should result in an error output from mist-cli, because it wants to delete itself. Is that really intended? It seems to be a side-effect of the behaviour of the script, where it first downloads to /Applications and then attempts to copy it to either the default destination (/Users/Shared/Mist), or to a custom output directory (in this case, /Applications). Worse still, if the --force flag is used under these settings, the downloaded app gets immediately deleted!

To me, it would make sense if the downloaded app was compiled directly in the output-directory, rather than being copied there after being compiled in /Applications.

% mist download installer 13.0 application --application-name Install %NAME%.app --output-directory /Applications --cache-downloads --include-betas
┌──────────────────┐
│ INPUT VALIDATION │
└──────────────────┘
  ├─ User is 'root'...
  ├─ Download search string will be '13.0'...
  ├─ Include betas in search results will be 'true'...
  ├─ Only include compatible installers will be 'false'...
  ├─ Cache downloads will be 'true'...
  ├─ Output directory will be '/Applications'...
  ├─ Temporary directory will be '/private/tmp/com.ninxsoft.mist'...
  ├─ Force flag has not been set, existing files will not be overwritten...
  ├─ Application name will be 'Install %NAME%.app'...
┌────────┐
│ SEARCH │
└────────┘
  ├─ Searching for macOS download '13.0'...
  ├─ Found [012-84573] macOS Ventura beta 13.0 (22A5373b) [2022-10-12]
┌───────┐
│ SETUP │
└───────┘
  ├─ Nothing to do!
┌──────────┐
│ DOWNLOAD │
└──────────┘
  ├─ [ 1 / 7 ] 012-84573.English.dist.......... [ 07.52 KB / 07.52 KB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 2 / 7 ] BuildManifest.plist............. [ 03.36 MB / 03.36 MB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 3 / 7 ] Info.plist...................... [ 05.30 KB / 05.30 KB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 4 / 7 ] InstallAssistant.pkg............ [ 12.12 GB / 12.12 GB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 5 / 7 ] InstallInfo.plist............... [  0181  B /  0181  B (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 6 / 7 ] MajorOSInfo.pkg................. [ 01.33 MB / 01.33 MB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 7 / 7 ] UpdateBrain.zip................. [ 03.45 MB / 03.45 MB (100.0%) ]
  │            Verifying... ✓✓✓
┌─────────┐
│ INSTALL │
└─────────┘
  ├─ Creating new installer '/Applications/Install macOS Ventura beta.app'...
  ├─ Created new installer '/Applications/Install macOS Ventura beta.app'
┌─────────────┐
│ APPLICATION │
└─────────────┘
  └─ Existing file: '/Applications/Install macOS Ventura beta.app'. Use [--force] to overwrite.
Error: existingFile(path: "/Applications/Install macOS Ventura beta.app")
ninxsoft commented 2 years ago

The logic I am currently using in Mist.app that I haven't gotten around to implementing in mist-cli is to generate a temporary disk image containing the .app installer.

I never liked the idea of installing the package on / and copying / deleting out of /Applications. Bringing across the disk image approach should remove any dependency on /Applications 👍

IIRC smart cookies like the maintainer of installinstallmacos.py follow similar logic 😛

grahampugh commented 1 year ago

On the other hand, downloading directly to /Applications or some other folder is faster than copying to (and from) a disk image, and also avoids problems that I encounter quite frequently with people who have software that restricts the mounting of disk images.

The only real problem here is that the installer is being downloaded to /Applications, but the --output flag is not smart enough to check that the destination is the same as the source, and so gets itself in a tizz. A simple check to see if the source and destination are the same should solve that.

tempusthales commented 1 year ago

@ninxsoft I actually came across this today and everything I have tried is moot. Verbatim what @grahampugh is documenting is happening. Any path way for a fix? Soon(tm)? :)

ninxsoft commented 1 year ago

Progress! 🥳

I have a working pull request (#112) which creates the Install macOS.app in a Disk Image (.dmg) and no longer in /Applications:

This all aligns with how Mist.app operates (and helps keep things correct in my head)

Will leave #112 open for a few days to continue testing + window for providing feedback.

Thanks! 🙌

ninxsoft commented 1 year ago

Sample output:

➜ mist ✔ sudo mist download installer "Ventura" application image iso package --cache-downloads --temporary-directory "/Users/Shared/Mist/Cache" --force
┌──────────────────┐
│ INPUT VALIDATION │
└──────────────────┘
  ├─ User is 'root'...
  ├─ Download search string will be 'Ventura'...
  ├─ Include betas in search results will be 'false'...
  ├─ Only include compatible installers will be 'false'...
  ├─ Cache downloads will be 'true'...
  ├─ Output directory will be '/Users/Shared/Mist'...
  ├─ Temporary directory will be '/Users/Shared/Mist/Cache'...
  ├─ Force flag set, existing files will be overwritten...
  ├─ Application name will be 'Install %NAME% %VERSION%-%BUILD%.app'...
  ├─ Disk Image name will be 'Install %NAME% %VERSION%-%BUILD%.dmg'...
  ├─ Bootable Disk Image name will be 'Install %NAME% %VERSION%-%BUILD%.iso'...
  ├─ Package name will be 'Install %NAME% %VERSION%-%BUILD%.pkg'...
  ├─ Package identifier will be 'com.company.pkg.%NAME%.%VERSION%.%BUILD%'...
┌────────┐
│ SEARCH │
└────────┘
  ├─ Searching for macOS download 'Ventura'...
  ├─ Found [012-60271] macOS Ventura 13.1 (22C65) [2022-12-14]
┌───────┐
│ SETUP │
└───────┘
  ├─ Nothing to do!
┌──────────┐
│ DOWNLOAD │
└──────────┘
  ├─ [ 1 / 7 ] 012-60271.English.dist.......... [ 07.46 KB / 07.46 KB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 2 / 7 ] BuildManifest.plist............. [ 03.36 MB / 03.36 MB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 3 / 7 ] Info.plist...................... [ 05.04 KB / 05.04 KB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 4 / 7 ] InstallAssistant.pkg............ [ 12.22 GB / 12.22 GB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 5 / 7 ] InstallInfo.plist............... [  0181  B /  0181  B (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 6 / 7 ] MajorOSInfo.pkg................. [ 01.33 MB / 01.33 MB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 7 / 7 ] UpdateBrain.zip................. [ 03.46 MB / 03.46 MB (100.0%) ]
  │            Verifying... ✓✓✓
┌─────────┐
│ INSTALL │
└─────────┘
  ├─ Creating image '/Users/Shared/Mist/Cache/012-60271/012-60271.dmg'...
  ├─ Mounting disk image at mount point '/Volumes/012-60271'...
  ├─ Creating new installer '/Volumes/012-60271//Applications/Install macOS Ventura.app'...
  ├─ Created new installer '/Volumes/012-60271//Applications/Install macOS Ventura.app'
┌─────────────┐
│ APPLICATION │
└─────────────┘
  ├─ Deleting old application '/Users/Shared/Mist/Install macOS Ventura 13.1-22C65.app'...
  ├─ Copying '/Volumes/012-60271//Applications/Install macOS Ventura.app' to '/Users/Shared/Mist/Install macOS Ventura 13.1-22C65.app'...
┌────────────┐
│ DISK IMAGE │
└────────────┘
  ├─ Creating new temporary directory '/Users/Shared/Mist/Cache/012-60271/image'...
  ├─ Copying '/Volumes/012-60271//Applications/Install macOS Ventura.app' to '/Users/Shared/Mist/Cache/012-60271/image/Install macOS Ventura.app'...
  ├─ Deleting old image '/Users/Shared/Mist/Install macOS Ventura 13.1-22C65.dmg'...
  ├─ Creating image '/Users/Shared/Mist/Install macOS Ventura 13.1-22C65.dmg'...
  ├─ Deleting temporary directory '/Users/Shared/Mist/Cache/012-60271/image'...
  ├─ Created image '/Users/Shared/Mist/Install macOS Ventura 13.1-22C65.dmg'
┌─────────────────────┐
│ BOOTABLE DISK IMAGE │
└─────────────────────┘
  ├─ Creating new temporary directory '/Users/Shared/Mist/Cache/012-60271/iso'...
  ├─ Creating disk image '/Users/Shared/Mist/Cache/012-60271/iso/012-60271.dmg'...
  ├─ Mounting disk image at mount point '/Volumes/Install macOS Ventura'...
  ├─ Creating install media at mount point '/Volumes/Install macOS Ventura'...
  ├─ Unmounting disk image at mount point '/Volumes/Install macOS Ventura'...
  ├─ Deleting old image '/Users/Shared/Mist/Install macOS Ventura 13.1-22C65.iso'...
  ├─ Converting disk image '/Users/Shared/Mist/Cache/012-60271/iso/012-60271.cdr'...
  ├─ Moving '/Users/Shared/Mist/Cache/012-60271/iso/012-60271.cdr' to '/Users/Shared/Mist/Install macOS Ventura 13.1-22C65.iso'...
  ├─ Deleting temporary directory '/Users/Shared/Mist/Cache/012-60271/iso'...
  ├─ Created bootable disk image '/Users/Shared/Mist/Install macOS Ventura 13.1-22C65.iso'
┌─────────┐
│ PACKAGE │
└─────────┘
  ├─ Deleting old package '/Users/Shared/Mist/Install macOS Ventura 13.1-22C65.pkg'...
  ├─ Copying '/Users/Shared/Mist/Cache/012-60271/InstallAssistant.pkg' to '/Users/Shared/Mist/Install macOS Ventura 13.1-22C65.pkg'...
┌──────────┐
│ TEARDOWN │
└──────────┘
  ├─ Unmounting disk image at mount point '/Volumes/012-60271'...
  └─ Deleting image '/Users/Shared/Mist/Cache/012-60271/012-60271.dmg'...
grahampugh commented 1 year ago

EDIT: my bad, my wrapper script was set to only install mist if there wasn't a version already installed, so it was still running 1.9.1.