modified: pixi.toml
[GalaxyCodeBases.git] / etc / Mac / create_os_x_vm_install_dmg / Installdmg2iso.sh
blob3f0068809b41da534cf9eae2875af952cc9431b9
1 #!/bin/bash
2 # http://www.insanelymac.com/forum/topic/293481-how-to-create-a-bootable-iso-from-the-mavericks-installesddmg/
3 # 测试后发现无法启动……
5 ESD=$1
6 TMP=$2
8 if [ -z "$ESD" ] || [ -z "$TMP" ]; then
9 echo usage: "'$0' /path/to/esd /path/to/tmpdir"
10 exit 1
12 if ! [ -e "$ESD" ]; then
13 echo "file '$ESD' does not exist"
14 exit 1
16 if ! [ -e "$TMP" ]; then
17 echo "dir '$TMP' does not exist"
18 exit 1
21 MPAPP=/Volumes/install_app
22 MPIMG=/Volumes/install_img
23 IMGSPARSE=$TMP/install.sparseimage
24 IMGDVD=$TMP/install.cdr
26 detach_all() {
27 if [ -d "$MPAPP" ]; then hdiutil detach "$MPAPP"; fi
28 if [ -d "$MPIMG" ]; then hdiutil detach "$MPIMG"; fi
30 exit_all() {
31 echo +++ Command returned with error, aborting ...
32 exit 2
35 trap detach_all EXIT
36 trap exit_all ERR
38 echo +++ Trying to unmount anything from previous run
39 detach_all
41 echo +++ Mount the installer image
42 hdiutil attach "$ESD" -noverify -nobrowse -readonly -mountpoint "$MPAPP"
44 echo +++ Convert the boot image to a sparse bundle
45 rm -f "$IMGSPARSE"
46 hdiutil convert "$MPAPP"/BaseSystem.dmg -format UDSP -o "$IMGSPARSE"
48 echo +++ Increase the sparse bundle capacity to accommodate the packages
49 hdiutil resize -size 9g "$IMGSPARSE"
51 echo +++ Mount the sparse bundle for package addition
52 hdiutil attach "$IMGSPARSE" -noverify -nobrowse -readwrite -mountpoint "$MPIMG"
54 echo +++ Remove Package link and replace with actual files
55 rm -f "$MPIMG"/System/Installation/Packages
56 cp -rp "$MPAPP"/Packages "$MPIMG"/System/Installation/
58 echo +++ Unmount the installer image
59 hdiutil detach "$MPAPP"
61 echo +++ Unmount the sparse bundle
62 hdiutil detach "$MPIMG"
64 echo +++ Resize the partition in the sparse bundle to remove any free space
65 hdiutil resize -sectors min "$IMGSPARSE"
67 echo +++ Convert the sparse bundle to ISO/CD master
68 rm -f "$IMGDVD"
69 hdiutil convert "$IMGSPARSE" -format UDTO -o "$IMGDVD"
71 echo +++ Remove the sparse bundle
72 rm "$IMGSPARSE"
75 echo "Done"
76 echo "Find your DVD at '$IMGDVD'"