Build CM10 from scratch

If you want compile your personal build of CM10 from scratch (gerrit source) here you are in the right place!


This guide is for expert people only! You must be able to solve some little differenes between each linux disto, here I'm using Ubuntu 12.04.1, and differences between terminals too.

If you dont understand what I'm saying then this is not the place for you.

Operating System

First step is having a fully functional linux distro. You can choose what you prefer, I'm using ubuntu and I write commands for it. You can use OSX too, as I know, but I've completely no idea how, I never had a Mac.
Well, talking about linux, you need a 64bit distribution, so if you have an old 32 bit processor youn cannot go ahead. 

To check which version do you have, type in a shell

uname -a

If the results include "x86_64" you're ok.

Required Packages

You need to install some little packages, to be able to proceed, you can do this with your favorite package manager:

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev:i386 g++-multilib mingw32 openjdk-6-jdk pngcrush schedtool tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386

Some systems need some trick to install all this package, is your care to check this process completed correctly and fix eventually problems.

Install "repo"

Repo is the program that handles synchronization between our pc and the repository, in this case Cyanogen's one. To install do:

mkdir -p ~/bin
curl > ~/bin/repo
chmod a+x ~/bin/repo

So we have downloaded and added executables flag to it. Now we need a folder to store locally the sources, you can put it everywhere, but to be coherent with other guides, I do:

mkdir -p ~/android/system/

If you have a solid state disk SSD, you can choose to store this folder there. You can have a great speedup, you can save up to 1 hour in build time!

Repository initialization

Well, now it's time to initialize our source folder to correctly sync with repository:

cd ~/android/system/
repo init -u git:// -b jellybean

Nota: Maybe the repo command is not recognized. In this case yuo can restart the shell or te machine.


Now is download time! Write this command and get a fresh beer, you have to download several GB of data, please wait.

repo sync -j16

The "-j16" switch may be modified as you want, is the number of concurrent thread downloading from repo. 16 is my value, for a 100Mbit connection, maybe you can decrease a little to match your line speed. Someone uses 8 threads for an 8Mbit ADSL line...

Synchronization of specific repository

This only needs to be done the first time after syncing the repository. If this step has been completed, skip it.

To preserve bandwidth and time, repo sync only generic files that are common for every device. We need to sync now specific file, related to our device.

source build/ && breakfast maguro

In this case I'm building for my Galaxy Nexus, GSM edition, his name is "maguro". You have to insert the name of your device. You should know it, otherwise you can see to find yours.

This command is time consuming too, is fetching many other data, so, as have to wait!

Copy proprietary files.

For correct operation you must copy some proprietary files from the device. You need a fully functional CM10 release installed on your device.

Is neccessary to have installed and confiured Android SDK in the linux machine. For more details, here is the official wiki page from Cyanogen team:

Connect the device and, if all goes right, you can see it with:

adb devices

If you have more than one device connected, please, disconnect all but that you need.

When CM10 develop is finished we'll have a script that extracts files for us:

cd ~/android/system/device/samsung/maguro/

This script is not available now, so I've written a custom one, that works with my Galaxy Nexus. If you want to build for another device, you have to modify it. I reccomand to see how is this script in the CM9 branch for your device.

Note: You have to check that all copy process  terminate properly

Download proprietary drivers.

If your device manufacture provides some proprietary drivers, this is the right time to fetch it.
Regarding the Google (Nexus) devices, download address is:

You have to download and extract here:


Now execute all extracted files, to add drivers in the right place.

Download precompiled files.

There are some others files needed, like the toolchain, including GCC, to compile code.


Another small wait time and we're ready!


Great, we're ready to build!

The build process takes some hours, so be patient. My notebook, i7 740QM, takes more than two hours!

cd ~/android/system/
source build/ && brunch maguro


When is ready, we can find the result here:


This is the package to be flashed in recovery mode.

There is no Gapps included, so you have to find one yourself.


If you want to update your build, you have to do only this:

cd ~/android/system/
repo sync
source build/ && brunch maguro

You'll have an updated .zip package, but the name and the version is not updated.