Repository: rtrouton/create_os_x_vm_install_dmg Branch: main Commit: fd2f2d972e8c Files: 5 Total size: 17.3 KB Directory structure: gitextract_syrpmg9f/ ├── LICENSE ├── README.txt ├── create_vmware_osx_install_dmg.sh └── support/ ├── OSInstall.collection └── minstallconfig.xml ================================================ FILE CONTENTS ================================================ ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2014 rtrouton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.txt ================================================ Please Read: ------------ macOS 10.12.4 introduced a change that prevents the addition of third-party packages to the OS installer. This script uses the addition of a third-party installer package, so unfortunately this script cannot be used to generate 10.12.4 or later OS installers. If you need to build a macOS 10.12.x VM, my recommendation at this point is to use the macOS 10.12.3 installer. Once the OS is installed, update to later versions of macOS Sierra as a post-installation task. This script prepares customized OS X installer disk images for use with VMware Fusion and ESXi. It's adapted from the prepare_iso script created by Tim Sutton: https://github.com/timsutton/osx-vm-templates/tree/master/prepare_iso Pre-requisites: 1. This script and the associated support directory. This script and the support directory must be both stored in the same directory in order for the script to work properly. 2. A 10.7.x, 10.8.x, 10.9.x, 10.10.x, 10.11.x, or 10.12.x installer from Apple's Mac App Store. Running the script: Run the create_vmware_osx_install_dmg.sh script with two arguments: the path to an "Install OS X.app" or the InstallESD.dmg contained within, and an output directory. Example usage: If you have a 10.11.x El Capitan installer available, run this command: sudo /path/to/create_vmware_osx_install_dmg.sh "/Applications/Install OS X El Capitan.app" /path/to/output_directory This should produce a DMG file at output_directory that's named OSX_InstallESD_10.11_15A284.dmg. An MD5 checksum is printed at the end of the process. What the script does: 1. Mounts the InstallESD.dmg using a shadow file, so the original DMG is left unchanged. 2. minstallconfig.xml is also copied, which is looked for by the installer environment's rc.* files that first load with the system. This allows us to never actually modify the BaseSystem.dmg and only drop in these extra files. 3. Additional installer packages can be added using a first boot package, which is added to the OS X install by way of the OSInstall.collection file. The script is expecting the following: A. That the first boot package is named "First Boot Package Install.pkg" (no quotes) B. That the first boot package is stored in the support directory. This first boot package can be generated by First Boot Package Install Generator.app, which will generate a distribution-style flat package that can be used with 10.7 / 10.8 / 10.9 / 10.10 / 10.11 OS installs. The instructions for using this tool to generate first boot packages are documented here: https://github.com/rtrouton/First_Boot_Package_Install_Generator 4. If desired, a second disk image in .iso format can be generated for use with VMware ESXi servers running on Apple hardware. Once you have the customized DMG file created, you can choose it as an install disk image in VMware Fusion when creating virtual machines in VMware Fusion. This script has been tested with Apple's 10.7.5, 10.8.5, 10.9.5, 10.10.5, 10.11.6, and 10.12.0 installers from the Mac App Store. NOTES: 1. A pre-generated First Boot Package Install.pkg is stored in the support directory as a zip file named First_Boot_Package_Install.zip. Unzip the file before running the script. This first boot package will automatically install all available Apple software updates following the OS installation, but provide no other customization. 2. The 10.9.x disk images created with this method will not install a recovery partition into a VM. As a workaround, it appears that this can be addressed via using Per Olofsson’s Create Recovery Partition Installer to generate an installer that can install the missing recovery partition: Create Recovery Partition Installer is available from here on GitHub: https://github.com/MagerValp/Create-Recovery-Partition-Installer Unfortunately, that installer would be too large to include as part of First Boot Package Install’s payload (available space is around 350 MBs, the Recovery Partition installer is around 485 MBs.) In my testing, 10.7.x, 10.8.x, 10.10.x, 10.11.x and 10.12.x disk images will successfully install a recovery partition into the VM. ================================================ FILE: create_vmware_osx_install_dmg.sh ================================================ #!/bin/sh # # Preparation script for a customized OS X installer for use with VWware Fusion and ESXi # # What the script does, in more detail: # # 1. Mounts the InstallESD.dmg using a shadow file, so the original DMG is left # unchanged. # # 2. minstallconfig.xml is also copied, which is looked for by the installer environment's # rc.* files that first load with the system. This allows us to never actually modify the # BaseSystem.dmg and only drop in these extra files. # # 3. Additional installer packages can be added using a first boot package which *must* be named # First Boot Package Install.pkg, which is added to the OS X install by way of the OSInstall.collection file. # # This first boot package can be generated by First Boot Package Install Generator.app, which will # generate a distribution-style flat package that can be used with OS installs. The instructions # for using this tool to generate first boot packages are documented here: # https://github.com/rtrouton/First_Boot_Package_Install_Generator # # 4. If desired, a second disk image in .iso format can be generated for use with VMware ESXi # servers running on Apple hardware. # # Original script written by Tim Sutton: # https://github.com/timsutton/osx-vm-templates/tree/master/prepare_iso # # Thanks: (brought over from Tim's original script) # Idea and much of the implementation thanks to Pepijn Bruienne, who's also provided # some process notes here: https://gist.github.com/4542016. The sample minstallconfig.xml, # use of OSInstall.collection and readme documentation provided with Greg Neagle's # createOSXInstallPkg tool also proved very helpful. (http://code.google.com/p/munki/wiki/InstallingOSX) # # User creation via package install method also credited to Greg, and made easy with Per # Olofsson's CreateUserPkg (http://magervalp.github.io/CreateUserPkg) # # Antony Blakey for updates to support OS X 10.11: # https://github.com/timsutton/osx-vm-templates/issues/40 usage() { cat < "$CDROM_LOCAL" chmod a+x "$CDROM_LOCAL" mkdir "$PACKAGES_DIR/Extras" cp "$SUPPORT_DIR/minstallconfig.xml" "$PACKAGES_DIR/Extras/" cp "$SUPPORT_DIR/OSInstall.collection" "$PACKAGES_DIR/" cp -r "$FIRSTBOOT_PKG" "$PACKAGES_DIR/" rm -rf "$SUPPORT_DIR/tmp" msg_status "Unmounting BaseSystem.." hdiutil detach "$MNT_BASE_SYSTEM" if [ $DMG_OS_VERS_MAJOR -lt 9 ]; then msg_status "Pre-Mavericks we save back the modified BaseSystem to the root of the ESD." hdiutil convert -format UDZO -o "$MNT_ESD/BaseSystem.dmg" "$BASE_SYSTEM_DMG_RW" fi msg_status "Unmounting.." hdiutil detach "$MNT_ESD" msg_status "Converting to .dmg disk image.." if [[ $DMG_OS_VERS_MAJOR -ge 9 ]]; then msg_status "On Mavericks and later, the entire modified BaseSystem is our output dmg." hdiutil convert -format UDZO -o "$OUTPUT_DMG" "$BASE_SYSTEM_DMG_RW" else msg_status "Pre-Mavericks we're modifying the original ESD file." hdiutil convert -format UDZO -o "$OUTPUT_DMG" -shadow "$SHADOW_FILE" "$ESD" fi rm -rf "$MNT_ESD" "$SHADOW_FILE" "$BASE_SYSTEM_DMG_RW" if [[ $ISO = 1 ]]; then OUTPUT_ISO="$OUT_DIR/${OSNAME}_InstallESD_${DMG_OS_VERS}_${DMG_OS_BUILD}.iso" msg_status "Converting to .iso disk image...." /usr/bin/hdiutil convert "$OUTPUT_DMG" -format UDTO -o "$OUTPUT_ISO" /bin/mv $OUT_DIR/${OSNAME}_InstallESD_${DMG_OS_VERS}_${DMG_OS_BUILD}.iso.cdr "$OUTPUT_ISO" fi if [[ -n "$SUDO_UID" ]] && [[ -n "$SUDO_GID" ]]; then msg_status "Fixing permissions.." chown -R $SUDO_UID:$SUDO_GID "$OUT_DIR" fi msg_status "Checksumming .dmg disk image.." MD5=$(md5 -q "$OUTPUT_DMG") msg_status "MD5: $MD5" msg_status "Built .dmg disk image is located at $OUTPUT_DMG." if [[ -f "$OUTPUT_ISO" ]]; then msg_status "Checksumming .iso disk image.." MD5=$(md5 -q "$OUTPUT_ISO") msg_status "MD5: $MD5" msg_status "Built .iso disk image is located at $OUTPUT_ISO." fi msg_status "Build process finished." ================================================ FILE: support/OSInstall.collection ================================================ /System/Installation/Packages/OSInstall.mpkg /System/Installation/Packages/OSInstall.mpkg /System/Installation/Packages/First Boot Package Install.pkg ================================================ FILE: support/minstallconfig.xml ================================================ InstallType automated Language en Package /System/Installation/Packages/OSInstall.collection Target /Volumes/Macintosh HD TargetName Macintosh HD