Build ISO of OS X for VMWare Fusion and ESXi

The Following script with take an OS X Install app and convert it to an ISO image that you can then attach as a CDRom to boot VMWare Fusion and ESXi from

#!/bin/bash

#This script makes an ISO image of OS X

#Check were running as root
if [ $EUID != 0 ] ; then
    echo "`basename "$0"` MUST run as root..."
    exit 1
fi

#Check for path to installer
if [ $# != 1 ] ; then
    echo "`basename "$0"` MUST be given a path to an OSX Installer App"
    echo "e.g. `basename "$0"` /Applications/Install\ OS\ X\ El\ Capitan\ GM\ Candidate.app"
    exit 1
fi

hdiutil attach "$1"/Contents/SharedSupport/InstallESD.dmg
hdiutil create -verbose -size 8GB -layout SPUD ~/Desktop/osxiso.dmg -fs HFS+ -volname osxiso
hdiutil attach ~/Desktop/osxiso.dmg

asr restore --source /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg  --target /Volumes/osxiso --erase -format HFS+ --noprompt --noverify

rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -a -v /Volumes/OS\ X\ Install\ ESD/Packages /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -a -v /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg /Volumes/OS\ X\ Install\ ESD/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System

#Grab OSX info from BaseSyste.dmg
ver1=`defaults read /Volumes/OS\ X\ Base\ System/System/Library/CoreServices/SystemVersion.plist ProductVersion`
ver2=`defaults read /Volumes/OS\ X\ Base\ System/System/Library/CoreServices/SystemVersion.plist ProductBuildVersion`

hdiutil eject /Volumes/OS\ X\ Base\ System
hdiutil eject /Volumes/OS\ X\ Install\ ESD
hdiutil convert ~/Desktop/osxiso.dmg -format UDTO -o ~/Desktop/osxiso

mv ~/Desktop/osxiso.cdr ~/Desktop/"$ver1"_"$ver2".iso
mv ~/Desktop/osxiso.dmg ~/Desktop/"$ver1"_"$ver2".dmg

echo "$ver1"_"$ver2".iso and "$ver1"_"$ver2".dmg produced on current users Desktop

exit 0

The Key to geeting this working is the SPUD format for the image, This is a legacy Apple format used for bootable CDRoms. DDM and an Apple Partition Scheme