#!/bin/sh #Set this to the directory of the autopatch dir APDIR="/Users/$USER/Desktop/Auto-Patch/" cpfix () { cp -r ./files/$1 $2 chown -R root:wheel $2 chmod -R 755 $2 echo $1 replaced } cd $APDIR #Convert dmg to editable image hdiutil convert /Users/"$USER"/Desktop/Auto-Patch/leopard.dmg -format UDTO -o /Users/osx/Desktop/Auto-Patch/leopard.iso #Mount new iso readwrite hdiutil attach -readwrite /Users/"$USER"/Desktop/Auto-Patch/leopard.iso.cdr -owners on #Rename image diskutil rename /Volumes/Mac\ OS\ X\ Install\ DVD/ osx86dvd #Delete Xcode to Free Space for Standard DVD Burn rm -rf /Volumes/osx86dvd/Xcode\ Tools echo Deleted Xcode #Remove old files # I tried to use this script to delete and copy disk Utility # onto the new bootable iso,It will not copy due to Spaces in its name. # Just copy it manually after this script is run running # rm -rf /Volumes/osx86dvd/Applications/Utilities/Disk\ Utility.app rm -rf /Volumes/osx86dvd/usr/standalone/i386 rm -rf /Volumes/osx86dvd/usr/sbin/Bless rm -R /Volumes/osx86dvd/System/Library/Extensions rm -R /Volumes/osx86dvd/System/Installation/Packages/.packages rm -rf /Volumes/osx86dvd/System/Library/CoreServices/boot.efi rm -rf /Volumes/osx86dvd/System/Library/PrivateFrameworks/MediaKit.framework echo Deleted old boot files echo Deleted old Bless echo Deleted unnecessary extensions #Move Necessary Files cpfix mach_kernel /Volumes/osx86dvd/mach_kernel cpfix Bless /Volumes/osx86dvd/usr/sbin/Bless cpfix i386 /Volumes/osx86dvd/usr/standalone/i386 cpfix translate /Volumes/osx86dvd/usr/libexec/oah/translate cpfix translated /Volumes/osx86dvd/usr/libexec/oah/translated cpfix Extensions.mkext /Volumes/osx86dvd/System/Library/Extensions.mkext cpfix ATSServer /Volumes/osx86dvd/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Support/ATSServer cpfix mds /Volumes/osx86dvd/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Support/mds cpfix diskimages-helper /Volumes/osx86dvd/System/Library/PrivateFrameworks/DiskImages.framework/Versions/A/Resources/diskimages-helper cpfi postflight /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg/Contents/Resources/postflight cpfix osinstall.dist /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg/Contents/osinstall.dist cpfix Extensions /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg/Contents/Resources/Extensions cpfix MediaKit.framework /Volumes/osx86dvd/System/Library/PrivateFrameworks/MediaKit.framework echo All Patches Applied #Generate Bootable ISO MKISOFS="$APDIR"/resources/mkisofs VOLNAME="osx86dvd" MKSIOFS_QUIET= HDIUTIL_QUIET= I386ISO=/tmp/i386booter.iso MASTERCD="$APDIR"/leopard.iso MSTRCDMNTD=/Volumes/osx86dvd/ # This give's you a DVD-R sized Disc Image SIZE="4481M" # The following can be anywhere you like its the the output image CDDMG=/Users/"$USER"/N.O.R.A.D.10.5.9a303.iso mkdir -p /tmp/i386 cp $MSTRCDMNTD/usr/standalone/i386/* /tmp/i386/ cd /tmp/i386 #"$MKISOFS" -R -V "$VOLNAME" -no-emul-boot -T -J -c boot.cat -b cdboot -hide-joliet-trans-tbl $MKISOFS_QUIET -o "$I386ISO" . "$MKISOFS" -V "$VOLNAME" -no-emul-boot -boot-load-size 4 -c boot.cat -b cdboot $MKISOFS_QUIET -o "$I386ISO" . sectors=`du "$I386ISO" | tail -1 | awk '{print $1}'` # create a bootable image and remove any previous copies cd "$MSTRCDMNTD" if [ -f "$CDDMG" -o -f "$CDDMG".dmg ]; then rm -f "$CDDMG" "$CDDMG".dmg fi hdiutil create $HDIUTIL_QUIET "$CDDMG".dmg -size $SIZE -layout NONE dev=`hdid -nomount "$CDDMG".dmg | tail -1 | awk '{print $1}'` rdev=`echo $dev | sed s/disk/rdisk/` pdisk $rdev -initialize blocks=`pdisk $rdev -dump | grep 2: | awk -F" " '{print $4}'` if [ "$QUIET" == "" ]; then pdisk $rdev -dump fi # create the partition on the image pdisk $rdev -createPartition "$VOLNAME" Apple_HFS $sectors `expr $blocks - $sectors` # figure out what slice the partition was created on slice=`pdisk $rdev -dump | grep "$VOLNAME" | awk -F: '{print $1}' | awk -F" " '{print $1}'` # copy the data onto the image dd if="$I386ISO" of=$rdev skip=64 seek=64 bs=512 newfs_hfs -v "$VOLNAME" ${rdev}s${slice} mkdir -p /mnt mount -t hfs -o perm ${dev}s${slice} /mnt ditto -rsrc "$MSTRCDMNTD" /mnt bless -folder /mnt/System/Library/CoreServices -bootinfo /mnt/usr/standalone/i386/boot -label "$VOLNAME" umount /mnt hdiutil eject $HDIUTIL_QUIET $dev cd /tmp/ diskutil eject /Volumes/osx86dvd #Update PreBinding update_prebinding -root /Volumes/osx86dvd -force #Rename to original image name diskutil rename /Volumes/Mac\ OS\ X\ Install\ DVD/ diskutil eject /Volumes/Mac\ OS\ X\ Install\ DVD/ #Rename image to actual extension type mv "$CDDMG".dmg "$CDDMG".iso hdiutil mount "$CDDMG".iso -readwrite -owners on diskutil rename /Volumes/osx86dvd Mac\ OS\ X\ Install\ Disc\ x86 hdiutil eject /Volumes/Mac\ OS\ X\ Install\ Disc\ x86 #Remove tempdisk & other dirs since they are useless now rm -rf /Users/"$USER"/Desktop/Auto-Patch/leopard.iso rm -rf /tmp rm -rf /mnt