All pastes #179115 Raw Edit

Untitled

public text v1 · immutable
#179115 ·published 2006-09-21 22:56 UTC
rendered paste body
#!/bin/sh

#Set this to the directory of the autopatch dir
APDIR="/Users/osx/Desktop/1/"

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 ./place-dmg-in-here/macosx_10.4.4_dvd.dmg -format UDTO -o ./place-dmg-in-here/tempdisk.iso

#Mount new iso readwrite
hdiutil attach -readwrite ./place-dmg-in-here/tempdisk.iso.cdr -owners on

#Rename image
diskutil rename /Volumes/Mac\ OS\ X\ Install\ Disc\ 1 osx86dvd

#Delete Xcode to Free Space for Standard DVD Burn
rm -rf /Volumes/osx86dvd/Xcode\ Tools
echo Deleted Xcode

#Remove old files
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/OSInstall.mpkg
rm -R /Volumes/osx86dvd/System/Installation/Packages/.packages
rm -rf /Volumes/osx86dvd/System/Library/CoreServices/boot.efi
echo Deleted old boot files
echo Deleted old Bless
echo Deleted unnecessary extensions

#Move Necessary Files
cpfix mach_kernel /Volumes/osx86dvd/mach_kernel

cpfix rc.cdrom /Volumes/osx86dvd/etc/rc.cdrom

cpfix Disk\ Utility.app /Volumes/osx86dvd/Applications/Utilities/Disk\ Utility.app

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

cpfix OSInstall.mpkg /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg

cpfix rc /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg/Contents/Resources/rc

cpfix rc.shutdown /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg/Contents/Resources/rc.shutdown

cpfix OSInstall.dist /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg/Contents/OSInstall.dist

cpfix postflight /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg/Contents/Resources/postflight

cpfix Extensions /Volumes/osx86dvd/System/Installation/Packages/OSInstall.mpkg/Contents/Resources/Extensions

cpfix 10.4.7.Combo.update.Intel.Decryption.With.New.System.Protection.pkg /Volumes/osx86dvd/System/Installation/Packages/10.4.7.Combo.update.Intel.Decryption.With.New.System.Protection.pkg

cpfix 10.4.7.Intel.SSE2.pkg /Volumes/osx86dvd/System/Installation/Packages/10.4.7.Intel.SSE2.pkg

cpfix 10.4.7.Intel.SSE3.pkg /Volumes/osx86dvd/System/Installation/Packages/10.4.7.Intel.SSE3.pkg

cpfix JaS.10.4.7.Radeon.Xseries.Support.pkg /Volumes/osx86dvd/System/Installation/Packages/JaS.10.4.7.Radeon.Xseries.Support.pkg

cpfix ApplicationsServer.pkg /Volumes/osx86dvd/System/Installation/Packages/

cpfix QuickTimeStreamingServer.pkg /Volumes/osx86dvd/System/Installation/Packages/

cpfix ServerAdminTools.pkg /Volumes/osx86dvd/System/Installation/Packages/

cpfix ServerEssentials.pkg /Volumes/osx86dvd/System/Installation/Packages/

cpfix ServerSetup.pkg /Volumes/osx86dvd/System/Installation/Packages/

echo All Patches Applied

#Generate Bootable ISO
MKISOFS="$APDIR"/resources/mkisofs
VOLNAME="osx86dvd"
MKSIOFS_QUIET=
HDIUTIL_QUIET=
I386ISO=/tmp/i386booter.iso
MASTERCD="$APDIR"/place-dmg-in-here/tempdisk.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="$APDIR"/Burn-this-iso/BurnThisImage

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/Mac\ OS\ X\ Install\ Disc\ 1

#Update PreBinding
update_prebinding -root /Volumes/osx86dvd -force

#Rename to original image name
diskutil rename /Volumes/osx86dvd Mac\ OS\ X\ Install\ Disc\ 1
diskutil eject /Volumes/Mac\ OS\ X\ Install\ Disc\ 1

#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"/place-dmg-in-here/tempdisk.iso.cdr
rm -rf /tmp
rm -rf /mnt