Build a LineageOs4MicroG ROM using Docker on Ubuntu

Posted by

One month back if anyone had said that I could build a ROM using Docker I would have laughed. I had taught myself how to build a custom ROM for my cell phone the hard way. I have three phones at home. The three phones have three different flavors of the Android Operating system. My current daily driver is a MiA1 tissot. The phone was released with Nougat and was later updated to Oreo. The current version of Oreo is 8.1. The phone is officially supported by LineageOs4MicroG. That is where I decided to try my hand at using Docker to build my own ROM. After a few false starts it finally worked. Now it works like clockwork. Let me share what I did with you.

Before we proceed let me explain what MicroG is. To those – like myself – who do not want to have Google services on their phone and yet are addicted to apps like twitter, whatsapp or GooglePay – MicroG is a must. The problem with Google is that, their apps tend to steal your personal information and marketing it. I do not like that. Yet I need to use apps like WhatsApp and Twitter. These apps need Google play store to run in the background. The way around is to install MicroG. What MicroG does is it spoofs the apps into believing that Google Play is installed on your phone!

Installing Micro G the standard way- downloading apk’s and installing them- is a pain. The easiest way is to either download a custom ROM with MicroG already built in or build a custom ROM yourself. This is where LineageOS4MicroG comes in. These builds require docker to be setup on your PC.

A word about Docker.

Docker is a build method which is almost entirely automated. Once you have the environment up and running on your PC you just sit back and wait for the build to complete. No action is required from your side. Lets see what the per-requisites are for setting up a Docker build environment.

Step 1:
Install docker on your PC. I use a Ubuntu PC but Docker can be installed on windows as well as Mac.

Check the docker web site for instructions specific to your system.

https://docs.docker.com/install/

Confirm that docker is installed on your PC by running the below command

docker
run hello-world

the output should be something like this

docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world ca4f61b1923c: Pull complete Digest: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. ...

Step 2: pull the lineageos4microg on to your pc

docker
pull lineageos4microg/docker-lineage-cicd

You should see a screen similar to the screenshot below….this was for another pull..but you get the idea 🙂

docker pull image

Step 3:

Create directories

sudo mkdir -p \

/lineageos4microg/src \

/lineageos4microg/zips \

/lineageos4microg/logs \

/lineageos4microg/ccache \

/lineageos4microg/keys \

/lineageos4microg/local_manifests

this would create directories on the file system. The lineageos4microg environment takes up about 150 GB of space so I do not prefer creating folders outside /home as I ran into space problems

An easier way is to just create folders using nautilus under home for e.g.

Create a folder lineageos4microg under home

and inside it create these 6 folders

lineage
zips
logs
cache
keys
manifests

Step 4:

Create an xml file… copy paste this in notepad, gedit and save with the name custom_package.xml

The name is not important, it is the .xml part which is important.

<?xml version=”1.0″ encoding=”UTF-8″?>
<manifest>
<project name=”lineageos4microg/android_prebuilts_prebuiltapks” path=”prebuilts/prebuiltapks” remote=”github” revision=”master” />
</manifest>

Step 5:

start the build with the below command

docker run \
-e “BRANCH_NAME=lineage-15.1” \
-e “DEVICE_LIST=<device name>” \
-e “SIGN_BUILDS=true” \
-e “CCACHE_SIZE=100G” \
-e “SIGNATURE_SPOOFING=restricted” \
-e “CUSTOM_PACKAGES=GmsCore GsfProxy FakeStore MozillaNlpBackend NominatimNlpBackend com.google.android.maps.jar FDroid FDroidPrivilegedExtension” \
-v “/home/manoj/lineageos4microg/lineage:/srv/src” \
-v “/home/manoj/lineageos4microg/zips:/srv/zips” \
-v “/home/manoj/lineageos4microg/logs:/srv/logs” \
-v “/home/manoj/lineageos4microg/cache:/srv/ccache” \
-v “/home/manoj/lineageos4microg/keys:/srv/keys” \
-v “/home/manoj/lineageos4microg/manifests:/srv/local_manifests” \
lineageos4microg/docker-lineage-cicd:latest

Please note:

– replace the <device name> with your phone name. For e.g. my MiA1 is called tissot. You can get your device name by typing the below adb command

$ adb shell getprop ro.product.device

assuming you have adb setup and functioning on your pc. If not click here xxxxx

– in the above command I have set Ccache size as100G. This is because I have a lot of empty space on my PC. Set it to 50G or as per your convenience.

– the PC will seem to hang with the message Syncing repositories. This is because the setup is downloading files from the internet. This process can take a long -long time. You can see what is happening by checking the log files. Copy the logs on to your desktop and open this copy. Do not try to open the actual logs as data is being written on to it.

what these commands mean:
All the command starting with the -e are setting your environment for the build. The cache size, Lineage branch (in this case 15.1) , signature spoofing – read detailed documentation links to understand this better. Safe to say use restricted for now.
All the commands starting with the -v are the location of your source files or folders where your logs and zip is to be placed. I got errors here when the path was not correct.

Check the path to get the command to run smoothly. It is a one time task. Save the command to run it again the next time you want to build.

The \ sign mark the end of each line.

To see more samples refer the links given below for the LineageOS4microG site.

Step 6:

Once the build is complete you will find the build in the zips folder.

Enjoy!!!

The advantage of the Docker build is once the environment is set up it does all the work almost automatically. The resources on the PC are optimally used. For e.g. I have 15 GB or RAM but am unable to run any other application while building normally. With Docker I use my PC as normall while the build is running in the background. You can run multiple device builds at the same time, You just have to add device names separated by a comma.

Additional reading for reference and trouble shooting

Docker installation : get details for your PC

https://docs.docker.com/install/

For e.g. for Ubuntu https://docs.docker.com/install/linux/docker-ce/ubuntu/

LineageOS4MicroG related documentation

https://hub.docker.com/r/lineageos4microg/docker-lineage-cicd/

https://github.com/lineageos4microg/docker-lineage-cicd

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s