Building Resurrection Remix (Nougat) for Zuk Z1 – Part 1: Setting up the build environment

This guide will be for newbies who are trying to start building with Zuk Z1. Zuk Z1 is a nice phone with Snapdragon 801 processor. Its a pretty old processor but thanks to ZUK company and developers such as Ordenkrieger and Acuicultor, Android Nougat was made available for users to flash and use. So what is Zuk Z1? This is Zuk Z1.

Zuk Z1 courtesy of GSMArena

Zuk Z1 courtesy of GSMArena

So how do you really start with ROM building?

A lot of people, and even myself ask, “Can a newbie like me without formal knowledge in Computer Science courses or programming background build a ROM?” Turns out, the answer is yes. A lot of people venture into this ROM building. However, very few were successful and can actually produce a working build. There are many factors affecting the success of doing a working build but if you ask me, patience and perseverance is the biggest deciding factor. While ROM building is relatively easy (specially if you do not encounter any build issues), understanding what a series of commands do and how the whole process works under the hood requires a lot of patience. For me this is very important as diving into the technical details will help one solve future challenges in ROM building.

A little back story

If you don’t wanna hear my experience in how I came up with the build, you are can always skip this section.

Everything starts with reading. Even before I downloaded a single source code of Resurrection Remix (RR) from GitHub, I read a lot of things. I mainly hang in XDA forums and got background tabs waiting to be read coming from numerous Google searches that I did. I research each and every command and tried to understand how stuff works. After I got my confidence going, I managed try things out in my computer. I followed guides and executed the commands one by one. I read, I execute, and repeat. Its a never ending cycle. After numerous trials, errors to be debugged, and painstaking researches, I was able to push for the final working build.

And that is my story! I read, I tried things out, and in the end it worked. Oh, pretty anti-climactic right? Kidding aside, what you have just read is just a very short summary. Here’s actually what I did:

  1. Learn how to setup the build environment
    1. Get a Linux distribution running as a Virtual Machine
    2. Install necessary packages (software) needed for the build
    3. Install Repo tool
  2. Learn how to test build Cyanogenmod 13 (purely for educational purposes only)
    1. Initialize repository and sync sources
    2. Create local manifest which includes repositories that provides:
      1. Proprietary blobs
      2. Device tree
      3. Custom kernel (if any)
    3. Redo a sync
    4. Build
  3. Build Resurrection Remix Nougat
    1. Initialize repository and sync sources
    2. Create local manifest which includes repositories that provides:
      1. Proprietary blobs
      2. Device tree
      3. Custom kernel
      4. Other tools
    3. Redo a sync
    4. Build
  4. Flash Resurrection Remix Nougat to Zuk Z1

The time it took me from start of ROM building journey to finish?

From: Saturday, 10 December 2016
To: Friday, 7 April 2017
Total of: 119 days or 3 months, 29 days of reading, research, and building

Yes. That long. The key? Perseverance.

How to build Resurrection Remix (RR) Nougat?

With that backstory out of my system, let us now focus on what really matters, building RR Nougat for Zuk Z1. If you have read the back-story, you may already have an idea on what we are going to tackle in this part. However, for those who did skip that little back story and is really trying their best to save time, here’s what we are going to do in five simple steps:

  1. Setup build environment
  2. Initialize and sync repositories
  3. Create local manifests to include
  4. Re-sync repositories
  5. Build

Pretty easy right? Sort of. If you are lucky and if you do not want to learn some of the technical details on what you are doing, you can go through the 5 sections with ease. But if you are like me who research every single part of the process to understand how everything works and what a command does, well, good luck!

As I was writing this guide, I noticed that it would be better to split this into two parts. In this post we will only talk about setting the build environment. If you already have a working environment, I suggest you skip this post and head to part 2.

Setting up the build environment

There are many ways to setup the build environment. You can dual boot your machine to run Windows and Linux side by side or just settle with a Virtual Machine (VM). In my case, I used a virtual machine to build the RR Nougat for Zuk Z1. Though it wouldn’t matter on which path you choose, I would recommend that you choose the VM route if you have a capable machine as it will be faster and much easier to deploy the VM instead of messing out with dual boot configuration in your machine.

By the way, I am using Asus ROG G752VT laptop which features a quadcore processor and 16GB RAM. If your machine is somewhat on the same level of specs as I do, I suggest you go for the VM route as we will be doing the VM route in this tutorial. Here are the steps that we need to go through to setup our build environment:

  1. Download a Linux distribution.
  2. Install the Linux distribution in VMware.
  3. Install additional packages required for the build.
    1. Setup repo tool
    2. Enable ccache

Download a Linux distribution

There are a lot of Linux distributions around the web. However most of the build environment setup tutorials always recommend Ubuntu. Personally I prefer building with Arch but that has yet to come as I am yet to finish building my Arch distro from the ground up (UPDATE: I got it working). Anyway, to continue with the setup, download the latest Ubuntu LTS (Long term support), here. I am using  Ubuntu 16.04 just in case you wanna know what version I am using.

You will be downloading an .iso file which we will be used installing the distribution in our VM instance.

Install in VMware

After you have successfully downloaded the file, you can now proceed in installing it on VMware instance. You can go and download VMware here.

But wait, what is a VM? A VM or a Virtual Machine is a container which enables us to run an operating system (OS) on top of our OS. Think of it as a computer inside your computer which you can freely install Windows (XP, Vista, 7, 8, 10, etc) or Linux (Ubuntu, Debian, Arch, etc) all without messing up the configuration of your machine.

Now, create a new VM instance with the .iso selected as shown below:

VMware - Install operating system (.iso)

VMware – Install operating system (.iso)

Then, customize your space allocation and hardware. Make sure that you set your disk space to at least 150GB and with “store virtual disk as a single file” selected. Then adjust the CPU to “2”, and RAM to atleast 6GB (6114 to be exact) as shown below:

VMware - Customize disk allocation

VMware – Customize disk allocation

VMware - Customizing hardware

VMware – Customizing hardware

After creating the instance, proceed to boot it. If it all goes right, VMware will install Ubuntu with minimal supervision. Now, you can go ahead and grab a drink and chill if you want.

VMware - Ubuntu easy install

VMware – Ubuntu easy install

Installing additional packages

Once Ubuntu is installed, we can go and install additional packages (software) required for the build. You may need to be familiar working with the terminal (command prompt for Windows) to perform this step.

At the Ubuntu desktop, fire up terminal by clicking the somewhat start button located in the upper left corner of the screen and type “terminal”. Once the search results comes up and you find a weird looking black box, click it.

Ubuntu terminal

Ubuntu terminal

After terminal it is launched, we can now proceed entering these commands:

sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng maven

Ubuntu - package install confirmation

Ubuntu – package install confirmation

After pressing enter, it will put a lot of text in your terminal session and at the end, you will have to type “y” to confirm installation. After confirming, it will install all these additional packages required for the build.

Ubuntu - package install

Ubuntu – package install

Okay, I pasted the commands, but what does it do?

To understand the command we just entered, let us divide it into 3 parts:

  • sudo – this command tells the computer to grant temporary root or administrator permissions on the current command
  • apt-get install – this command summons the package / software installer
  • git ccache automake.. – these are the packages we are going to install

Now we need “sudo” because the default account for our Linux installation is a regular user which is restricted in making any changes that could potentially be harmful for the system such as installing packages / software. Therefore a “sudo” command is needed to give us temporary root or administrator rights for the current command. apt-get install is the command needed in order to tell our computer to install packages. The “apt-get install” command needs to know what packages we are going to install. Therefore we must indicate the name of the packages we are going to install separated by a space.

With that short terminal course finished, let us proceed with the next step.

Setting up the repo tool

Downloading repo tool

Downloading repo tool

To install the repo tool, enter this in the terminal:

mkdir ~/bin && curl > ~/bin/repo && chmod a+x ~/bin/repo

This will download the repo tool and make it an executable that can be used in terminal without going to the directory where repo is downloaded. To further understand the command, we need to slice and analyze it bit by bit.

  • mkdir – this command will make a new directory or folder in ~/ (~ means home directory) with a folder name of “bin”
  • && – this tells the terminal to issue another command after the preceding command is finished
  • curl – this will download a resource over the Internet
  • http://commondata.. – the address needed by curl where the resource is located
  • > ~/bin/repo – the location where curl will put the downloaded resource
  • chmod – or “change mode”. A command that is used to change the file permissions of a file. For more information, see here.
  • a+x – arguments needed by chmod. This will set the target file to be executable for all users (a = all users and x = executable)

Enabling and adding ~/bin to the executable path directories and setting up ccache

Enable ccache in .bashrc

Enable ccache in .bashrc

The next step is to add ~/bin folder that we created in the executable path directories so that binaries placed in that folder will be picked up everytime we fire up a terminal session. In addition, we also need to enable the use of ccache. ccache is a functionality that will help us compile the ROM faster on succeeding compiles by saving a cache of compiled items in our hard disk.

To configure this, type in the terminal the following:

nano ~/.bashrc

This will open the .bashrc file located in ~/ (or our home directory) with nano — a command line text editor. Afterwards, scroll down to the last line and add the following:

export PATH=~/bin:$PATH

export USE_CCACHE=1

Also, add this if you are on Arch Linux:

export PATH=”/usr/lib/ccache/bin/:$PATH”

and press CTRL+X and type y and confirm overwrite of file.

.bashrc edit for CCACHE

.bashrc edit for CCACHE

And there you have it! You now have a working build environment. The only thing that is left is to download the sources, include a local manifest, and compile the ROM.

Head to Part 2 to continue building!


This also helped me in building this guide and compiling the ROM. Feel free to visit them for more information.

Leave a Reply

Be the First to Comment!

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

%d bloggers like this: