All pastes #673609 Raw Edit

9A499

public text v1 · immutable
#673609 ·published 2007-08-28 15:43 UTC
rendered paste body
#!/bin/sh

APDIR=`pwd`
DMG="/Volumes/TigerHD/Users/ticklemonster/Documents/leopard_client_9a527.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 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/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

# 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 
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.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
for kext in `ls files/Extensions`; do
	cpfix Extensions/$kext /Volumes/osx86dvd/System/Library/Extensions/
done

# 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/i386booter.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

# 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 "$APDIR"/leopard.iso.cdr
#rm -rf /mnt