El Capitan을 ISO 파일로 굽는 Bash 스크립트

Mavericks 때 구한 쉘 스크립트를 새 운영체제가 나올 때마다 조금씩 수정해서 요긴하게 사용한다. 앱스토어에서 El Capitan을 다운로드 받은 후에 이 스크립트를 실행하면 바탕화면에 ~/Desktop/Mavericks.iso 파일이 생긴다.

#!/usr/bin/env bash -x
hdiutil attach "/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint /Volumes/install_app
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Convert the boot image to a sparse bundle
hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o "/tmp/El Capitan"
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Increase the sparse bundle capacity to accommodate the packages
hdiutil resize -size 8g "/tmp/El Capitan.sparseimage"
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Mount the sparse bundle for package addition
hdiutil attach "/tmp/El Capitan.sparseimage" -noverify -nobrowse -mountpoint /Volumes/install_build
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Remove Package link and replace with actual files
rm /Volumes/install_build/System/Installation/Packages
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
cp -rp /Volumes/install_app/Packages /Volumes/install_build/System/Installation/
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Unmount the installer image
hdiutil detach /Volumes/install_app
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Unmount the sparse bundle
hdiutil detach /Volumes/install_build
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Resize the partition in the sparse bundle to remove any free space
hdiutil resize -size `hdiutil resize -limits "/tmp/El Capitan.sparseimage" | tail -n 1 | awk '{ print $1 }'`b "/tmp/El Capitan.sparseimage"
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Convert the sparse bundle to ISO/CD master
hdiutil convert "/tmp/El Capitan.sparseimage" -format UDTO -o "/tmp/El Capitan"
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Remove the sparse bundle
rm "/tmp/El Capitan.sparseimage"
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
# Rename the ISO and move it to the desktop
mv /tmp/El\ Capitan.cdr ~/Desktop/El\ Capitan.iso
exitStatus=$?
if [ $exitStatus -ne 0 ]; then
exit $exitStatus
fi
exit 0

Author Details
Kubernetes, DevSecOps, AWS, 클라우드 보안, 클라우드 비용관리, SaaS 의 활용과 내재화 등 소프트웨어 개발 전반에 도움이 필요하다면 도움을 요청하세요. 지인이라면 가볍게 도와드리겠습니다. 전문적인 도움이 필요하다면 저의 현업에 방해가 되지 않는 선에서 협의가능합니다.
0 0 votes
Article Rating
Subscribe
Notify of
guest


This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments