Last active
August 29, 2015 14:20
-
-
Save samnung/399696b8963a922f8dbb to your computer and use it in GitHub Desktop.
Fix detection of application and result existence
This file contains hidden or 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 | |
# taken from http://www.fredmastro.com/?p=40 | |
set -e # exit when some command fails | |
if [[ $# != 2 ]]; then | |
echo "Usage: $0 <path-to-osx-install-application> <result-ios-path>" >&2 | |
exit 1 | |
fi | |
app_path=$1 | |
if [[ ! -d "$app_path" ]]; then | |
echo "$0: path to application '$app_path' doesn't exist" >&2 | |
exit 1 | |
fi | |
result_iso=$2 | |
if [[ -f "$result_iso" ]]; then | |
echo "$0: file at result path '$result_iso' already exist" >&2 | |
exit 1 | |
fi | |
# Mount the installer image | |
hdiutil attach "${app_path}/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint /Volumes/install_app | |
# Convert the boot image to a sparse bundle | |
hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o /tmp/Yosemite | |
# Increase the sparse bundle capacity to accommodate the packages | |
hdiutil resize -size 8g /tmp/Yosemite.sparseimage | |
# Mount the sparse bundle for package addition | |
hdiutil attach /tmp/Yosemite.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build | |
# Remove Package link and replace with actual files | |
rm /Volumes/install_build/System/Installation/Packages | |
cp -rp /Volumes/install_app/Packages /Volumes/install_build/System/Installation/ | |
# Copy missing BaseSystem files | |
cp /Volumes/install_app/BaseSystem.dmg /Volumes/install_build/ | |
cp /Volumes/install_app/BaseSystem.chunklist /Volumes/install_build/ | |
# Unmount the installer image | |
hdiutil detach /Volumes/install_app | |
# Unmount the sparse bundle | |
hdiutil detach /Volumes/install_build | |
# Resize the partition in the sparse bundle to remove any free space | |
hdiutil resize -size `hdiutil resize -limits /tmp/Yosemite.sparseimage | tail -n 1 | awk '{ print $1 }'`b /tmp/Yosemite.sparseimage | |
# Convert the sparse bundle to ISO/CD master | |
hdiutil convert /tmp/Yosemite.sparseimage -format UDTO -o /tmp/Yosemite | |
# Remove the sparse bundle | |
rm /tmp/Yosemite.sparseimage | |
# Rename the ISO and move it to the desktop | |
mv /tmp/Yosemite.cdr "$result_iso" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment