Setup Ubuntu 13.10 for Building CyanogenMod

|

I run an ESXi whitebox at home. One of my VM's is solely for building CyanogenMod. Somehow, somehow, I manage to mess up the VM every once in awhile though. Here are the steps I take to setup a fresh Ubuntu 13.10 for building CyanogenMod.

Requirements

  • 64-bit processor and 64-bit Ubuntu. I use the server edition.
  • You need at least 30-40GB of free space for building CyanogenMod. I would recommend even more though so you can have a large ccache area. For me, I give the VM 8GB of memory and 100GB of space on a fast SSD.

Install the basic packages

The stock Ubuntu is pretty ....stock. You need some basic packages for building Android:

sudo apt-get install g++ make schedtool git gnupg flex bison \
    gperf build-essential zip curl libc6-dev \
    libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 \
    libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev \
    g++-multilib mingw32 tofrodos python-markdown libxml2-utils \
    xsltproc zlib1g-dev:i386
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 \
    /usr/lib/i386-linux-gnu/libGL.so

Reference: Google's Android Environment Setup page

Install Java6

OpenJDK causes problems as does Oracle's Java7. Stick with Oracle Java6 to keep things reliable.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer

Reference: Install Java via Ubuntu PPA

Install VMware tools (if this is a virtualized box)

If you are on a VMware virtualized machine, first select "Install VMware Tools" from vSphere or VMware Workstation and then run the following commands on your VM:

sudo mount /dev/cdrom /mnt
tar xzvf /mnt/VMwareTools-*.tar.gz
sudo ./vmware-install.pl

Answer the default for all questions expect "yes" to "Would you like to enable VMware automatic kernel modules?"

Check out CyanogenMod

The code below checks out CyanogenMod 11. If you want a difference version, change the names appropriately.

mkdir -p Android/cm-11.0
cd Android/cm-11.0
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
repo sync -j16

Setup ccache

Building Android is slow. It is massively slower if you don't have ccache enabled! Add the following lines to your ~/.profile:

export USE_CCACHE=1
export CCACHE_DIR=.ccache

Log out and log back in to get ~/.profile resourced. Then do the following to initialize the cache:

cd Android/cm-11.0
./prebuilts/misc/linux-x86/ccache/ccache -M 20G

Of course, replace the "20G" with however much space you want to give the cache.

Build CyanogenMod for your device

Of course, since I'm the maintainer of the AT&T Galaxy SII Skyrocket device for CyanogenMod, we will use that as an example. You will need to adjust the following instructions for your particular brand (e.g. sony or htc) and device.

First get the blobs for your device. Either run device///extract-files.sh or create Android/cm-11.0/.repo/local_manifests/local_manifest.xml with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <project name="TheMuppets/proprietary_vendor_samsung" path="vendor/samsung" remote="github" />
</manifest>

Next, to pull down the blobs (since we modified the manifest, let's resync):

cd Android/cm-11.0
repo sync -j16

Finally, build time!

cd Android/cm-11.0
./vendor/cm/get-prebuilts
CM_EXTRAVERSION=mytest1 CM_BUILDTYPE=SNAPSHOT brunch cm_skyrocket-userdebug
blog comments powered by Disqus