Skip to content

Instantly share code, notes, and snippets.

@ghorbanzade
Forked from julianxhokaxhiu/create-iso.sh
Last active July 12, 2018 09:03
Show Gist options
  • Save ghorbanzade/c1b60adab05df362bde4495f73ff4c06 to your computer and use it in GitHub Desktop.
Save ghorbanzade/c1b60adab05df362bde4495f73ff4c06 to your computer and use it in GitHub Desktop.
Script to Convert OSX app Image to Bootable iso
#!/bin/bash
# tested for Yosemite, ElCapitan and Sierra
print_usage () {
echo "usage: ${0} path_to_app"
exit -1;
}
if [ $# -ne 1 ]; then
echo "error: argument missing"
print_usage
fi
if [ ! -f "${1}/Contents/SharedSupport/InstallESD.dmg" ]; then
echo "error: expect command line argument to be path to osx .app directory"
print_usage
fi
APP_NICK="$(basename "${1}")";
hdiutil attach "${1}/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil create -o "/tmp/${APP_NICK}.cdr" -size 7316m -layout SPUD -fs HFS+J
hdiutil attach "/tmp/${APP_NICK}.cdr.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/BaseSystem.chunklist
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
hdiutil detach /Volumes/install_app
hdiutil detach /Volumes/OS\ X\ Base\ System/
hdiutil convert "/tmp/${APP_NICK}.cdr.dmg" -format UDTO -o "/tmp/${APP_NICK}.iso"
mv "/tmp/${APP_NICK}.iso.cdr" "~/Desktop/${APP_NICK}.iso"
rm "/tmp/${APP_NICK}.cdr.dmg"
DST="~/Desktop/${APP_NICK}.iso"
if [ -f ${DST} ]; then
echo "${DST}"
exit 0
fi
exit -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment