Building Resurrection Remix (Nougat) for Zuk Z1 – Part 2: Syncing sources and performing the build

If you are reading this post, you might have already prepared your build environment. If you haven’t yet, check out the Part 1 of this tutorial.

In this post, we will tackle how to synchronize the repositories, make an SElinux patch, and perform a build of Resurrection Remix Nougat for Zuk Z1.

Prepare working folder and initialize repository

With the build environment in optimal setup, head to the Desktop (or any folder) of the VM instance and create a working folder of your choice. I named mine “RR7-ham”.

RR7-ham working folder

RR7-ham working folder

Go to the working folder you have just created and initialize repository by typing:

repo init -u https://github.com/ResurrectionRemix/platform_manifest.git -b nougat

This will perform initial sync of the repository of the ROM we are building. The “-b” specifies what branch we are using for the build. For more information on the repo command, go here.

Remember not to type the command above in a root environment. You will know you are not using the root account if you do not see any pound sign “#” on the terminal before you enter your commands (notice the $ sign before the repo command in the screenshot below. This indicates that I am using a regular account and not the root account).

RR-Nougat - Initializing repository

RR-Nougat – Initializing repository

After entering the command, the terminal will do its job and download all necessary files. You will then encounter an error:

fatal: unable to auto-detect email address (got ‘test@ubuntu.(none)’)

Additional details needed by git tool

Additional details needed by git tool

To quickly fix this, you just have to follow the additional instructions provided in the terminal. Type:

git config –global user.email “insert email here”

to set your email address for the git tool and

git config –global user.name “insert username here”

to setup your username. I am not sure if you can put any value here as I did enter my github credentials when I was on this part. After successfully modifying your preferred email and username, you can now proceed and accept the “Enable color display” and continue to add a local manifest.

Adding the local manifest

While in the working folder (RR7-ham), go to “.repo” folder by typing the following in the terminal

cd .repo/

Then, create a “local_manifests” folder.

mkdir local_manifests

Inside the “local_manifests” folder,

cd local_manifests

create an XML file by typing:

nano ham-additional-repo.xml

Create a local manifest xml file using nano

Create a local manifest xml file using nano

The command above will spawn the nano program where you can paste the additional repositories needed (see below) in addition to the repositories we used when doing the repo init command. Paste the block of text below in your nano instance.

<?xml version=”1.0″ encoding=”UTF-8″?>
<manifest>
<project name=”OneRomOne-N/android_device_zuk_ham” path=”device/zuk/ham” remote=”github” revision=”nuclear-n” />
<project name=”OneRomOne-N/proprietary_vendor_zuk” path=”vendor/zuk” remote=”github” revision=”nuclear-n” />
<project name=”acuicultor/Radioactive-Kernel-HAM” path=”kernel/cyanogen/msm8974″ remote=”github” revision=”cpuquiet” />
<project name=”LineageOS/android_device_qcom_common” path=”device/qcom/common” remote=”github” />
</manifest>

To further understand this local manifest, let us break it down to different parts:

<?xml version=”1.0″ encoding=”UTF-8″?>
<manifest>

is part of the manifest template. This should not be omitted if you want to use this local manifest file.

Next is the device tree of Zuk Z1 (below). I believe this is the device tree used by Nuclear ROM for Zuk Z1. If you want to know more about device trees, head to the Telegram Channel by Zly. I believe he/she is researching on this.

<project name=”OneRomOne-N/android_device_zuk_ham” path=”device/zuk/ham” remote=”github” revision=”nuclear-n” />

The next line contains the repository with the proprietary bits for Zuk Z1.   We can also blobs from the Muppets as I believe they are just the same. Though I’m not sure if their blobs are up-to-date.

<project name=”OneRomOne-N/proprietary_vendor_zuk” path=”vendor/zuk” remote=”github” revision=”nuclear-n” />

The next line contains the code for the custom kernel. We will be using Radioactive kernel for this one so I added a repo in the local manifest for it. I believe this is purely optional and you can omit this one if you want to use the stock kernel.

<project name=”acuicultor/Radioactive-Kernel-HAM” path=”kernel/cyanogen/msm8974″ remote=”github” revision=”cpuquiet” />

And for the last part, we need to add this to enable the use of some additional tools such as dtbtool needed in order to compile ROM.

<project name=”LineageOS/android_device_qcom_common” path=”device/qcom/common” remote=”github” />

After adding the local manifest using nano, hit

CTRL + X

and type “Y” and press enter to save changes.

Adding local manifest using nano

Adding local manifest using nano

Then go to the top level of the working folder by doing a

cd ../

and proceed to the next stage.

Syncing repositories

This is one of the most time consuming parts in ROM building. Don’t worry, this will only take long if you are:

  • Doing the repo sync for the first time after your repo init
  • In an area with slow internet connection

Since we already have the repositories set up, we will now proceed with the sync. Type:

repo sync -f --force-sync --no-clone-bundle

or if the command does not work.

repo sync -f --force-sync

This will start the download of  the required source files by the ROM. If all goes well, you can proceed immediately to the next step after syncing the repositories. Note however that this part takes around 1 to 3 hours to perform if you are in a fast internet connection. In my case, I downloaded the source for 8 hours straight.

Syncing repositories

Syncing repositories

Patching SElinux

Before we hurry and build the ROM, we should first patch SElinux. I still do not fully understand what the code does but I guess it patches SElinux so that it will be turned off at boot. If you do not do this, the ROM will be in a bootloop state after flashing it in your device.

Go to “system/core” by doing a “cd /system/core” and type

git add .

This will make the current directory we are in as a staging folder for git.

After the command above is successfully ran, do a:

git fetch https://review.lineageos.org/LineageOS/android_system_core refs/changes/36/142836/2 && git cherry-pick FETCH_HEAD

in the terminal. The command above will fetch the necessary patch for the SElinux. To view the actual code for this patch, go here.

Build Resurrection Remix Nougat

After syncing the repositories and patching SElinux, you can now proceed with the build. Go to the root of the working directory and type:

. build/envsetup.sh && brunch ham

This will compile all the necessary files to create a ROM. A built-in script from Resurrection Remix team will run and ask you a number of questions regarding the build. When asked what kind of build you are going to do, select “unofficial“. This is necessary to prevent any negative discussions from the community specially if you are going to post your build to various forums.

After the build is finished (took me around 3 hours in my machine for the initial compile), head to “out/target/product/ham” and get the .zip file of the ROM. we just built. There are two .zip files in there. Be sure not to pick the lineage-OTA.

And there you have it! You have successfully build Resurrection Remix Nougat for Zuk Z1. Cheers!

Additional notes if you are in Arch Linux

If you are doing the build in Arch Linux, you need to do the following steps before doing the

. build/envsetup.sh && brunch ham

First up, set a Python 2 environment. You can do this by typing

virtualenv2 venv

Then after the command is finished running, activate the virtual environment.

source venv/bin/activate

Remember that you need to do this before doing the build.

PS: Rebuilding RR Nougat

If you want to rebuild an updated RR Nougate, just go to your working directory and type:

make clean && make clobber

then perform a repo sync, patch SElinux, and build it again using the same commands.

Hopefully everything will be faster in this succeeding build thanks to ccache.

Cheers!


Looking for pre-built flashable zips? Go here.


Special thanks to Resurrection Remix Team!

Leave a Reply

Be the First to Comment!

Speak up you comment ninja! Let's talk. Leave a reply.

wpDiscuz
shares
%d bloggers like this: