Skip to content

Instantly share code, notes, and snippets.

@andromedarabbit
Created February 6, 2016 14:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andromedarabbit/dc7d5fe85bec4d0e1da2 to your computer and use it in GitHub Desktop.
Save andromedarabbit/dc7d5fe85bec4d0e1da2 to your computer and use it in GitHub Desktop.
Create bootable Mavericks ISO
#!/usr/bin/env bash -x
hdiutil attach /Applications/Install\ OS\ X\ Mavericks.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Convert the boot image to a sparse bundle
hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o /tmp/Mavericks
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Increase the sparse bundle capacity to accommodate the packages
hdiutil resize -size 8g /tmp/Mavericks.sparseimage
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Mount the sparse bundle for package addition
hdiutil attach /tmp/Mavericks.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Remove Package link and replace with actual files
rm /Volumes/install_build/System/Installation/Packages
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
cp -rp /Volumes/install_app/Packages /Volumes/install_build/System/Installation/
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Unmount the installer image
hdiutil detach /Volumes/install_app
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Unmount the sparse bundle
hdiutil detach /Volumes/install_build
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Resize the partition in the sparse bundle to remove any free space
hdiutil resize -size `hdiutil resize -limits /tmp/Mavericks.sparseimage | tail -n 1 | awk '{ print $1 }'`b /tmp/Mavericks.sparseimage
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Convert the sparse bundle to ISO/CD master
hdiutil convert /tmp/Mavericks.sparseimage -format UDTO -o /tmp/Mavericks
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Remove the sparse bundle
rm /tmp/Mavericks.sparseimage
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Rename the ISO and move it to the desktop
mv /tmp/Mavericks.cdr ~/Desktop/Mavericks.iso
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment