[Nexus 6P General] connectionalive:
Hi,

I have decided to write this post after reading so many different guides on my journey to build my own version of Cyanogenmod and after countless tries and hours of research I succeeded. Here's how:

You will need:

A Ubuntu box

A basic knowledge of Linux

A fast internet connection or a lot of patience.

Once you have setup your Ubuntu box either in a Virtual Machine of as a stand alone PC you will need to open a terminal, this can be done by pressing 'CTRL + ALT + T' or opening the search menu and typing "Terminal".

You should see the following:

username@machinename:~$

We will need to install all the necessary files in order to build and download Cyanogenmod, we can do this by running the following command:

sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev openjdk-7-jdk openjdk-7-jre

As many Linux users have more than one version of Java installed we will need to set the the version we just installed as our default version.

sudo update-alternatives --config java
sudo update-alternatives --config javac

If by any chance you have a 64-bit version of Ubuntu installed we will require some extra files, if not please skip this command.

sudo apt-get install g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev

We will now for simplicity's sake need to create the following directories in your home folder. These directories will host our build.

mkdir -p ~/bin
mkdir -p ~/android/system

Once you have setup everything correctly we will now to download the Cyanogenmod source code of which we are going to use the 'Repo' utility. This utility is an automated tool for GitHub cloning. We can download this and set the correct permissions by running the following commands.

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

chmod a+x ~/bin/repo

To continue with download the source code we will now initialize the GitHub repository that holds Cyanogenmod. We are going to need to specify the repository with -u and the branch with -b. Here I am going to download the latest available version of Cyanagenmod 13.0.

cd ~/android/system/
~/bin/repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0

And to finally start downloading the source:

~/bin/repo sync -c -f -j8

Where:

-c Download the current version instead of all history.

-F Forces the connection to continue even if a connection error occurs.

-j8 This specifies the number of parallel operations. Use -j8 for a quad core processor and a -j16 for an octa-core.

Once the download completes successfully we will need to download the device specific code, this includes specific applications and kernel configurations for your device. To start downloading the files type:

source build/envsetup.sh
breakfast angler

The download should now start, it should only take minutes however this depends on your internet connection.

Again once this completes, we need to grab proprietary specific files. We first need to navigate to ~/android/system/device/huawei/angler. You can do this by running the following command:

cd ~/android/system/device/huawei/angler

As the script we are going to use has some dependencies we will need to get them first.

git clone https://github.com/JesusFreke/smali
cd smali
./gradlew build
cd ..

Additionally we need to download a Google Stock Image, I'm using angler-mmb29m-factory-8c31db3f.tgz, once downloaded you will need to unzip it and cd to it within the terminal.

and then download:

wget http://people.canonical.com/~mfisch/tools/ext4_utils.tar.gz
tar xzsf ext4_utils.tar.gz
cd ext4_utils
mv simg2img ../angler-mmb29m/
cd ../angler-mmb29m/

We will now convert the system and vendor img's using simg2img to a readable format and mount them so we extract the propriety files using ./extract_files.sh

We can do all of this by using the following commands.

./simg2img system.img system.ext4
./simg2img vendor.img vendor.ext4
sudo mkdir -p /mnt/system
sudo mkdir -p /mnt/vendor
sudo mount -rw system.ext4 /mnt/system
sudo mount -rw vendor.ext4 /mnt/vendor

Finally we can extract the proprietary files for the system image by running the following commands.

cd ~/android/system/device/huawei/angler/
./extract_files /mnt/ smali/

Finally we can finish off by our by running the brunch command to build and generate the .zip file of our own Cyanogenmod.

brunch angler

Note: This will take 20 mins - 2 hours - 2 days depending on your hardware spec.

And well that's it, the location of your generated .zip file should be in blue at the end of your terminal.