Skip to content

Instantly share code, notes, and snippets.

@gasinvein
Forked from julianxhokaxhiu/create-iso.sh
Last active July 12, 2018 09:35
Show Gist options
  • Save gasinvein/c11d423c09ec1a07441901dcc6880254 to your computer and use it in GitHub Desktop.
Save gasinvein/c11d423c09ec1a07441901dcc6880254 to your computer and use it in GitHub Desktop.
Simple bash script to create a Bootable ISO from macOS Sierra Install Image from Mac App Store
#!/bin/bash -e
#
# Credits to fuckbecauseican5 from https://www.reddit.com/r/hackintosh/comments/4s561a/macos_sierra_16a238m_install_success_and_guide/
# Adapted to work with the official image available into Mac App Store
#
# Enjoy!
SOURCE_APP="$1"
DEST_IMAGE="$2"
if ! [ -d "$SOURCE_APP" ]; then
echo "directory $SOURCE_APP does not exist"
exit 1
fi
if [ -f "$DEST_IMAGE.dmg" ] || [ -f "$DEST_IMAGE.iso" ]; then
echo "image $DEST_IMAGE already exist"
exit 1
fi
hdiutil attach "$SOURCE_APP/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint "/Volumes/install_app"
hdiutil create -o "$DEST_IMAGE" -size 8G -layout SPUD -fs HFS+J
hdiutil attach "$DEST_IMAGE.dmg" -noverify -nobrowse -mountpoint "/Volumes/install_build"
asr restore -source "/Volumes/install_app/BaseSystem.dmg" -target "/Volumes/install_build" -noprompt -noverify -erase
rm "/Volumes/OS X Base System/System/Installation/Packages"
cp -rp "/Volumes/install_app/Packages" "/Volumes/OS X Base System/System/Installation/"
cp -rp "/Volumes/install_app/BaseSystem.chunklist" "/Volumes/OS X Base System/"
cp -rp "/Volumes/install_app/BaseSystem.dmg" "/Volumes/OS X Base System/"
hdiutil detach "/Volumes/install_app"
hdiutil detach "/Volumes/OS X Base System/"
hdiutil convert "$DEST_IMAGE.dmg" -format UDTO -o "$DEST_IMAGE"
rm "$DEST_IMAGE.dmg"
mv "$DEST_IMAGE".{cdr,iso}
echo "image $DEST_IMAGE.iso created"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment