Created
January 19, 2017 14:55
-
-
Save anoldguy/863d78e3cd0fe58046d029efe31266b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ============================================================== | |
# How to make an ISO from the "Install $OS_NAME.app" | |
# ============================================================== | |
OS_NAME="${1:-macOS Sierra}" | |
SHORT_NAME="${2:-macOS}" | |
INSTALLER_PATH="/Applications/Install $OS_NAME.app" | |
IMAGE_PATH="/tmp/$SHORT_NAME" | |
echo | |
echo Mount the installer image | |
echo ----------------------------------------------------------- | |
echo $ hdiutil attach "$INSTALLER_PATH"/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app | |
hdiutil attach "$INSTALLER_PATH"/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app | |
echo | |
echo Create $SHORT_NAME blank ISO image with a Single Partition - Apple Partition Map | |
echo -------------------------------------------------------------------------- | |
echo $ hdiutil create -o $IMAGE_PATH -size 8g -layout SPUD -fs HFS+J -type SPARSE | |
hdiutil create -o $IMAGE_PATH -size 8g -layout SPUD -fs HFS+J -type SPARSE | |
echo | |
echo Mount the sparse bundle for package addition | |
echo -------------------------------------------------------------------------- | |
echo $ hdiutil attach $IMAGE_PATH.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build | |
hdiutil attach $IMAGE_PATH.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build | |
echo | |
echo Restore the Base System into the $SHORT_NAME ISO image | |
echo -------------------------------------------------------------------------- | |
echo $ asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase | |
asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase | |
echo | |
echo Remove Package link and replace with actual files | |
echo -------------------------------------------------------------------------- | |
echo $ rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages | |
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages | |
echo $ cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/ | |
cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/ | |
echo | |
echo Copy $OS_NAME installer dependencies | |
echo -------------------------------------------------------------------------- | |
echo $ cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist | |
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist | |
echo $ cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg | |
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg | |
echo | |
echo Unmount the installer image | |
echo -------------------------------------------------------------------------- | |
echo $ hdiutil detach /Volumes/install_app | |
hdiutil detach /Volumes/install_app | |
echo | |
echo Unmount the sparse bundle | |
echo -------------------------------------------------------------------------- | |
echo $ hdiutil detach /Volumes/OS\ X\ Base\ System/ | |
hdiutil detach /Volumes/OS\ X\ Base\ System/ | |
echo | |
echo Resize the partition in the sparse bundle to remove any free space | |
echo -------------------------------------------------------------------------- | |
echo $ hdiutil resize -size `hdiutil resize -limits $IMAGE_PATH.sparseimage | tail -n 1 | awk '{ print $1 }'`b $IMAGE_PATH.sparseimage | |
hdiutil resize -size `hdiutil resize -limits $IMAGE_PATH.sparseimage | tail -n 1 | awk '{ print $1 }'`b $IMAGE_PATH.sparseimage | |
echo | |
echo Convert the sparse bundle to ISO/CD master | |
echo -------------------------------------------------------------------------- | |
echo $ hdiutil convert $IMAGE_PATH.sparseimage -format UDTO -o $IMAGE_PATH | |
hdiutil convert $IMAGE_PATH.sparseimage -format UDTO -o $IMAGE_PATH | |
echo | |
echo Remove the sparse bundle | |
echo -------------------------------------------------------------------------- | |
echo $ rm $IMAGE_PATH.sparseimage | |
rm $IMAGE_PATH.sparseimage | |
echo | |
echo Rename the ISO and move it to the desktop | |
echo -------------------------------------------------------------------------- | |
echo $ mv $IMAGE_PATH.cdr ~/Desktop/$SHORT_NAME.iso | |
mv $IMAGE_PATH.cdr ~/Desktop/$SHORT_NAME.iso |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment