All pastes #792554 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-11-21 14:52 UTC
rendered paste body
#!/bin/sh
clear
echo "####################################################################################"
echo "###                                                                              ###"
echo "###   This script will modify your stock DVD so OS X Leopard                     ###"
echo "###   can be installed on a non-mac Intel PC                                     ###"
echo "###                                                                              ###"
echo "###   Backed up only files :                                                     ###"
echo "###   ======================                                                     ###"
echo "###   AppleIntelCPUPowermanagement.kext, AppleEFIRuntime.kext, boot.efi          ###"
echo "###                                                                              ###"
echo "###   Backed up and replaced files :                                             ###"
echo "###   ==============================                                             ###"
echo "###   OSInstall.mpkg, AppleSMBios.kext, AppleHDA.kext, IONetworkingFamily.kext   ###"
echo "###   GeForce.kext, NVDAResman.kext, NVDANV50Hal.kext                            ###"
echo "###   i386 folder, bless, minibless                                              ###"
echo "###                                                                              ###"
echo "###   Added files :                                                              ###"
echo "###   =============                                                              ###"
echo "###   ALCinject.kext, NVinject.kext, dsmos.kext                                  ###"
echo "###                                                                              ###"
echo "####################################################################################"
echo "###                                                                              ###"
echo "###   You may CANCEL this script within 15 seconds pressing (^C)                 ###"
echo "###                                                                              ###"
echo "####################################################################################"
echo ""
echo

##### OFFERING TO CANCEL THE SCRIPT WITHIN 10 SECONDS #####

t=10

while [ "$t" != -1 ]
do
	if [ "$t" = "0" ]; then
		printf "Go !"
	else
		printf "$t s... "
	fi
	sleep 1
	t=$(expr $t - 1)
done

clear

echo
echo "#######################################"
echo "###                                 ###"
echo "###   Script will now proceed       ###"
echo "###                                 ###"
echo "#######################################"
echo ""

##### CHECKING INSTALL PARTITION AND ENABLING OWNERS #####

echo
echo "### Checking target Install Partition is present"

if [ ! -d /Volumes/Install_DVD/ ]; then
	if [ -d /Volumes/Mac\ OS\ X\ Install\ DVD/ ]; then
		echo
		echo "### ERROR : SCRIPT REQUIREMENT NOT MATCHED :"
		echo
		echo "    Target install Partition : \"/Volumes/Install_DVD/\" not found !"
		echo "    A partition named \"Mac OS X Install DVD\" has been detected though,"
		echo '    Do you want the script to remane it to \"Install_DVD\" : (y/n) ? \c'; read choice
		if [ "$choice" = "y" ]; then
			echo
			echo "### Renaming found Partition to : \"/Volumes/Install_DVD\""
			diskutil rename /Volumes/Mac\ OS\ X\ Install\ DVD/ Install_DVD
			sleep 2
		else
			echo
			echo "### WARNING : SCRIPT CANCELED BY USER :"
			echo
			echo "    Target install Partition : \"/Volumes/Install_DVD/\" not found !"
			echo "    A partition named \"Mac OS X Install DVD\" has been detected though,"
			echo "    If \"Mac OS X Install DVD\" is the partition you want to use :"
			echo
			echo "    1. Rename it to \"Install_DVD\","
			echo "    2. Then restart this script."
			echo
			exit 0
		fi
	else
		echo
		echo "### FAILURE : SCRIPT CANNOT CONTINUE"
		echo
		echo "    Target Install Partition : \"/Volumes/Install_DVD/\" not found !"
		echo
		echo "    1. Restore original DVD to a partition,"
		echo "    2. Rename it to \"Install_DVD\","
		echo "    3. Restart this script."
		echo
		exit 0
	fi
fi

echo
echo "### Enabling \"Owners\" on Install Partition"
vsdbutil -a /Volumes/Install_DVD/

##### SETTING UP VARIABLES AND FUNCTION #####

APDIR=/Users/oki/Desktop
TARGET=/Volumes/Install_DVD
mkdir $TARGET/System/Library/Extensions-ORIG

cpfix () {
    cp -Rf $1 $2
    chown -R root:wheel $2
    chmod -R 755 $2
}

##### BACKING UP AND REPLACING PACKAGES AND FILES #####

cd $APDIR/Macintosh/

echo
echo "### Backing up and Replacing : \"OSInstall.mpkg\""

mv $TARGET/System/Installation/Packages/OSInstall.mpkg $TARGET/System/Installation/Packages/OSInstall.mpkg.ORIG
cpfix packages/OSInstall.mpkg $TARGET/System/Installation/Packages/OSInstall.mpkg

if [ -e $TARGET/System/Installation/Packages/OSInstall.mpkg ] &&  [ -e $TARGET/System/Installation/Packages/OSInstall.mpkg.ORIG ]; then
	echo "    Success : File \"OSInstall.mpkg\" has been replaced"
else
	echo "    Failure : There has been a problem replacing file \"OSInstall.mpkg\""
fi

echo
echo "### Backing up and replacing : \"minibless\""

mv $TARGET/"Install Mac OS X.app/Contents/Resources/minibless" $TARGET/"Install Mac OS X.app/Contents/Resources/minibless.ORIG"
cp -Rf boot/minibless "/Volumes/Install_DVD/Install Mac OS X.app/Contents/Resources/"
chmod 755 $TARGET/"Install Mac OS X.app/Contents/Resources/minibless"
chown root:wheel $TARGET/"Install Mac OS X.app/Contents/Resources/minibless"

if [ -e $TARGET/"Install Mac OS X.app/Contents/Resources/minibless" ] && [ -e $TARGET/"Install Mac OS X.app/Contents/Resources/minibless.ORIG" ]; then
	echo "    Success : File \"minibless\" has been replaced"
else
	echo "    Failure : There has been a problem replacing file \"minibless\""
fi

echo
echo "### Backing up and replacing : \"bless\""

mv $TARGET/usr/sbin/bless $TARGET/usr/sbin/bless.ORIG
cpfix boot/bless $TARGET/usr/sbin/bless

if [ -e $TARGET/usr/sbin/bless ] && [ -e $TARGET/usr/sbin/bless.ORIG ]; then
	echo "    Success : File \"bless\" has been replaced"
else
	echo "    Failure : There has been a problem replacing file \"bless\""
fi


echo
echo "### Backing up and replacing : \"i386\" files"

mv $TARGET/usr/standalone/i386 $TARGET/usr/standalone/i386.ORIG
cpfix boot/i386-efi $TARGET/usr/standalone/i386

if [ -e $TARGET/usr/standalone/i386 ] && [ -e $TARGET/usr/standalone/i386.ORIG ]; then
	echo "    Success : Folder \"i386\" has been replaced"
else
	echo "    Failure : There has been a problem replacing folder \"i386\""
fi

echo
echo "### Backing up : \"boot.efi\""

chflags -R nouchg $TARGET/System/Library/CoreServices/boot.efi
mv $TARGET/System/Library/CoreServices/boot.efi $TARGET/System/Library/CoreServices/boot.efi.ORIG

if [ -e $TARGET/System/Library/CoreServices/boot.efi.ORIG ]; then
	echo "    Success : File \"boot.efi\" has been renamed to \"boot.efi.ORIG\""
else
	echo "    Failure : There has been a problem renaming file \"boot.efi\" to \"boot.efi.ORIG\""
fi

##### BACKING UP AND REPLACING EXTENSIONS #####

cd $APDIR/Macintosh/kexts/

echo
echo "### Backing up and Replacing Extensions"
echo

i1=0
i2=0
i3=0

for kext in *.kext
do
	case $kext in
		"ALCinject.kext" | "NVinject.kext" | "dsmos.kext") # Will be added
			cpfix $kext $TARGET/System/Library/Extensions/$kext;
			if [ -e $TARGET/System/Library/Extensions/$kext ]; then
				echo "    Success : Extension \""$kext"\" has been added"
				i1=$(expr $i1 + 1)
			else
				echo "    Failure : There has been a problem adding extension \""$kext"\""
			fi;;
		"AppleIntelCPUPowerManagement.kext") # Will be moved (might be required depending on the kernel used : | "AppleEFIRuntime.kext")
			mv $TARGET/System/Library/Extensions/$kext $TARGET/System/Library/Extensions-ORIG/;
			if [ ! -e $TARGET/System/Library/Extensions/$kext ] && [ -e $TARGET/System/Library/Extensions-ORIG/$kext ]; then
				echo "    Success : Extension \""$kext"\" has been moved"
				i2=$(expr $i2 + 1)
			else
				echo "    Failure : There has been a problem moving extension \""$kext"\""
			fi;;
		*) # will be replaced
			mv $TARGET/System/Library/Extensions/$kext $TARGET/System/Library/Extensions-ORIG/;
			cpfix $kext $TARGET/System/Library/Extensions/$kext;
			if [ -e $TARGET/System/Library/Extensions/$kext ] && [ -e $TARGET/System/Library/Extensions-ORIG/$kext ]; then
				echo "    Success : Extension \""$kext"\" has been replaced"
				i3=$(expr $i3 + 1)
			else
				echo "    Failure : There has been a problem replacing extension \""$kext"\""
			fi;;
	esac
done

echo
echo "### Extensions added : " $i1
echo "### Extensions moved : " $i2
echo "### Extensions replaced : " $i3
echo "### Total Extensions processed : " $(expr $i1 + $i2 + $i3)

##### REMOVING EXTENSIONS CACHE #####

echo
echo "### Removing \"Extensions.mkext\""

rm $TARGET/System/Library/Extensions.mkext

if [ ! -e $TARGET/System/Library/Extensions.mkext ]; then
	echo "    Success : \"Extensions.mkext\" has been removed"
else
	echo "    Failure : There has been a problem removing \"Extensions.mkext\""
fi

echo
echo "####################################################"
echo "###                                              ###"
echo "###                 All Done !!                  ###"
echo "###                                              ###"
echo "###   Please check for reported errors if any.   ###"
echo "###                                              ###"
echo "####################################################"
echo