Tag Archives: docker

Easy way to add custom packages to a LineageOS4MicroG ROM

So you have figured out how to build your own custom ROM using Docker…if not click here.
Once you have become an expert at it you would want to add a custom touch to the build. I realized that I was downloading a few apps which I wanted to use. For example – twitter, whatsapp, nextcloud and so on. Now remember these are apps which are not going to be installed by default as they are owned by different organizations and due to licensing issues they cannot and will not be a part of any Lineage ROM that you will download officially from the web. So what do you do?

Simple you add the apk’s to your custom build. Remember as long as you are not going to going to distribute it online you should be ok because as mentioned these applications are licensed to different organizations and not open source.

Steps to add a custom apk to your ROM.

Please note : This method works on the docker setup environment.

Step 1:

Download the apk (s) of your choice. For e.g. say I downloaded nextcloud , Nextcloud notes and twitter apks.

Step 2:

Create a folder with the apk name for e.g. NextCloud or Notes. Something short and simple.

Step 3:

Copy paste the downloaded apk into the folder. Remember to download the correct apk to the designated folder 🙂

Step 4:
Change the name of the apk file. For e.g. the name of the NextCloud apk is com.nextcloud.client_3.3.0-30030099_minAPI14(arm64-v8a,armeabi,armeabi-v7a,x86,x86_64)(nodpi)_apkmirror.com.apk!!!! (download it yourself if you think I am joking)
Rename the apk to something simple for e.g. NextCloud.apk
Do not worry renaming will not impact your build.
Step 5:

Add an Android.mk file with text like below to each of the folders. The below is the sample I always use.
Two values need to be changed in this file.
One the LOCAL_MODULE and the other the LOCAL_SRC_FILES.
For e.g from the below example the words FDroid and Fdroid.apk need to be replaced by the apk folder name and the apk name. If I am adding the NextCloud apk then the value for LOCAL_MODULE will be the folder name i.e. NextCloud and the value for LOCAL_SRC_FILES would be NextCloud.apk.

Similarly you have to create Android.mk files for each of the apks that you are adding.

Each folder will have one apk file and one Android.mk file with the below contents

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := FDroid
LOCAL_SRC_FILES := FDroid.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)

Step 6:

Now make a few additions to the following file

vendor/lineage/config/common.mk

Browse down to the PRODUCT_PACKAGES +=

The default line may look like this – (your file would be different from this these are just samples)

PRODUCT_PACKAGES += FDroid GmsCore GsfProxy FakeStore MozillaNlpBackend NominatimNlpBackend com.google.android.maps.jar FDroid FDroidPrivilegedExtension

Add the names of the custom packages you have added to make it look something like this

PRODUCT_PACKAGES += FDroid Flym GmsCore GsfProxy FakeStore MozillaNlpBackend NextCloud NominatimNlpBackend Notes com.google.android.maps.jar FDroid FDroidPrivilegedExtension Telegram Twitter WhatsApp WordPress

save the common.mk

Copy the complete list of packages as you would need it in the next step

Step 7: Pass the package list copied from the previous step and pass it to your docker run command for example now your command should look like …with all the custom packages being passed.

docker run \
-e “BRANCH_NAME=lineage-15.1” \
-e “DEVICE_LIST=tissot” \
-e “SIGN_BUILDS=true” \
-e “CCACHE_SIZE=100G” \
-e “SIGNATURE_SPOOFING=restricted” \
-e “CUSTOM_PACKAGES=FDroid Flym GmsCore GsfProxy FakeStore MozillaNlpBackend NextCloud NominatimNlpBackend Notes com.google.android.maps.jar FDroid FDroidPrivilegedExtension Telegram Twitter WhatsApp WordPress ” \
-v “/home/username/lineageos4microg/lineage:/srv/src” \
-v “/home/username/lineageos4microg/zips:/srv/zips” \
-v “/home/username/lineageos4microg/logs:/srv/logs” \
-v “/home/username/lineageos4microg/cache:/srv/ccache” \
-v “/home/username/lineageos4microg/keys:/srv/keys” \
-v “/home/username/lineageos4microg/manifests:/srv/local_manifests” \
lineageos4microg/docker-lineage-cicd:latest

Step 8: Once the build is complete. Pick it up from the zips folder and flash on your phone.

Check all the apps you installed are running

Step 9: Congratulate yourself for having built your customized ROM!!!
Enjoy!!!

Build a LineageOs4MicroG ROM using Docker on Ubuntu

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.

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

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

LineageOS4MicroG related documentation