Some useful Docker commands

Docker is a great tool for building and shipping apps. At /e/OS the organization were I work we use it to build our officially supported Smartphone OS.
I used to build ROM’s using the traditional Repo Sync way , writing commands and waiting for them to execute. After trying out Docker I have now become a fan!
Docker combines all the commands and executes them without you having to interfere in the process.

These are a set of commands I find very useful when executing or using Docker containers.

Command to Stop all running containers
(use with caution)

docker stop $(docker ps -aq)

Command to Delete all containers

(use with caution)

docker rm $(docker ps -a -q)

Command to Delete all images

(use with caution)

docker rmi $(docker images -q)

Command to Show all images

docker image ls

Command to Remove image by id

You can retrieve the image ID by executing the previous command

docker rmi 75f08d5b848d

Here the 75f08xxxx you see in the command above is an image id retrieved by the above command

Interested in learning more about Docker ? Try out this tutorial

How To dirty install a custom ROM

This post assumes you are experienced in installing custom ROM’s and have TWRP recovery already installed on your Phone

What is a Dirty Install : The difference between a clean install and a dirty install is that here there is no wipe or cleaning up of the existing data.

Why or when would you do a Dirty install: When you do not want to lose existing data on your phone, are too lazy to make a backup of your data 🙂

PreRequisites

  • Smartphone with TWRP installed
  • A working USB data cable(there are cables for charging only )
  • Download the zip file of the custom ROM you plan to install

    Ensure you have downloaded a ROM which was built specifically for your device.
    Flashing builds incompatible with your device can brick your phone.
  • Take a backup of any important data you have on your phone
  • Ensure you have developer options set on your phone

The Steps

  • On your phone remove any pattern , fingerprint locks you may have set
    This is to avoid any issues during the install process
  • Reboot to Recovery

    You can also boot into recovery by connecting your phone with a data USB cable to and adb enable computer and typing the below command on a console

    adb reboot recovery
  • Copy the .zip file – the ROM you want to install – from your PC to your phone

    You can also do this using the below adb command from the PC console

    adb push download.zip /sdcard/
  • In TWRP main screen tap the Install button
  • Browse to the zip file and swipe to install
  • Once the install is successful you will see an option to Reboot to System

After this the new OS should boot on your phone. Enjoy !!

How to Clean Install a custom ROM

This post assumes you are experienced in installing custom ROM’s and have TWRP recovery already installed on your Phone

PreRequisites

  • Smartphone with TWRP installed
  • A working USB data cable(there are cables for charging only )
  • Download the zip file of the custom ROM you plan to install

    Ensure you have downloaded a ROM which was built specifically for your device.
    Flashing builds incompatible with your device can brick your phone.
  • Take a backup of any important data you have on your phone
  • Ensure you have developer options set on your phone

The Steps

  • On your phone remove any pattern , fingerprint locks you may have set
    This is to avoid any issues during the install process
  • Reboot to Recovery

    You can also boot into recovery by connecting your phone with a data USB cable to and adb enable computer and typing the below command on a console

    adb reboot recovery
  • In the TWRP tap on the button marked Factory Reset
  • In the TWRP tap on the button marked Format Data

    the would remove any encryption on your phone if not encrypted wipe Dalvik + cache + data
  • Copy the .zip file – the ROM you want to install – from your PC to your phone

    You can also do this using the below adb command from the PC console

    adb push download.zip /sdcard/
  • In TWRP main screen tap the Install button
  • Browse to the zip file and swipe to install
  • Once the install is successful you will see an option to Reboot to System

After this the new OS should boot on your phone. Enjoy !!

/e/ : A user Data Privacy respecting operating system

A lot has been written and discussed in the media about the unwelcome intrusion by big business houses into our private lives. Details about the Facebook data sharing scandal with Cambridge Analytic or leaks about the way Google has been ‘Googling’ our personal information and sharing it with its business partners are on news channels everywhere. If you have ever browsed to purchase a product on the internet, then you would have observed subtle hints of this intrusion in action. For days after you would be seeing advertisements from companies selling products similar to the one you were browsing. This happens when your browsing behavior is captured and shared with business houses. These business houses now attempt to coax you into buying their products which are of a similar kind. Welcome to the world of zero data privacy!

