Created
July 29, 2014 04:05
-
-
Save alvaromuir/cdb03dce75fa7838d232 to your computer and use it in GitHub Desktop.
Build xnu (Darwin) kernel script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
############################################# | |
# Builds the latest xnu (Darwin) kernel # | |
# create a directory to do this in first!!! # | |
# it cleans the downloaded files after # | |
# ya homie, @alvaromuir # | |
############################################# | |
export PATH="/usr/local/bin:$PATH" | |
CURL="curl -O " | |
# set dem variables, son! | |
DTRACE=dtrace-118.1 | |
AVAILVER=AvailabilityVersions-6 | |
KERNEL=xnu-2422.1.72 | |
echo "Checking for dtrace ..." | |
command -v dtrace >/dev/null 2>&1 || { | |
echo >&2 "dtrace required, but it's not installed. Installing now."; | |
$CURL http://www.opensource.apple.com/tarballs/dtrace/$DTRACE.tar.gz \ | |
&& tar xzf $DTRACE.tar.gz \ | |
&& cd $DTRACE \ | |
&& mkdir -p obj sym dst \ | |
&& xcodebuild install -target ctfconvert -target ctfdump -target ctfmerge \ | |
ARCHS="x86_64" SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym \ | |
DSTROOT=$PWD/dst \ | |
&& sudo ditto $PWD/dst/usr/local /usr/local \ | |
&& cd .. \ | |
&& echo "Cleaning up downloaded sources" \ | |
&& rm -rf $DTRACE* | |
} | |
echo "Checking for Availability Versions ..." | |
if [ ! -f `xcrun -sdk / -show-sdk-path`/usr/local/libexec/availability.pl ]; then | |
echo "Availability Versions required, but not installed. Installing now." | |
$CURL http://opensource.apple.com/tarballs/AvailabilityVersions/$AVAILVER.tar.gz \ | |
&& tar xzf $AVAILVER.tar.gz \ | |
&& cd $AVAILVER \ | |
&& mkdir -p dst \ | |
&& make install SRCROOT=$PWD DSTROOT=$PWD/dst \ | |
&& sudo ditto $PWD/dst/usr/local `xcrun -sdk / -show-sdk-path`/usr/local \ | |
&& cd .. \ | |
&& echo "Cleaning up downloaded sources" \ | |
&& rm -rf $AVAILVER* | |
fi | |
echo "Getting xnu kernel (Darwin) ..." | |
rm -rf $KERNEL* \ | |
&& $CURL http://opensource.apple.com/tarballs/xnu/$KERNEL.tar.gz \ | |
&& tar xzf $KERNEL.tar.gz \ | |
&& cd $KERNEL; | |
## revise MakeInc.def | |
if [ -f makedefs/MakeInc.def ]; then | |
sed -i"any_symbol" 's/-Werror//' makedefs/MakeInc.def; | |
fi | |
make TARGET_CONFIGS="release x86_64 default" SDKROOT=`xcrun -sdk / -show-sdk-path`; | |
cd .. \ | |
&& echo "Cleaning up downloaded sources" \ | |
&& rm -rf $KERNEL.tar.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment