-
-
Save pythoninthegrass/0f5bd6fdf406a2b06f59830f4b0d72c9 to your computer and use it in GitHub Desktop.
Simple bash script to create a Bootable ISO from macOS Sierra Install Image from Mac App Store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# SOURCE: | |
# https://gist.github.com/julianxhokaxhiu/6ed6853f3223d0dd5fdffc4799b3a877 | |
# TODO: error handling | |
# activate verbose standard output (stdout) | |
set -v | |
# activate debugging (execution shown) | |
set -x | |
# Current user | |
logged_in_user=$(logname) # posix alternative to /dev/console | |
# Working directory | |
# script_dir=$(cd "$(dirname "$0")" && pwd) | |
# Set $IFS to eliminate whitespace in pathnames | |
IFS="$(printf '\n\t')" | |
# create mountpoint and volume | |
hdiutil attach '/Applications/Install macOS Sierra.app/Contents/SharedSupport/InstallESD.dmg' -noverify -nobrowse -mountpoint '/Volumes/install_app' | |
hdiutil create -o '/tmp/Sierra.cdr' -size 7316m -layout SPUD -fs HFS+J | |
hdiutil attach '/tmp/Sierra.cdr.dmg' -noverify -nobrowse -mountpoint '/Volumes/install_build' | |
# copy dmg contents to volume | |
asr restore -source /Volumes/install_app/BaseSystem.dmg -target '/Volumes/install_build' -noprompt -noverify -erase | |
# remove intermediate files | |
rm '/Volumes/OS X Base System/System/Installation/Packages' | |
# copy remaining install files to volume | |
cp -rp '/Volumes/install_app/Packages' '/Volumes/OS X Base System/System/Installation' | |
cp -rp '/Volumes/install_app/BaseSystem.chunklist' '/Volumes/OS X Base System/BaseSystem.chunklist' | |
cp -rp '/Volumes/install_app/BaseSystem.dmg' '/Volumes/OS X Base System/BaseSystem.dmg' | |
# unmount volumes | |
hdiutil detach '/Volumes/install_app' | |
hdiutil detach '/Volumes/OS X Base System' | |
# wait for operations to finish | |
sleep 10 | |
# convert dmg to iso (cdr) | |
hdiutil convert '/tmp/Sierra.cdr.dmg' -format UDTO -o '/tmp/Sierra.iso' | |
# relocate iso to desktop | |
mv '/tmp/Sierra.iso.cdr' "/Users/$logged_in_user/Desktop/Sierra.iso" | |
# cleanup | |
rm '/tmp/Sierra.cdr.dmg' | |
# deactivate verbose and debugging stdout | |
set +v | |
set +x | |
unset IFS | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment