Skip to content

Instantly share code, notes, and snippets.

@leiless
Created August 17, 2018 09:08
Show Gist options
  • Save leiless/dc0959ea7ae98efaae8ad57e51de975d to your computer and use it in GitHub Desktop.
Save leiless/dc0959ea7ae98efaae8ad57e51de975d to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Created 18H17
#
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/HighSierra.cdr"
ISO_NAME="HighSierra.iso"
ISO_NAME="HighSierra_17G65.iso"
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 "$OSX_APP"/Contents/SharedSupport/BaseSystem.dmg \
--target $VOL_BUILD --noprompt --noverify -erase
cp -rp $VOL_INSTALL/Packages "$VOL_BASE"/System/Installation/PackagesLink
cp -rp "$OSX_APP"/Contents/SharedSupport/BaseSystem.chunklist "$VOL_BASE"
cp -rp "$OSX_APP"/Contents/SharedSupport/BaseSystem.dmg "$VOL_BASE"
hdiutil detach $VOL_INSTALL
hdiutil detach "$VOL_BASE"
hdiutil convert ${IMG_CDR}.dmg -format UDTO \
-o /tmp/$ISO_NAME
rm -f ${IMG_CDR}.dmg
mv /tmp/$ISO_NAME.cdr ~/Desktop/$ISO_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment