Home » » How to Build your own CyanogenMod from Source

How to Build your own CyanogenMod from Source

Posted by Droid Firmware Flash on Saturday, June 14, 2014




WHAT YOU'LL NEED:

  • An already built CyanogenMod Zip for your device (Doesn't matter if it's a nightly or stable).
  • A decent computer running Linux or OS X (virtual box is acceptable too)
  • At least 35 GB of free space on your Hard Drive
  • Patience!!!

NOTICE:

This tutorial is intended for the more advanced users out there.  I'm already going to assume that you have Linux up and running and you're familiar with basic Linux and Android operations.  Also note that depending on your computer and internet speeds this could take anywhere from 5 hours (no less than that) to 5 days to complete.  You're going to be downloading over 15 GB in source code, which depending on your internet, could take awhile.  I have a 50Mbps high speed connection and it still took me 3-4 hours.  In addition, your computer hardware will determine how fast your compiling process will take.  Again, I have a Core i7 3770k along with 16GB of ram and it took 45min-1 hour.  So just be aware that this isn't a ten minute process.

STEP 1: SETTING UP BASHRC

 To make life easier, let's add bin as a path.  In a terminal window type in
sudo gedit ~/.bashrc
 At the very end of the file add the following:
export PATH=${PATH}:~/bin
In just a little bit we're going to be creating a bin directory, so it's helpful to do it now.

Hit save once your done, and close it.  Now in terminal type in
~/.bashrc
 This will re-load your bashrc. (Rebooting would do the same thing, but that's no fun).

STEP 2: PREPARING YOUR BUILD ENVIRONMENT

Alright, there are multiple things you're going to need to install before you can start cooking.  Simply copy and paste this into terminal.  (This was taken straight from Cyanogen wiki page)
    
sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-6-jre openjdk-6-jdk pngcrush schedtool libxml2 libxml2-utils xsltproc

And if you're running a 64 bit System, paste this into terminal as well:
 
g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib

STEP 3: DIRECTORIES

Alright, time to make some directories.  In your home folder, let's create a directory called bin.  That will hold the repo stuff.  For the actual source files let's create a directory called CM10.2 (You don't have to call it cm10.2, you can name it to whatever you want, just note that I'm always going to reference it as cm10.2 in this tutorial).  You can create these directories easily by typing the following in terminal:
mkdir -p ~/bin
mkdir -p ~/CM10.2


STEP 4: INSTALLING REPO

Now let's download the repo file and change its permissions so that we can execute it.  In terminal type in:    
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo <br />
chmod a+x ~/bin/repo

Step 5: Initialize the CM Source and Downloading the Source Code

Now it's time to initialize the source code to download.  In terminal change to your CM10.2 directory.  So type:
cd ~/CM10.2
Now we need to decide what version of cyanogenmod we want to get.  I'm going to go with 10.2 since I know there is source available for my device, but you can choose whichever build you like.  So type in:
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2
Just a quick note, if this is your first time using repo you might be prompted to type in your email address and name. Finally, when you're ready type in:
repo sync
This will begin long process of downloading over 15GB of source code.  This will take anywhere between 4 hours to 4 days depending on your internet speed.  Get that coffee ready!</p>
Note: If repo gets stuck or freezes during the download, just hit control + z to stop it, and type "repo sync" again.

STEP 6: PREBUILT APPS

Congratulations! You made it through one of the longest steps! Now you're half-way there. Now let's get the prebuilt apps.  In terminal type in the following:
cd ~/cm10.2/vendor/cm
./get-prebuilts

Cool. No Confirmation will appear so you'll just have to trust it happened.

STEP 7: DEVICE SPECIFIC CODE

Now it's time to prepare the device specific code. In terminal type the following:
cd ~/cm10.2
source build/envsetup.sh
breakfast m7spr (After breakfast you're typing in your device's name.  Look it up if you're not sure. I'm using a sprint htc one, so it's m7spr)

The device specific code will download.

STEP 8: EXTRACT PROPRIETARY BLOBS

In order to get the device specific files, you're going to need to have an already built CyanogenMod rom for your device.  Now this process can be accomplished through the actual device but I'm going to show your through the zip.  Make a new folder called original in your home folder, and extract the zip to that folder.
mkdir -p ~/original
Then in terminal type in the following commands:
cd ~/cm10.2/device/htc/m7spr
./extract-files.sh ~/original
Of course replace m7spr and cm10.2 with the appropriate device and zip you used.

Great! You're almost done.  According to the CyanongenMod wiki we can also turn on cache building to speed up subsequent builds after this one.  Type in:
export USE_CCACHE=1

STEP 9: STARTING THE BUILD

Now, the moment you have been waiting for.  It's time to start building your CM Rom. Type in the following:
croot
brunch m7spr
Again, replace m7spr with your device.  If you get any errors, here are some helpful tips taken right from wiki.cyanogenmod.org:
If the build doesn't start, try lunch and choose your device from the menu. If that doesn't work, try breakfast and choose from the menu. The command make m7att should then work. A second, bonus tip! If you get a command not found error for croot or brunch or lunch, be sure you've done the ". build/envsetup.sh”command in this Terminal session from the ~/cm10.2 directory

STEP 10: THAT'S IT!

Hopefully your build completed without errors.  If you had any errors refer to here if you have any trouble. Now the last thing to do is grab your newly built cyanogenmod zip.  Simply go into the out/target/product/m7spr folder and you should see your cyanogenmod zip.  From here you can flash it in recovery on your phone.  Hope you enjoyed and have fun!

This guide was compiled using the help from several sources:





0 comments:

Post a Comment

Popular Posts

Blog Archive

.comment-content a {display: none;}