#!/bin/bash # Mount the Installer image hdiutil attach /Applications/Install\ macOS\ Sierra.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app # Create Sierra sparseimage of 7316mb with a Single Partition - Apple Partition Map hdiutil create -o /tmp/Sierra -size 7316m -layout SPUD -fs HFS+J -type SPARSE # Mount the Sierra sparseimage hdiutil attach /tmp/Sierra.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build # Restore the Base System into the Sierra Blank sparseimage asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase # Remove Packages link and replace with actual files rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/ # Copy Sierra installer dependencies cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg # Unmount the installer image hdiutil detach /Volumes/install_app # Unmount the Base System image hdiutil detach /Volumes/OS\ X\ Base\ System/ # Convert the Sierra spareseimage image to ISO/CD master hdiutil convert /tmp/Sierra.sparseimage -format UDTO -o /tmp/Sierra.iso # Rename the Sierra ISO image and move it to the desktop mv /tmp/Sierra.iso.cdr ~/Desktop/'Sierra 10.11.0.iso' # Delete Sierra.sparseimage file rm -f /tmp/Sierra.sparseimage