[Nexus 4 General] klvnhng:
If you are looking for my nightly builds, you can find them here.

So after countless hours of frustration and face-desking, I finally managed to make a working build of CyanogenMod 10.2 (Android 4.3). To make the process slightly less painful for you, I've decided to create this noob-friendly guide. This is my first development guide, so feel free to leave criticism or suggestions through PM.

Prerequisites

You will need:

A relatively recent computer running Ubuntu with a reasonable amount of RAM (I recommend at least 4 GB) and around 35 GB of free hard drive storage

A decent internet connection

Some understanding of basic Android and Linux operation and terminology is helpful

Setting up the build environment

The first thing you need to do is install the correct Java Development Kit/JDK, Oracle Java 6. If you have OpenJDK installed, you have to uninstall it by typing this command into the terminal, which can be brought up by pressing Ctrl+Alt+T or searched for in the dash.

sudo apt-get purge openjdk*

To install Oracle Java 6, type this into the terminal (one line at a time):

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

Android SDK requires the x32 compatability packages, ia32-libs. Install it by entering this:

sudo apt-get install ia32-libs
y

Now you will need to get the Android SDK/Software Developer Kit, if you haven't already. Go ahead and download it here.

Extract it to a folder of your choice (in this guide, I will refer to it as ~/android/sdk) and from that folder, enter these commands into the terminal:

cd ~/android/sdk/adt-bundle/sdk/tools
./android sdk

Click Install packages. cd to ~/android/sdk/adt-bundle/sdk/platform-tools and type:

adb
fastboot

If you've done everything correctly, you should get a big block of text for both (which list all of the adb/fastboot commands).

Next, install the build packages. Copy and paste this command into the terminal:

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 pngcrush schedtool libxml2 libxml2-utils xsltproc g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib
y

You will now need to set up the directories for your build environment. Type this into the terminal:

mkdir -p ~/bin
mkdir -p ~/android/cm-10.2

Set up the repo binary (used for syncing your local repository with the CM source):

curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

Syncing your local repository with the CM source

The next step is to initialize the repository and download the CM source code to your computer. Type the following lines into the terminal:

cd ~/android/cm-10.2
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2
repo sync

You have now begun downloading all of the CM source code to your build directory. Depending on your internet speed, this can take up to a couple of hours. If the sync interrupts, don't worry. Simply continue the sync (you don't have to restart completely, only the project you were downloading when the interrupt occured, phew) by entering:

repo sync

Remember, you need to cd into your build directory (~/android/cm-10.2, if you've been following this guide) for the command to work.

Go and get yourself a drink or something, this step takes a long time.

Now comes the fun part: Building

You're almost to the end! In order to make a working build, you have to get the proprietary files (mainly device build files and drivers) for the Nexus 4. The easiest way to do this is to create a file named "roomservice.xml" in the ~/android/cm-10.2/.repo/local_manifests directory. Now, .repo is a hidden directory, so in order to access that directory you can either 1) show hidden files and folders in Nautilus (the Ubuntu file manager) or 2) access the folder and create the file using terminal commands. Both methods are explained below (2 is probably easier, but does not always work, in my experience).

1) Open up a Nautilus window. Navigate to your build directory (once again, ~/android/cm-10.2) and press Ctrl+H. This allows you to see hidden files and folders. You should see a folder labelled .repo. Enter it and inside, create a directory called "local_manifests", if there isn't already one. Enter that folder and create a blank file called "roomservice.xml". Next, copy the following lines into the file and press save:

<manifest>
<project name="TheMuppets/proprietary_vendor_lge.git" path="vendor/lge" remote="github" revision="cm-10.2"/>
</manifest>

2) Type this into the terminal:

gedit ~/android/cm-10.2/.repo/local_manifests/roomservice.xml

ext, copy the following lines into the file and press save:

<manifest>
<project name="TheMuppets/proprietary_vendor_lge.git" path="vendor/lge" remote="github" revision="cm-10.2"/>
</manifest>

If you get an error, try method 1.

Do another repo sync:

repo sync

After this, you can download the necessary pre-built apps:

~/android/cm-10.2/vendor/cm/get-prebuilts

Finally, you will build. If you aren't there already, cd to your build directory and run the following commands in the terminal:

. build/envsetup.sh
brunch mako

Now, just let your computer do the rest. This step is very demanding for your computer, so I recommend you leave it alone while it builds. Go get another drink.

Done? If everything went correctly, cd to ~/android/cm-10.2/out/target/product/mako and you should see your newly built ROM entitled:

cm-10.2-20xxxxxx-UNOFFICIAL-mako.zip

Congratulations! You've successfully built CM 10.2!

For re-builds (i.e. when the source code has been updated and you would like to make a new nightly), just do this:

cd ~/android/cm-10.2
make clean [I](for incremental builds, you can skip this step. You can also do make clobber; thanks [MENTION=4520802]obtained[/MENTION])[/I]
repo sync
. build/envsetup.sh
brunch mako

If you ever encounter an error or problem and need help, feel free to post here or send me a PM.

Happy building, everyone!

Sources:

How To Build CyanogenMod Android for Google Nexus 4 ("mako")

http://wiki.cyanogenmod.org/w/Build_for_mako

[GUIDE] How to build CM10.1 (Android 4.2.1) for the Nexus 4 (mako)

http://xdaforums.com/showthread.php?t=2047981

[GUIDE] Building CM10.2 for Nexus 4 with Mac OS X 10.8.X)[UPDATED: 8.8.2013]

http://xdaforums.com/showthread.php?t=2087318

UBUNTU 12.04 - INSTALL ANDROID TOOLS (ADB, FASTBOOT, ...)

http://bernaerts.dyndns.org/linux/245-ubuntu-precise-install-android-sdk