Skip to content

Instantly share code, notes, and snippets.

@leiless
Created August 12, 2018 03:45
Show Gist options
  • Save leiless/131e01a981c81906dd7e77be7a31413c to your computer and use it in GitHub Desktop.
Save leiless/131e01a981c81906dd7e77be7a31413c to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Created 18H12
#
if [ $# -ne 1 ]; then
echo "`basename $0` installer_app"
exit 1
fi
set -ex
OSX_APP="$1"
VOL_INSTALL="/Volumes/install_app"
VOL_BUILD="/Volumes/install_build"
VOL_BASE="/Volumes/OS X Base System"
IMG_CDR="/tmp/Sierra.cdr"
if [ ! -d "$OSX_APP" ]; then
echo "$OSX_APP not directory"
exit 1
fi
if [ ! -f "$OSX_APP"/Contents/SharedSupport/InstallESD.dmg ]; then
echo "InstallESD.dmg not found in $OSX_APP"
exit 2
fi
hdiutil attach "$OSX_APP"/Contents/SharedSupport/InstallESD.dmg \
-noverify -nobrowse -mountpoint $VOL_INSTALL
hdiutil create -o $IMG_CDR -size 7316m \
-layout SPUD -fs HFS+J
hdiutil attach ${IMG_CDR}.dmg -noverify -nobrowse \
-mountpoint $VOL_BUILD
asr restore -source $VOL_INSTALL/BaseSystem.dmg \
-target $VOL_BUILD -noprompt -noverify -erase
rm -rf "$VOL_BASE"/System/Installation/Packages
cp -rp $VOL_INSTALL/Packages "$VOL_BASE"/System/Installation
cp -rp $VOL_INSTALL/BaseSystem.chunklist "$VOL_BASE"
cp -rp $VOL_INSTALL/BaseSystem.dmg "$VOL_BASE"
hdiutil detach $VOL_INSTALL
hdiutil detach "$VOL_BASE"
hdiutil convert ${IMG_CDR}.dmg -format UDTO \
-o /tmp/Sierra.iso
rm -f ${IMG_CDR}.dmg
mv /tmp/Sierra.iso.cdr ~/Desktop/Sierra.iso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment