[Nexus 6P General] tr4nqui1i7y:
This is how to build a functioning MIUI 8 port for the Nexus 6P.

To start, use Ubuntu 16.04 64-bit. Dependencies will change if you use a different version

Run these commands in the terminal to get all the pre-requisites.

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop maven openjdk-8-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline6-dev lib32z1-dev

From cyanogenmod wiki:

Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:

1. Obtain OpenJDK 1.7 from the openjdk-r PPA

2. Enable experimental OpenJDK 1.8 support in CyanogenMod 13.0 (not available in earlier version). To enable OpenJDK 1.8 support, add this line to your $HOME/.bashrc file: export EXPERIMENTAL_USE_JAVA8=true.

You'll have to have to have android SDK installed as well.

http://developer.android.com/sdk/installing.html

Be sure to add the sdk tools to your path.

Once you have the tools added to your path, head over to github and make a free account.

Once you have a free account you'll be able to download the source for patchrom.

Open terminal again and run these commands.

mkdir patchrom

This will make a directory called patchrom

cd patchrom

This will put you into that directory

repo init -u git://github.com/MiCode/patchrom.git -b marshmallow

This will sync the directory with the latest tools and source

This is where you will be asked to sign into your github account.

You'll need to take into consideration which base ROM you would like to use to build MIUI.

I recommend building MTC20L pre-rooted, if you have the time and resources.

Otherwise, find a ROM that is pre-rooted and has a single system.img. This will make the process a lot easier.

If you find that the ROM has system.dat, among other system files, then you might consider another ROM.

Now, you'll need to copy a few files from the ROM. (or you can run make workspace in the same directory as stockrom)

framework.jar services.jar telephony-common.jar and wifi-service.jar

These should all be located in the /system/framework/ of the ROM you chose.

Decompile these with apktool.

The decompiled folders should be labeled

framework.jar.out services.jar.out telephony-common.jar.out and wifi-service.jar.out respectively.

Back to building.

You'll notice that there is already an angler folder located inside of the patchrom directory. This is a very old base, and does not boot without modification.

That is why we are building from a different ROM, and with a slightly different method than found on the patchrom github.

Remove everything from the /patchrom/angler/ folder

Place all of the decompiled folders into this directly, and make sure they are named appropriately.

Place the ROM you chose as a base in this directory as well.

Rename the ROM to stockrom.zip - This is important for the makefile

The makefile found in the github prokect is a start, but you'll need to make your own. You can ask for more help with that in this thread.

~ https://github.com/MiCode/patchrom_angler/blob/marshmallow/makefile ~ Use this for ideas. Yours will not be identical

Using [MENTION=5262839]STRYDER~007[/MENTION] 's words to better understand the makefile

"Explanations:-

'local-zip-file' = Name of your original Base ROM zip

'local-out-zip-file' = Name for your finished MIUI rom

'local-modified-apps' = Apps that will be modified to fit in with the framework. They need to be modified because they contact with the system

'local-remove-apps' = Apps that will be removed from the original ROM

'local-pre-zip' = Refers to code-block that should be executed before the zip is done.

'local-after-zip' = Refers to code-block executed after the zip is completed

'local-zip-misc' = The code-block just described at 'local-pre-zip'. It adds some Google Apps and a build.prop

'local-test' = Another code-block"

Once you have a makefile established you can move on to your first build.

Open the terminal again

cd patchrom
. build/envsetup.sh
cd angler
make workspace - (if you didn't manually decompile)
make firstpatch

This will vary in length depending on your machine

Once that has completed you'll need to look through the /patchrom/angler/temp/rejects/ folder and the terminal to find all of the manual patches that you'll need to apply.

Here is the tutorial that I used - http://xdaforums.com/chef-central/android/guide-patchrom-rejects-fixing-tutorial-t3203287

After you have successfully manually patched everything, you can run the final command in the terminal for now

make fullota

This will create a file called fullota in the /patchrom/angler/ directory.

You can test to see if it will boot. You will still need to flash the vendor file that matches your stock rom of choice.

At the time I built, some extra modifications needed to be made to the boot.img

I used [MENTION=718594]super[/MENTION]R 's kitchen to decompile the boot.img - http://xdaforums.com/chef-central/android/kitchen-superrs-kitchen-t3202296

Set the current status to the following (unless you prefer otherwise)

Add/Remove init.d support: Enabled

Insecure/Secure: Insecure

Remove dm-verity: Disabled

Add/Remove forceencrypt: Disabled

In short, make sure every option appears green, rather than red.

Now, you can repack the boot.img and put it back into the ROM

You should now have a booting MIUI 8 for the Nexus 6P that you built!