Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added changes to fix issue #73 and added support for Catalina #83

Merged
merged 2 commits into from
Aug 19, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 48 additions & 21 deletions prepare-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# - Sierra (10.12)
# - High Sierra (10.13)
# - Mojave (10.14)
# - Catalina (10.15)

set -e

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 --------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down