3 # This executable converts a Mavericks .app (which allows to upgrade a machine
4 # from Mac OS 10.6.7+ to Mavericks) into a Mavericks .dmg (which allows to
5 # install Mavericks from scratch on a machine).
7 # It has been tested with "Install OS X 10.9 Developer Preview.app" (build
10 # http://www.insanelymac.com/forum/topic/290949-how-to-install-os-x-10x-snow-leopard-to-el-capitan-in-vmware-workstation-1011-workstation-proplayer-12-player-67-esxi-56/page-2#entry1956505
16 # The first argument is the path to the .app bundle (the input of the
19 # The second argument is the path to the .dmg file (the output of the
20 # executable), which must end with ".dmg".
22 [ "${outputDmg: -4}" = .dmg
]
26 # The problem: /System/Installation/Packages inside /BaseSystem.dmg inside
27 # "$inputApp"/Contents/SharedSupport/InstallESD.dmg is a dangling symlink,
28 # which prevents installing Mavericks from scratch.
29 # The solution: Replace the symlink with the /Packages directory inside
30 # "$inputApp"/Contents/SharedSupport/InstallESD.dmg.
34 tmpDir
=`mktemp -d -t 'Create Mavericks Installer'`
35 installMnt
="$tmpDir"/install
36 installPkg
="$installMnt"/Packages
37 outputMnt
="$tmpDir"/output
38 outputPkg
="$outputMnt"/System
/Installation
/Packages
42 if [ -d "$outputMnt" ]; then
43 hdiutil detach
"$outputMnt"
47 if [ -d "$installMnt" ]; then
48 hdiutil detach
"$installMnt"
60 # Mount InstallESD.dmg so we can access /BaseSystem.dmg and /Packages inside.
61 hdiutil attach
"$inputApp"/Contents
/SharedSupport
/InstallESD.dmg \
62 -mountpoint "$installMnt" -nobrowse
65 # Create "$outputDmg", a read/write copy of the read-only BaseSystem.dmg.
66 hdiutil convert
"$installMnt"/BaseSystem.dmg
-format UDRW
-o "$outputDmg"
69 # Enlarge "$outputDmg" to accommodate for our modifications. The UDRW image
70 # format is not sparse, so we must precisely compute the new size.
71 curSectors
=`hdiutil resize "$outputDmg" -limits | tail -1 | awk '{ print $2 }'`
72 extraSectors
=`BLOCKSIZE=512 du -s -- "$installPkg" | awk '{ print $1 }'`
73 hdiutil resize
"$outputDmg" -sectors $
((curSectors
+ extraSectors
))
77 hdiutil attach
"$outputDmg" -mountpoint "$outputMnt" -nobrowse
80 # Modify "$outputDmg".
82 cp -r -- "$installPkg" "$outputPkg"
89 ls -alh -- "$outputDmg"