Jump to content

OS X kernelcache patcher


1 post in this topic

Recommended Posts

Hi everyone  :)

 

Maybe my idea is interesting and helpful for someone.
We'll see. So, this is my first shell script. It create a patched OS X kernelcache.
You can use the new kernelcache to modify a Recovery HD, customize your own OS X Install USB etc. See code below.

#!/bin/sh
#
# Script-Name: 			OS X kernelcache patcher
# Author: 			tamta
# Release Date:			2014-02-01
# Release Version:		1.1
# Task / Purpose:		Create a patched OS X kernelcache. You can use them to modify a Recovery HD,
#				customize your own OS X Install USB etc.
# Sytem Requirements:		Running Mac OS X on a Virtual Machine, Hackintosh-PC etc.
# Other Requirements:		Original Install OS X xxxxxx.app from Apple AppStore, FakeSMC.kext and 1,50 GB
#				free space on harddisk
# Tested OS:			OS X Mountain Lion, OS X Mavericks
# Tested on:			Virtual Machine
#
###############################################################################################################
######################################## Attention: Don't edit lines! #########################################
###############################################################################################################
######################## The script works not correctly when you edit the lines below! ########################
###############################################################################################################
clear;
echo
echo ==========================================================================================================
echo ===================== This script create a patched OS X kernelcache. You can use them ====================
echo ==================== to modify a Recovery HD, customize your own OS X Install USB etc. ===================
echo ============== Sytem Requirements: Running Mac OS X on a Virtual Machine, Hackintosh-PC etc. =============
echo ==================== Other Requirements: Original Install OS X xxxxxx.app from Apple =====================
echo ======================= AppStore, FakeSMC.kext and 1,50 GB free space on harddisk ========================
echo ==========================================================================================================
echo
echo
echo ==========================================================================================================
echo ======= Please drag in your Install OS X xxxxxx.app or type the full path to them and press Enter. ======= 
echo ==========================================================================================================
echo
echo
read DMG
echo
if [ -z "$DMG" ]; then
	echo
	echo "None Install OS X xxxxxx.app selected or found!"
	echo
	exit
elif [ ! -d "$DMG/Contents/SharedSupport" ]; then
	echo
	echo "None Install OS X xxxxxx.app selected or found!"
	echo
	exit
fi
echo
echo ==========================================================================================================
echo ============ Please drag in your FakeSMC.kext or type the full path to them and press Enter. ============= 
echo ==========================================================================================================
echo
echo
read FILE
echo
if [ -z "$FILE" ]; then
	echo
	echo "None FakeSMC.kext selected or found!"
	echo
	exit
elif [ ! -x "$FILE/Contents/MacOS/FakeSMC" ]; then
	echo
	echo "None FakeSMC.kext selected or found!"
	echo
	exit
fi
###############################################################################################################
######################################## Attention: Don't edit lines! #########################################
###############################################################################################################
######################## The script works not correctly when you edit the lines below! ########################
###############################################################################################################
echo
echo ==========================================================================================================
echo ============================== Starting Process. This may take few minutes. ==============================
echo ==========================================================================================================
echo ============================= Please enter your User-password when prompted. =============================
echo ==========================================================================================================
echo
DMG1=$DMG/Contents/SharedSupport/InstallESD.dmg
DMG2=/Volumes/Mac\ OS\ X\ Install\ ESD/BaseSystem.dmg
DMG3=/Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg
echo
echo Mount InstallESD.dmg
echo
sudo hdiutil attach "$DMG1" -noverify -nobrowse
echo
echo
echo Mount BaseSystem.dmg
echo
if [ -s "$DMG2" ]; then
	hdiutil attach "$DMG2" -noverify -nobrowse
	S1=/Volumes/Mac\ OS\ X\ Install\ ESD
	S2=/Volumes/Mac\ OS\ X\ Base\ System
	N1=Mac\ OS\ X\ Base\ System
	N2=Mac\ OS\ X\ Base\ System/System/Library/Extensions
	PKG=/Volumes/Mac\ OS\ X\ Install\ ESD/Packages/BaseSystemBinaries.pkg
fi
if [ -s "$DMG3" ]; then
	hdiutil attach "$DMG3" -noverify -nobrowse
	S1=/Volumes/OS\ X\ Install\ ESD
	S2=/Volumes/OS\ X\ Base\ System
	N1=OS\ X\ Base\ System
	N2=OS\ X\ Base\ System/System/Library/Extensions
	PKG=/Volumes/OS\ X\ Install\ ESD/Packages/BaseSystemBinaries.pkg
fi
echo
echo
echo Create tmp-folder on Desktop.
mkdir ~/Desktop/tmp
echo
echo
echo Create "$N1" directory in tmp-folder on Desktop.
mkdir ~/Desktop/tmp/"$N1"
echo
echo
echo Copy contents of "$S2" to "$N1" directory in tmp-folder on Desktop.
sudo ditto "$S2" ~/Desktop/tmp/"$N1"
echo
echo
echo Copy FakeSMC.kext to "$N2" in tmp-folder on Desktop.
sudo cp -r "$FILE" ~/Desktop/tmp/"$N2"
echo
echo
echo Assign proper ownership to copied FakeSMC.kext.
sudo chown -R 0:0 ~/Desktop/tmp/"$N2"/FakeSMC.kext
echo
echo
echo Copy mach_kernel from BaseSystemBinaries.pkg to tmp-folder on the Desktop.
pkgutil --expand "$PKG" ~/Desktop/tmp/BaseSystemBinaries
tar -xf ~/Desktop/tmp/BaseSystemBinaries/Payload mach_kernel
mv mach_kernel ~/Desktop/tmp
echo
echo
echo Create a new kernelcache on Desktop.
echo
kextcache -volume-root ~/Desktop/tmp/"$N1" -kernel ~/Desktop/tmp/mach_kernel -prelinked-kernel ~/Desktop/kernelcache -l -n ~/Desktop/tmp/"$N2"
echo
echo
echo Unmount "$S2"
echo
hdiutil detach "$S2"
echo
echo
echo Unmount "$S1"
echo
hdiutil detach "$S1"
echo
echo
echo Remove all temporary files, directories and folders from Desktop.
sudo rm -rf ~/Desktop/tmp
echo
echo
echo All done!
echo
echo

I do not know if it helps someone, but I could with patched kernelcache both create an OS X Install USB for
Clean-Install via Command-Line as the newly created Recovery HD on the virtual machine bring to run.
Just try it and send a feedback. :yes:  Sorry for my bad english.  ;) 

Well then, see you later.  :wink_anim:

Link to comment
Share on other sites

 Share

×
×
  • Create New...