rendered paste body#!/bin/shAPDIR=`pwd`DMG="/Users/user/Desktop/9A599.dmg"cpfix () { cp -r ./files/$1 $2 chown -R root:wheel $2 chmod -R 755 $2}cd $APDIRecho Converting DMG to editable image...hdiutil convert $DMG -format UDTO -o $APDIR/leopard.isoecho Mounting new ISO read-write...hdiutil attach -readwrite $APDIR/leopard.iso.cdr -owners onecho Renaming image...diskutil rename /Volumes/Mac\ OS\ X\ Install\ DVD/ osx86dvd##### Remove old files #####echo Deleting Xcode to free space for standard DVD burn...rm -rf /Volumes/osx86dvd/Optional\ Installs/Xcode\ Tools/echo Removing old files...rm -rf "/Volumes/osx86dvd/Install Mac OS X.app/Contents/Resources/minibless"# Remove printer packagesrm -rf /Volumes/osx86dvd/System/Installation/Packages/*Printer*rm -rf /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg# Kernelrm -rf /Volumes/osx86dvd/mach_kernelrm -rf /Volumes/osx86dvd/mach.sys# Boot-related thingsrm -rf /Volumes/osx86dvd/usr/standalone/i386rm -rf /Volumes/osx86dvd/usr/sbin/blessrm -rf /Volumes/osx86dvd/System/Library/CoreServices/boot.efi# Extensionsrm -rf /Volumes/osx86dvd/System/Library/Extensions.mkextrm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleSMBIOS.kextrm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleACPIPlatform.kextrm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleIntelIntegratedFramebuffer.kextrm -rf /Volumes/osx86dvd/System/Library/Extensions/IOHDIXController.kextrm -rf /Volumes/osx86dvd/System/Library/Extensions/IOATAFamily.kextrm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleAHCIPort.kext# Boot speed-up?rm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleHWSensor.kext# Needed for kernels without power_management_init calledrm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleIntelCPUPowerManagement.kext rm -rf /Volumes/osx86dvd/System/Library/LaunchDaemons/ossmgr.plist##### Move necessary files #####cp files/minibless "/Volumes/osx86dvd/Install Mac OS X.app/Contents/Resources/minibless"chown root:wheel "/Volumes/osx86dvd/Install Mac OS X.app/Contents/Resources/minibless"chmod 755 "/Volumes/osx86dvd/Install Mac OS X.app/Contents/Resources/minibless"# Replacement OSInstall.mpkgcpfix OSInstall.mpkg /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg# New boot-related filescpfix i386 /Volumes/osx86dvd/usr/standalone/i386cpfix bless /Volumes/osx86dvd/usr/sbin/blesscpfix mach_kernel /Volumes/osx86dvd/mach_kernel# New extensionsfor kext in `ls files/Extensions`; docpfix Extensions/$kext /Volumes/osx86dvd/System/Library/Extensions/doneecho All patches applied!echo Creating bootable DVD in 10 seconds...echo You might want to CTRL-Z and inspect /Volumes/osx86dev now.sleep 10##### Generate Bootable ISO #####MKISOFS="$APDIR"/resources/mkisofsVOLNAME="osx86dvd"MKSIOFS_QUIET=HDIUTIL_QUIET=I386ISO=/tmp/i386booter.isoMASTERCD="$APDIR"/leopard.isoMSTRCDMNTD=/Volumes/osx86dvd/# This gives you a DVD-R sized disc imageSIZE="4481M"# The following can be anywhere you like its the the output imageCDDMG="$APDIR"/BurnThisImagemkdir -p /tmp/i386cp $MSTRCDMNTD/usr/standalone/i386/* /tmp/i386/cd /tmp/i386"$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 copiescd "$MSTRCDMNTD"if [ -f "$CDDMG" -o -f "$CDDMG".dmg ]; then rm -f "$CDDMG" "$CDDMG".dmgfihdiutil create $HDIUTIL_QUIET "$CDDMG".dmg -size $SIZE -layout NONEdev=`hdid -nomount "$CDDMG".dmg | tail -1 | awk '{print $1}'`rdev=`echo $dev | sed s/disk/rdisk/`pdisk $rdev -initializeblocks=`pdisk $rdev -dump | grep 2: | awk -F" " '{print $4}'`if [ "$QUIET" == "" ]; then pdisk $rdev -dumpfi# Create the partition on the imagepdisk $rdev -createPartition "$VOLNAME" Apple_HFS $sectors `expr $blocks - $sectors`# Figure out what slice the partition was created onslice=`pdisk $rdev -dump | grep "$VOLNAME" | awk -F: '{print $1}' | awk -F" " '{print $1}'`# Copy the data onto the imagedd if="$I386ISO" of=$rdev skip=64 seek=64 bs=512newfs_hfs -v "$VOLNAME" ${rdev}s${slice}mkdir -p /mntmount -t hfs -o perm ${dev}s${slice} /mntditto -rsrc "$MSTRCDMNTD" /mntbless -folder /mnt/System/Library/CoreServices -bootinfo /mnt/usr/standalone/i386/boot -label "$VOLNAME"umount /mnthdiutil eject $HDIUTIL_QUIET $devcd /tmp/# Update prebindingupdate_prebinding -root /Volumes/osx86dvd -force# Rename to original image namediskutil rename /Volumes/osx86dvd Mac\ OS\ X\ Install\ DVDhdiutil eject /Volumes/Mac\ OS\ X\ Install\ DVD# Rename image to actual extension typemv "$CDDMG".dmg "$CDDMG".isohdiutil mount "$CDDMG".iso -readwrite -owners ondiskutil rename /Volumes/osx86dvd Mac\ OS\ X\ Install\ Disc\ x86hdiutil eject /Volumes/Mac\ OS\ X\ Install\ Disc\ x86# Remove tempdisk & other dirs since they are useless nowrm -rf "$APDIR"/leopard.iso.cdr#rm -rf /mnt