#!/usr/bin/env bash
#===========================================================================
# Works only with the official image available in the Mac App Store.
# Make sure you download the official installer before running this script.
#===========================================================================

# Change this at your desire. Sometimes this works out of the box, sometimes not.
# Default size: ~17 GB
DISK_SIZE="17408"

#===========================================================================

hdiutil create -o /tmp/Sequoia.cdr -size $DISK_SIZE -layout SPUD -fs HFS+J
hdiutil attach /tmp/Sequoia.cdr.dmg -noverify -mountpoint /Volumes/install_build
sudo "/Applications/Install macOS 15 beta.app/Contents/Resources/createinstallmedia"  --volume /Volumes/install_build --nointeraction
hdiutil detach "/Volumes/Shared Support"
hdiutil detach "/Volumes/Install macOS 15 beta"
hdiutil convert /tmp/Sequoia.cdr.dmg -format UDTO -o /tmp/Sequoia.iso
mv /tmp/Sequoia.iso.cdr ~/Desktop/Sequoia.iso
rm /tmp/Sequoia.cdr.dmg