From 37b24fac43044a67870d61cdc346d193fff7b314 Mon Sep 17 00:00:00 2001 From: cipaterson <46644142+cipaterson@users.noreply.github.com> Date: Wed, 23 Jun 2021 17:10:23 +0800 Subject: [PATCH] Added changes to fix issue #73 and added support for Catalina --- prepare-iso.sh | 69 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/prepare-iso.sh b/prepare-iso.sh index f84bdb8..077fd91 100755 --- a/prepare-iso.sh +++ b/prepare-iso.sh @@ -7,6 +7,7 @@ # - Sierra (10.12) # - High Sierra (10.13) # - Mojave (10.14) +# - Catalina (10.15) set -e @@ -51,8 +52,11 @@ function createISO() echo echo Create ${isoName} blank ISO image with a Single Partition - Apple Partition Map echo -------------------------------------------------------------------------- - echo $ hdiutil create -o /tmp/${isoName} -size 8g -layout SPUD -fs HFS+J -type SPARSE - hdiutil create -o /tmp/${isoName} -size 8g -layout SPUD -fs HFS+J -type SPARSE + # Just in case - delete any previous sparseimage + [ -e /tmp/${isoName}.sparseimage ] && rm -f /tmp/${isoName}.sparseimage + # increased size to 16G - 8G is too small for Catalina + echo $ hdiutil create -o /tmp/${isoName} -size 16g -layout SPUD -fs HFS+J -type SPARSE + hdiutil create -o /tmp/${isoName} -size 16g -layout SPUD -fs HFS+J -type SPARSE echo echo Mount the sparse bundle for package addition @@ -63,9 +67,15 @@ function createISO() echo echo Restore the Base System into the ${isoName} ISO image echo -------------------------------------------------------------------------- - if [ "${isoName}" == "HighSierra" ] || [ "${isoName}" == "Mojave" ] ; then + if [ "${isoName}" == "HighSierra" ] || [ "${isoName}" == "Mojave" ] || [ "${isoName}" == "Catalina" ] ; then echo $ asr restore -source "${installerAppName}"/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase - asr restore -source "${installerAppName}"/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase + #following asr command returns an error and prints: + #"Personalization succeeded + #"asr: Couldn't personalize volume /Volumes/macOS Base System - Operation not permitted + #I disabled SIP and the error still occurs. + #This was reported in Issue #73 for Mojave + #I added ||true for now to prevent the script from exiting as the steps that follow still seem to work fine for Catalina + asr restore -source "${installerAppName}"/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase ||true else echo $ asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase @@ -74,7 +84,10 @@ function createISO() echo echo Remove Package link and replace with actual files echo -------------------------------------------------------------------------- - if [ "${isoName}" == "HighSierra" ] || [ "${isoName}" == "Mojave" ] ; then + if [ "${isoName}" == "Mojave" ] || [ "${isoName}" == "Catalina" ] ; then + echo $ ditto -V /Volumes/install_app/Packages /Volumes/macOS\ Base\ System/System/Installation/ + ditto -V /Volumes/install_app/Packages /Volumes/macOS\ Base\ System/System/Installation/ + elif [ "${isoName}" == "HighSierra" ] ; then echo $ ditto -V /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/ ditto -V /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/ else @@ -87,7 +100,12 @@ function createISO() echo echo Copy macOS ${isoName} installer dependencies echo -------------------------------------------------------------------------- - if [ "${isoName}" == "HighSierra" ] || [ "${isoName}" == "Mojave" ] ; then + if [ "${isoName}" == "Mojave" ] || [ "${isoName}" == "Catalina" ] ; then + echo $ ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.chunklist /Volumes/macOS\ Base\ System/BaseSystem.chunklist + ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.chunklist /Volumes/macOS\ Base\ System/BaseSystem.chunklist + echo $ ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.dmg /Volumes/macOS\ Base\ System/BaseSystem.dmg + ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.dmg /Volumes/macOS\ Base\ System/BaseSystem.dmg + elif [ "${isoName}" == "HighSierra" ] ; then echo $ ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist echo $ ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg @@ -108,9 +126,13 @@ function createISO() echo echo Unmount the sparse bundle echo -------------------------------------------------------------------------- - echo $ hdiutil detach /Volumes/OS\ X\ Base\ System/ - hdiutil detach /Volumes/OS\ X\ Base\ System/ - + if [ "${isoName}" == "Mojave" ] || [ "${isoName}" == "Catalina" ] ; then + echo $ hdiutil detach /Volumes/macOS\ Base\ System/ + hdiutil detach /Volumes/macOS\ Base\ System/ + else + echo $ hdiutil detach /Volumes/OS\ X\ Base\ System/ + hdiutil detach /Volumes/OS\ X\ Base\ System/ + fi echo echo Resize the partition in the sparse bundle to remove any free space echo -------------------------------------------------------------------------- @@ -158,29 +180,34 @@ function installerExists() # Main script code # # Eject installer disk in case it was opened after download from App Store -for disk in $(hdiutil info | grep /dev/disk | grep partition | cut -f 1); do +# grep "partition_scheme" because "partition" finds too many lines +for disk in $(hdiutil info | grep /dev/disk | grep partition_scheme | cut -f 1); do hdiutil detach -force ${disk} done # See if we can find an eligible installer. # If successful, then create the iso file from the installer. -if installerExists "Install macOS Mojave.app" ; then - createISO "Install macOS Mojave.app" "Mojave" +if installerExists "Install macOS Catalina.app" ; then + createISO "Install macOS Catalina.app" "Catalina" else - if installerExists "Install macOS High Sierra.app" ; then - createISO "Install macOS High Sierra.app" "HighSierra" + if installerExists "Install macOS Mojave.app" ; then + createISO "Install macOS Mojave.app" "Mojave" else - if installerExists "Install macOS Sierra.app" ; then - createISO "Install macOS Sierra.app" "Sierra" + if installerExists "Install macOS High Sierra.app" ; then + createISO "Install macOS High Sierra.app" "HighSierra" else - if installerExists "Install OS X El Capitan.app" ; then - createISO "Install OS X El Capitan.app" "ElCapitan" + if installerExists "Install macOS Sierra.app" ; then + createISO "Install macOS Sierra.app" "Sierra" else - if installerExists "Install OS X Yosemite.app" ; then - createISO "Install OS X Yosemite.app" "Yosemite" + if installerExists "Install OS X El Capitan.app" ; then + createISO "Install OS X El Capitan.app" "ElCapitan" else - echo "Could not find installer for Yosemite (10.10), El Capitan (10.11), Sierra (10.12), High Sierra (10.13) or Mojave (10.14)." + if installerExists "Install OS X Yosemite.app" ; then + createISO "Install OS X Yosemite.app" "Yosemite" + else + echo "Could not find installer for Yosemite (10.10), El Capitan (10.11), Sierra (10.12), High Sierra (10.13), Mojave (10.14) or Catalina (10.15)." + fi fi fi fi