To understand the situation better, have a look at your smart phone and the applications you use on a daily basis. On android phones, almost every second application is in some way connected to Google. Gmail, Google maps, Google Assistant, Google Drive the list is endless. When you install these apps they ask you for your permission to access your contacts, your text messages, files, folders, images etc. While on the face these requests may look harmless, take some time and think about the issue seriously. What if the product or service you had browsed was of a personal nature? That information in the hands of a stranger could be dangerous for you in the long run. This pilfering of your personal data is happening through your smartphones and computers every single day, every minute. Google, Microsoft, Apple, Amazon everyone has a finger in this pie. What is even worse is that they are making billions out of your personal information! So now that I have scared you enough you might be wondering if there is a way out of this mess? Do not worry help is just round the corner.

Introducing /e/. /e/ is the brain child of Gaël Duval – the man behind the popular linux distribution – Mandrake Linux. The popular Linux OS is still remembered for its extremely user friendly interface and smooth and efficient functioning. It helped introduce millions to linux. After moving out of mandrake Linux which was renamed to Mandriva in 2006 Gael was the Chairman and Chief Technology Officer at Ulteo. The company is bought by AZNetwork group in 2015.In 2016, he co-founded NFactory.io, an incubator-accelerator of “startups.

The rampant ‘data pilfering’ on smartphone devices by Google and Apple set Gaël thinking. The result was a series of three articles ‘Leaving Apple & Google: my eelo odyssey’. In these articles he announced his intention to come out with an alternate platform for devices. An operating system which would respect the individual and value his right to privacy. A Kickstarter campaign to fund the idea was launched. People from around the world contributed. This was a clear indication that the concept had popular support, all that it lacked was a clear direction.
Gaël has come out with a mission which declares the following as its objectives:

 

  1. We make available independent and open source IT infrastructure products & services, with an emphasis on respect for user data privacy, for the benefit of all.
  2. We think that /e/ can have a global, worldwide impact as a major open source project in the public interest. It will help by freeing users from personal data spying and advertising.
  3. /e/ is about freedom and privacy in the digital world.

A copy of the manifest is attached below:

To set the record straight, Gaël’s team is not writing the code from scratch. It has picked up a branch from the Lineage code base and has started with it. The lineage code base is a free open source operating system based on the android platform which caters to smartphones and tablets. The code is accessible through GitHub.

At present /e/ has a team of about fifteen developers working full time under the direction and guidance of Gaël developing the first release of the operating system. Gaël’s team is currently working on various elements in the operating system which he insists would have a great UI. Those who have used Mandriva earlier can definitely look forward to Gaël delivering on that promise! Various third party applications are currently being integrated . The base OS would have a “reasonable minimum” set of application to begin with. The idea being that a user could always add more applications as per his or her requirement. There would be no forceful installation of applications that sit there unused taking up space and sending back the users personal information!

The team target to release their first beta version of the OS by August end of 2018. The next step would be the opening up of the source code repository. This should be the trigger for developers from around the world to pitch in and add their code as well. Version 1.0 of /e/ is targeted for the end of 2018 or early 2019.

/e/ has come out with a road map for its development activities

For more information about /e/ go to the web site.

To read more about Gaël Duval

To contribute to /e/ financially

How To-set up adb

This post covers the set up of adb tool on windows, mac or linux systems. To find out how to install adb or fastboot click here

Tip: Disable any security keys, patterns or passwords you have set on your device before trying out any installations. Having a password or lock can cause issues in some installations.You can always set them up later.

To use adb with your device, you’ll need to enable developer options and USB debugging:

  • Open Settings, and select “About”.
  • Tap on “Build number” seven times.
  • Go back, and select “Developer options”.
  • Scroll down, and check the “Android debugging” or “USB debugging” entry under “Debugging”.
  • Plug your device into your computer.
  • On the computer, open up a terminal/command prompt and type

    adb devices
  • A dialog should show on your device, asking you to allow usb debugging.

  • Check “always allow”, and choose “OK”.

adb should now be running on your device.

Want to setup Fastboot ? click here

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.

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

A web with a view

<span>%d</span> bloggers like this: