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

Advertisements

How to flash lineage official OTA on the MiA1

Let me explain the process of how to flash lineage official OTA on the MiA1. The reason why this needs a separate post is because it is slightly complicated and the chances of failure are high. The process of flashing the lineage ROM on the MiA1 has changed now that we have a signed Over the Air (OTA) ROM coming in every week on Tuesday.
I am assuming that you have a basic understanding about flashing ROM’s  and understand why custom ROM’s are flashed. I am also assuming you know about platform tools like adb and fastboot and have a working adb and fastboot on your PC.

WARNING: As always remember there is a good chance  that the process of flashing custom ROM’s can seriously damage your phone and even permanently brick it i.e. render it useless. You have been warned  and are doing so at your own risk.

Now that we are done with the warning lets start flashing.
Before you proceed download these files.
Downloads:
Please note these files are available either from this web site or you can search for them on the web and download them from their original sites. I leave the option to you. The point is you would need these files to continue with the task at hand.

Copy required files
Copy the boot recovery image file into the folder where you installed adb on your PC.
Copy the remaining files on to your phone. These files are Lineage ROM for 10 July + Mind the Gaps + TWRP installer.
Copy them into the download folder on your phone. You can either use the PC or try it through adb push is you are comfortable with that.
The command for an adb push would be as under

adb push TWRP-installer-3.2.1-with-Tissot-Manager-2.3.zip  /Downloads
adb push <complete file name to be pushed including extension> /<destination>

Coming from Stock MiA1 ROM follow the steps given below. These steps should be the same even if you are coming from other unofficial version of the Lineage ROM  and want to install the official lineage ROM.

fastbootmode

Step 1. Boot phone into fastboot mode

From a PC which has adb and the correct drivers installed type the above command to boot the phone into the fastboot mode. This is the mode where you get the picture of a bunny wearing the Chinese army hat!

Alternately you can also switch off the phone. Press and hold volume – and power button and keep holding till you feel it vibrate. This should happen in 1-2 seconds. Then release. The bunny in the hat should be on your screen now!

Step 2 : From the folder where you have installed adb and copied the Boot recovery image type the below command in the console.
fastboot boot boot-recovery.img

Within 2-3 seconds the boot image will be hot booted on you phone and you should be in the TWRP screen.

Step 3. Wipe cache, data and system

Step 4. Flash the Lineage Official ROM for July 10. This is a slightly weird step required because flashing the latest ROM directly will give you an signature verification error!!!
Hope this error is fixed in later versions of the ROM.

Step 5. Flash the TWRP installer .
This TWRP is by CosmicDan and specifically create for the Tissot. Please note the TWRP screen will give you very detailed instructions at each stage of the installation. Read it carefully. In spite of all the help on this page or the Lineage  web sites the setup may still fail in some cases. That is where the messages on the TWRP screen would come in handy. Read the messages and you would be able to resolve most of the issue on your own.

Step 6.   Reboot Recovery. This is a required step
Step 7.   Flash Magisk 16.6
Step 8.   Flash Mind the gapps
Step 9.   Reboot System
Once you have the ROM up and running. Go to  System >> About phone >> Tap the build number 7 times and you will be into developer mode. Enable USB debugging and Advance restart. If you are not familiar with these steps click here for details  
This is just in case you are stuck again and need to recover your phone then it would be helpful to have USB debugging enabled on your phone to allow access through adb from your PC.

Now remember you are in the July 19 version of the ROM.

To get the latest OTA update

  • Go to System >> About Phone >> LineageOS updates and click to download the latest build for your phone.
    Downloading_6%

    This is a painfully slow download so have patience and relax.
    The download from the lineage web site can take hours. It took about 4 hours on my phone that too on a 10 MB internet WiFi connection!
    Once the download is complete install the build . This will also take some time.
    Preparing for first Boot

When the build is finally installed, you can check the results in settings.
The latest ROM released on the Tuesday of the current week should be showing up.

Here there is an important thing to note. Once the new ROM is installed it will wipe out your magisk and TWRP installation .
Mind the Gapps will work seamlessly.
Flash TWRP and magisk again if you need them.

Settings_1

Best of luck!

How to flash official lineage ROM for Xiaomi MiA1 tissot

Update 18 July 2018:
The first OTA Over the air ROM rolled out on the Tuesday 17, July. While this was a milestone moment for those who had the Lineage ROM on the Xiaomi Mi A1 there was a major hiccup in the release.
The first problem was the OTA downloads were extremely slow. When it finally made to the user’s phones the update failed.

Screenshot_Updater_20180718-022951

The telegram group for MiA1 was flooded with messages from MiA1 users and the issue is expected to be resolved in the next build. There is a build every Tuesday.

The current work around is as under ;

Please note this option works when coming from the previous week’s signed Lineage official ROM

Step 1: Download the latest ROM the July 17 version from here  
Please note the download may take a long time. On my 10 Mb line it took a couple of hours!!! Once downloaded copy the ROM on to your phone.

Step 2: Reboot to recovery

Please DO NOT WIPE ANYTHING

Step 3 : Flash the latest lineage official ROM, downloaded in Step # 1

Step 4: Reboot to recovery again

Step 5: Flash Mind the Gapps

Step 6: Flash Magisk

Step 7: Reboot

—————–

The official lineage ROM for the Xiaomi MiA1 was released on 10 July 2018. The release was eagerly awaited by thousands across the world. The only problem was that when it rolled in the user were in for a surprise… a slightly unpleasant surprise. The flashing of the ROM required a whole new set of steps and there were problems at each stage. I consider myself as quite an expert at flashing the unofficial ROM‘s..at least on my MiA1 and had even built a ROM for the MiA1  based on code from GitHub. but I had some real problems this time. After a lot of false starts I finally managed to get the official ROM on my phone.Given below are the steps I took. You would need adb and fastboot on your PC to achieve all this. In case you do not have the same please click here and also enable phone developer options.

Step 1:Download and copy the files mentioned below to your phones Downloads folder. Copy the Boot recovery.img file to the adb folder.

Step 2: If coming from a the unofficial Lineage ROM get to the boot loader screen.
Power off phone.
Hold Power + Volume down button.
When the phone vibrates release. You should be in the Boot loader screen.

Step 3: From your PC go to the folder where you have adb and type

fastboot boot boot-recovery.img
Within seconds the recovery image will be loaded on to you phone and you should be in the TWRP screen.

Step 4:  Wipe cache, data and system

5 . Flash Lineage Official

6. Flash TWRP by CosmicDan file TWRP-Installer-3.2.1-with-Tissot-Manager-2.3.zip
This TWRP will install itself on both A and B partitions of your phone.

7. In TWRP Reboot to Recovery

8. Flash Magisk 16.6

9. Flash Mind the gapps

10. Reboot System and wait for the phone to boot up.

Download the files from here.

The Football epidemic – cause and cure

fifa world cup

Every four years a strange disease sweeps across the globe. People from different races, cultures and tribes, start showing similar symptoms. Strangers start talking and best friends become enemies. Employees trudge into workplaces like zombies. There is no known cure for this malady. It does not differentiate between doctors, scientists, politicians, beggars or billionaires. Luckily the infliction lasts for a month. It dissipates the way it appeared, slowly. For days after the fever had abated some of us walk around with a silly grin on our face while others wander around with drooping shoulders and talk to themselves. The name of this disease is ‘ Football Mania’ and in case you are still wondering, it comes along with the football world cup held once every four years.
I was struck by this illness way back in the eighties. An article in the Readers Digest mentioned about a man named Paolo Rossi. He was a football player from Italy. The article described his skills on the field in detail. We had a black and white TV then and I decided to watch and validate this article for myself.
My father was an army officer. Unlike most men his age or in his profession he did not like to watch sports on TV. He also did not like to watch the news, soap operas or movies. Now he must be in his eighties and we are still not sure what exactly are his areas of interest. Sorry I digressed. Returning back to 1982 it was not exactly easy to watch TV in a house, knowing that somewhere in the background my father lurked. Yet somehow I managed it and ended up watching almost all the matches. The 1982 World Cup was the first world cup I ever saw and unknowingly I was infected by ‘Football Mania’.
Over the past four decades I have watched most of the matches of the World Cups. The only times i missed them was when I was traveling or posted in remote corners of the country – in places where there was no electricity or TV. I saw Germany,Brazil,Italy, France, Spain all become champions. Between them they covered most of the continents. Coming from a nation of one billion plus – India, it hurt. We are a cricket nation. We think breathe and dream cricket. We do not stand anywhere when it comes to Football. Even tiny Nepal defeats us! Thank God for Bhutan we somehow manage to get a few points but that is about it when we talk about India’s Football talent. That brings me to another feature of these world cups. Every four years the citizens of various countries temporarily ‘adopt’ the nationality of countries playing in the World cup! That is if there is a match between Argentina and Germany and I do not like the Germans, for the ninety minutes plus extra time if any, I become an Argentina supporter. I boo every time the German’s get possession of the ball and cheer every time they are shown a yellow card! After the final whistle is blown everything returns to normal and I am back to being an Indian busy applying for a German visa! Now isn’t that the perfect example of international brotherhood? To highlight this point further let me quote an incident which happened two days back. When South Korea defeated Germany and indirectly helped Mexico enter the next round, we witnessed something similar. People in Mexico went up to the South Korean embassy and thanked the Ambassador and even got him to take a few sips from a bottle of Tequila!

To those not interested in sports such behavior may look weird but then isn’t it a noble and better way to solve our issues and differences? ‘Fighting’ or rather competing on a sports ground rather then going to war and destroying each others on battle fields?

What Data Privacy is and why is it important

The purpose of this article is to explain what Data Privacy is and why is it important in layman’s terms. Of late most of us have seen a spurt of emails with the subject line mentioning updates to Data privacy policy. In my case the first one came from Xiaomi – since I own a phone of theirs, then another mail came from Google and now I see even my website hosting provider has issued one!

If you watch the news, you must have seen the videos of Mark Zuckerberg the founder of Facebook appearing before a committee of the US Senate last month. The events that led to this senate hearing occurred a couple of year’s back. It was a U.K based political consulting firm, Cambridge Analytica that triggered this sudden avalanche of interest in Data Privacy. Cambridge Analytica, combined data mining, data brokerage and data analytics to extract information from Facebook users.

The method adopted by Cambridge Analytica was rather simple. Through an application called ‘thisisyourdigitallife’ it asked Facebook users if it could collect their data. About 270,000 users volunteered and gave permission to the application to collect and share their data. Now with this approval and in violation of Facebook’s policies Cambridge Analytica gained access to the friend networks of these 270,000 users. Cambridge Analytica using this application illegally gained data on about 50 million users who were in the friend’s network of these 270,000. Remember that a majority of these 50 million, had not explicitly allowed Cambridge Analytica permission to access their personal data.
The data collected basically related to the user behaviour and browsing patterns. It analysed political leaning of the user and accordingly targeted segments of Facebook users with what it called ‘Strategic Communications’. While many mainstream political scientists question CA’s claims about the effectiveness of its methods of targeting voters the matter was considered serious enough by most governments of the world to suspend its operations in their territories.

By its own admission Cambridge Analytica declared that they were involved in 44 US political races in 2014. In 2015, CA admitted it performed data analysis services for Ted Cruz’s presidential campaign in the US. In 2016, CA claimed to have worked for Donald Trump’s presidential campaign as well as the ‘Leave.EU-campaign’ for the United Kingdom’s referendum on European Union membership. CA’s role in those campaigns has been controversial and is the subject of ongoing criminal investigations in both countries. As the bad press and negative publicity from all these disclosures reverberated across the world, on 1 May 2018, Cambridge Analytica and its parent company filed for insolvency and closed operations.

Now does that mean that all is well and the world is a better place to live in… well actually no. There are still some huge monsters out there and they are not hiding under the bed but still using your data and making money out of it. The worst part of it is that we are willingly providing our approval to these ‘monsters’ to collect and use our personal data.

Most of us own smart phones. Every time we install an application on our phones it innocently asks us permission to access the camera, microphone, contact list, folders etc, etc. We have become so used to these requests that we hardly read them and approve the request. That is when the problem starts.
Google, Amazon, Microsoft and Apple are the giants in the tech world. Today we have reached a stage where we are totally dependent on their application, products and tools. If you do not believe me try this simple test. Try removing or not using google products on your android phone for a day. This would mean not using Gmail, You Tube, Google Maps amongst other applications which you downloaded from Google Play. It would be next to impossible given our dependence on Google and other such companies for most of our mundane internet work. Be it sending or receiving emails, browsing websites, purchasing or selling products online we are puppets in the hands of these massive tech giants.

Now consider this scenario. Assume you want to buy a shoe. You do not have the time to go to the local shoe store, or maybe the design or make you are looking for is not available locally. The first thing you would do is open up your browser and search for the brand of your choice. We would search through Google or check out the options available on Amazon or other similar online retailers. Once you have searched you may or may not decide to purchase the shoe online. Suppose in our scenario you do not go ahead with the online purchase but decide to purchase it locally. As far as you are concerned the matter of the shoe is closed, right? Well the internet and these massive companies do not think so. After this, for a few weeks if you are observant you will notice that as you log on to any web site, you would see advertisements for shoes showing up on the sides of the pages you are browsing. This goes on for a few days. Ever wondered why that happens?

This happens because the information that you had browsed the web, searching for shoes is captured by your browser and passed on by the Googles and Amazon’s of the world. They in turn pass it on to the various web sites which sell these products. IN this way these advertisements customized for your requirements start appearing on to your web browser. If you happen to notice the ad and go ahead and click on it that takes you to the shop where you can buy the shoes. In case you make a purchase then a commission from the sale goes to all these intermediaries who essentially tricked you into buying their product. In essence the internet search engines and business portal make billions out of millions of users like you and me. Now how does that feel? Do you feel cheated or you are ok with being spied upon?

In the above scenario it was a simple shoe now imagine if you happened to browse a porn site or purchased some lingerie online. As a human being you have every right to do that. The problem is that information is also passed on to all the relevant companies who can target you in future. Imagine the case where the same PC or Laptop is shared between multiple people in the same house. How would you like it if your children or grandparent suddenly find their web site plastered by ads for such products? Another slightly dangerous aspect of this breach of data privacy is that organisations where you apply for jobs may want to check you background through your internet searches. The fact that you have in the past browsed such sites will make you un-fit to get jobs.

Then there is another side to this whole story. A lot of website propound extremist ideologies and display information about how to make explosives or propound violence. This browsing information has in the past been used by police organisations to track and arrest operatives from perpetrating acts of violence and mayhem. By tracking onsite browsing data, intelligence organisations have been able to find such criminals before they could put their plans into action. There are specific group who search the web for people who visit child- pornography sites or have such information. Such investigative work has resulted in the arrest across the world. While this is a positive aspect of such data collection it should be remembered that there is a fine line between protection and harassment and too often government agencies tend to overstep their limits and monitor citizens above and beyond what is permissible. Examples are the extreme cases of censorship applied by the Chinese government.
All this bring us to the question as to what is it that we as citizens do to protect ourselves from such blatant violation of our privacy. One way is read carefully the pop-up that come up when you install applications on your cell phones. If you feel that it is too intrusive do not accept it. Find alternative applications and products that respect your privacy and do not intrude into your private life. We will be publishing details of such applications and tools on this web site. Keep reading and stay safe!

An online diary of stories and articles

%d bloggers like this: