#!/bin/sh echo ################################################################################### echo All files are on the desktop in different directories echo Make sure you have : echo "patch-it.sh" + "post!install!patch.sh" on the desktop echo "files" directory + "extensions" directory inside files + 4 kext inside extensions echo "ressources" directory + "mkisofs" file inside of it echo chmod 755 = "patch-it.sh" + "post_install_patch.sh" + "mkisofs" echo ################################################################################### echo Procedure will continue in 10 seconds ... echo You might want to CTRL-Z to abort this script ... sleep 10 echo Building OSx86 Leopard 9A466 NOW !! echo *********************************** APDIR=/Users/oki/Desktop DMG="/Users/oki/Desktop/9A466.dmg" cpfix () { cp -r ./files/$1 $2 chown -R root:wheel $2 chmod -R 755 $2 } cd $APDIR echo Converting DMG to editable image... hdiutil convert $DMG -format UDTO -o $APDIR/leopard.iso echo Mounting new ISO read-write... hdiutil attach -readwrite $APDIR/leopard.iso.cdr -owners on echo Waiting for Leopard boot.iso to be mounted... sleep 10 echo showing /Volumes/ directory content before renaming... ls -lsa /Volumes/ echo Renaming image... diskutil rename /Volumes/Lepoard\ Boot/ osx86dvd echo showing /Volumes/ directory content after renaiming... ls -lsa /Volumes/ ##### Remove old files ##### echo Deleting Xcode to free space for standard DVD burn... rm -rf /Volumes/osx86dvd/Xcode\ Tools echo Removing old files... rm -rf "/Volumes/osx86dvd/Install Mac OS X.app/Contents/Resources/minibless" # Remove printer packages rm -rf /Volumes/osx86dvd/System/Installation/Packages/*Printer* rm -rf /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg # Kernel rm -rf /Volumes/osx86dvd/mach_kernel rm -rf /Volumes/osx86dvd/mach.sys # Boot-related things rm -rf /Volumes/osx86dvd/usr/standalone/i386 rm -rf /Volumes/osx86dvd/usr/sbin/bless rm -rf /Volumes/osx86dvd/System/Library/CoreServices/boot.efi # Extensions rm -rf /Volumes/osx86dvd/System/Library/Extensions.mkext rm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleSMBIOS.kext rm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleACPIPlatform.kext rm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleIntelIntegratedFramebuffer.kext rm -rf /Volumes/osx86dvd/System/Library/Extensions/Natit.kext # Boot speed-up? rm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleHWSensor.kext # Needed for kernels without power_management_init called rm -rf /Volumes/osx86dvd/System/Library/Extensions/AppleIntelCPUPowerManagement.kext ##### Move necessary files ##### # Replacement minibless 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.mpkg cpfix OSInstall.mpkg /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg # New boot-related files cpfix i386 /Volumes/osx86dvd/usr/standalone/i386 cpfix bless /Volumes/osx86dvd/usr/sbin/bless cpfix mach_kernel /Volumes/osx86dvd/mach_kernel # New extensions from patch for kext in `ls files/Extensions`; do cpfix Extensions/$kext /Volumes/osx86dvd/System/Library/Extensions/ done # Kexts added by previous command #AppleAC97Audio.kext #AppleACPIPlatform.kext #AppleAHCIPort.kext #AppleAzaliaAudio.kext #AppleIntelIntegratedFramebuffer.kext #ApplePS2Controller.kext #AppleSMBIOS.kext #AppleVIA.kext #AppleVIAATA.kext #IOAHCIFamily.kext #IOATAFamily.kext # ICH2-ICH6 ATA Fix cpfix Info.plist /Volumes/osx86dvd/System/Library/Extensions/IOATAFamily.kext/Contents/PlugIns/AppleIntelPIIXATA.kext/Contents/Info.plist echo 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/mkisofs VOLNAME="osx86dvd" MKSIOFS_QUIET= HDIUTIL_QUIET= I386ISO=/tmp/i386/booter.iso MASTERCD="$APDIR"/leopard.iso MSTRCDMNTD=/Volumes/osx86dvd/ # This gives you a DVD-R sized disc image SIZE="4481M" # The following can be anywhere you like its the the output image CDDMG="$APDIR"/BurnThisImage mkdir -p /tmp/i386 cp $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 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/ # Update prebinding update_prebinding -root /Volumes/osx86dvd -force # Rename to original image name #diskutil rename /Volumes/osx86dvd Mac\ OS\ X\ Install\ DVD #hdiutil eject /Volumes/Mac\ OS\ X\ Install\ DVD diskutil rename /Volumes/osx86dvd Leopard\ boot hdiutil eject /Volumes/Leopard\ boot # 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 diskutil rename /Volumes/osx86dvd Leopard\ boot\ x86 hdiutil eject /Volumes/Leopard\ boot\ x86 # Remove tempdisk & other dirs since they are useless now rm -rf "$APDIR"/leopard.iso.cdr rm -rf /mnt