Compiling CyanogenMod - Sony Xperia U (kumquat)

I could not find instructions for my phone, so I followed the guide on CyanogenMod Wiki for a different Sony phone. It appears to have been close enough.

Completed on 2012-12-29

Prepare the Build Environment

NOTE: These steps only need to be performed once. If the build environment is already prepared, skip to Copy proprietary files.

Install ADB

sudo apt-get install android-tools-adb
Or install the Android SDK.

Install the Build Packages

Install using preferred package manager:
For 64-bit systems:
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-glx:i386 libgl1-mesa-dev g++-multilib mingw32 \
  openjdk-6-jdk tofrodos python-markdown libxml2-utils xsltproc \
  zlib1g-dev:i386 pngcrush schedtool lzop

NOTE: The above was tested on Ubuntu 12.10, the package names may vary by chosen Linux distro.

Create the Directories

Create working directories for the build environment:
mkdir -p ~/bin
mkdir -p ~/android/system

Sync the Repository

Enter the following to download make executable the repo binary:
curl > ~/bin/repo
chmod a+x ~/bin/repo

NOTE: A reboot of the computer may be necessary for the above changes to be recognized.
Now, enter the following to initialize and sync the repository:
cd ~/android/system/
repo init -u git:// -b ics
repo sync -j4

Sync Relevant Repositories

NOTE: This only needs to be done the first time after syncing the repository. If this step has been completed, skip to Copy Proprietary Files.
By default, CyanogenMod 9 only syncs the core android repositories and none of the device or kernel trees to save both bandwidth and time. Run the following command to sync the necessary components for the device:
. build/ && breakfast kumquat

The system will automatically begin pulling the device repository and all required dependencies.

Copy Proprietary Files

NOTE: This only needs to be run once. If these steps have already been performed, skip to Download Prebuilts.
This step requires possession of the Kumquat with a working copy of CyanogenMod 9 installed and ADB working on the computer. This script will copy the proprietary files from the device.
Connect the device to the computer and run the following commands:
cd ~/android/system/device/sony/kumquat/

NOTE: If some hardware isn't functioning properly, this script may need to be run again in case there are updated proprietary files.

Download Prebuilts

Download Prebuilts needed by the build:
This actually failed for me. The script tries to get Term.apk but fails as the result 404's. I grabbed the required file from my existing phone, and extracted the required file by hand. Seems to have worked OK.

Building CyanogenMod

Check for updates

First, check for updates in the source:
cd ~/android/system/
repo sync

Configure Build & Compile

Now, the environment must be configured for the build process and then begin compilation for the Kumquat.
. build/ && brunch kumquat


Copy the .zip file from ~/android/system/out/target/product/kumquat/ to the root of the SD card.
Optional: Download Google Apps for CyanogenMod 9 and place it on the root of the SD card.
Flash both of these .zip files from recovery.