modified: pixi.toml
[GalaxyCodeBases.git] / etc / Mac / create_os_x_vm_install_dmg / Installdmg2boot.sh
blob2443a5646270d811fb165edc5222440261dcf840
1 #!/bin/bash
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
8 # 13A476u).
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
12 set -x
13 set -e
16 # The first argument is the path to the .app bundle (the input of the
17 # executable).
18 inputApp="$1"
19 # The second argument is the path to the .dmg file (the output of the
20 # executable), which must end with ".dmg".
21 outputDmg="$2"
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
41 cleanup() {
42 if [ -d "$outputMnt" ]; then
43 hdiutil detach "$outputMnt"
47 if [ -d "$installMnt" ]; then
48 hdiutil detach "$installMnt"
52 rmdir -- "$tmpDir"
56 # Cleanup on failure.
57 trap cleanup ERR
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))
76 # Mount "$outputDmg".
77 hdiutil attach "$outputDmg" -mountpoint "$outputMnt" -nobrowse
80 # Modify "$outputDmg".
81 rm -- "$outputPkg"
82 cp -r -- "$installPkg" "$outputPkg"
85 # Cleanup on success.
86 trap ERR; cleanup
89 ls -alh -- "$outputDmg"