Building and installing FOTA community builds

This article should help you to build community builds of B2G OS on your phone. These builds will have "firmware over the air" (FOTA) updates activated for the OS.

Prerequisites

In order to build and install this build, you should have a machine to build on and a host machine. These machines may be the same machine.

On the building machine, you should have all the software needed to make a build for your target phone (B2G OS build prerequisites for more information).

First, you need to check the device:

  • It must be a rooted device.
  • Recovery keys: We need to verify the keys that are used during recovery; these keys correspond to the AOSP keys. They are located in: /res/keys/. They should be the same.
  • Phone with already a recovery (librecovery)

It is possible to build nightly, aurora, and beta versions; to do so, just create 3 different folders: nightly aurora beta (if you only want to build one branch, you can go with one directory only). Nightly is updated every night, aurora corresponds to the latest stable version, and beta corresponds to the version that came before aurora.

Depending on your needs, you can choose to build every branch or only one or two. For every branch you need, follow the steps described on this page. Once you have reached the "Build" paragraph, the instructions will be branch-specific again.

Prepare your first B2G build with the correct BRANCH, as if you were making a build for the target phone. Follow the instructions on this page (Preparing for your first B2G build) until the end of the section "Configuring B2G for your device".

Note: if you have a specific manifest (xml) for config.sh, open this file and replace "master" with the the name of the branch you want in "B2G specific things".

Now, your working directory should be [BRANCH]/B2G/

DO NOT COMPILE YET! 

There are still a lot of changes to be done.

Signatures (only for B2G OS devices by default):

All ROMs for B2G OS devices must be signed; for Android devices, however, this is not mandatory.

We can only provide gecko and gaia; the update will be signed to avoid its installation on the wrong phone.

To do so you will need to have the signature of the root build; just keep build.prop on the phone:

adb pull /system/build.prop

Now, find the value of ro.build.fingerprint; this is the fingerprint.

Localization:

You can build a version containing all the locales by adding this script (langs.sh) on gaia/locales or you can choose to clone only some languages. In this case, modify gaia/locales/languages_all.json to only fetch the languages you cloned #TOVERIF => Building multilocale

If you build for aurora or beta, modify git checkoutmozillaorg/master by using git checkout v2.1 for aurora and git checkout v2.0 for beta in langs.sh

Don't forget to update your repositories before creating a new build.

langs.sh :

 #!/bin/sh
 set -e
 GIT_ROOT="https://git.mozilla.org/releases/l10n/"
 GIT_PROJ="/gaia.git"
 LANGS=$(json_pp < languages_all.json | grep ':' | cut -d':' -f1 | cut -d'"' -f2)
 for lang in ${LANGS}; do
     echo "Syncing $lang"
     if [ ! -d ${lang}/.git/ ]; then
         echo "No repo for ${lang}, cloning new one"
         git clone ${GIT_ROOT}${lang}${GIT_PROJ} $lang || true
     else
         echo "Updating close for ${lang}"
     cd ${lang} && (git fetch origin && git checkout origin/master) || true && cd ..
     fi;
 done;

Build configuration

You also need a .userconfig file for your build:

Create a file at the root of [BRANCH]/B2G/ named .userconfig and paste these lines :

 export SYSTEM_PARTITION=/dev/block/platform/msm_sdcc.1/by-name/system # to specify the system partition, find info with adb shell cat /proc/mounts
 export DATA_PARTITION=/dev/block/platform/msm_sdcc.1/by-name/userdata # to specify the data partition, find info with adb shell cat /proc/mounts
 export VARIANT=userdebug #to include gaia
 export PRODUCTION=1 #to have a user build
 export B2G_UPDATER=1
 export B2G_UPDATE_CHANNEL=aurora  #to modify [BRANCH]
 export ENABLE_DEFAULT_BOOTANIMATION=true #to have B2G boot animation
 export GAIA_DEV_PIXELS_PER_PX=1.5
 export LOCALE_BASEDIR=locales/ #Languages folder 
 export LOCALES_FILE=locales/languages_all.json #all languages for the build 
 export GAIA_KEYBOARD_LAYOUTS="$((find gaia/apps/keyboard/js/layouts/*.js | sed -e 's|gaia/apps/keyboard/js/layouts/||g' -e 's/\.js$//g') | tr -s '\r\n' ',' | sed -e 's/,$//g')" #All keyboard, you can change this with keyboard you want 
 export GAIA_DEFAULT_LOCALE=fr #languages by default, fr (french) for example
 export B2G_FOTA_DIRS="system/fonts system/b2g" #fira font bug
 export FOTA_FINGERPRINTS="[your fingerprint]"

You will need to edit the following variables:

  • SYSTEM_PARTITION (use adb shell cat /proc/mounts to know the partition)
  • DATA_PARTITION (here again, you can use adb shell cat /proc/mounts )
  • B2G_UPDATE_CHANNEL depending on your channel (aurora, beta, nightly)
  • GAIA_DEFAULT_LOCALE depending on the locale you want
  • (not needed but perhaps useful: GAIA_KEYBOARD_LAYOUTS (see the comment))
  • FOTA_FINGERPRINTS: add value of ro.build.fingerprint
  • GAIA_DEV_PIXELS_PER_PX: to know the correct settings for your device, please, visit this web-site with this device.

You can remove the parts following the pound sign (#) (including the sign itself). These are comments, and their only purpose is to explain what the line is doing.

After that, you will need to setup information about update url:

 cd gecko/
 git checkout -b [VERSION NUMBER or master for nightly]-local --track mozillaorg/[VERSION NUMBER or master for nightly]
 edit app.update.url in b2g/app/b2g.js you can keep %target% etc.. or you can just have something like
 pref("app.update.url", "http://[DOMAIN]/[PHONE NAME]/[BRANCH]/update.xml");
 

After that, in order to keep your modification, make a commit:

 git commit -a
 Repeat all these steps with the different branches to have a beta/aurora/nightly build.

Now the build configuration is done. All future steps must be repeated at each build in each branch folder.

Build

Setup for building a (new) update is: 

 cd [BRANCH]/B2G/ #to be in the good folder
 git pull # to update the repo code
 ./repo sync #to update repo code for android and B2G do not use the -d option, doing this will remove your modification
 cd gaia/locales/ && ./langs.sh && cd ../../ #to update languages
  
 ./build.sh # to building b2g
 ./build.sh gecko-update-fota # to build b2g and gaia in a .zip and .mar
  
 BUILDID=$(grep 'BuildID=' objdir-gecko/dist/bin/application.ini | cut -d'=' -f2) # setup buildid variable
 VERSION=$(grep '\nVersion=' objdir-gecko/dist/bin/application.ini | cut -d'=' -f2) # setup version of gecko variable
 python tools/update-tools/build-update-xml.py -c out/target/product/[PHONE NAME]/fota-[PHONE NAME]-update.mar -O -u http://[DOMAIN]/[PHONE NAME]/[BRANCH]/fota-[PHONE NAME]-update.mar -i $BUILDID -v $VERSION -V $VERSION | tee /var/www/[BRANCH]/update.xml # Modify this command with your information: good path to .mar, good path to .mar in url of update.xml, the command output should be into a file update.xml; this update.xml will go on your host machine, this corresponds to the file call by the system to find new update.
 cp out/target/product/[PHONE NAME]/fota-[PHONE NAME]-update.mar /var/www/[BRANCH]/fota-[PHONE NAME]-update.mar #to move .mar in the server 
 cp out/target/product/[PHONE NAME]/fota/partial/update.zip /var/www/[BRANCH]/update.zip #to move .zip in the server
 pushd /var/www/[BRANCH]/ # to go in the server file 
 sha1sum $(ls) | tee sha1.checksum #to have a signature file
 popd

If you want an IRC bot you can use ii or a build bot. I have made a script of this HERE (for more information on what a build bot is, see http://buildbot.net/ )

Flash the phone and try your build:

To install a build on a phone, just follow these steps:

 adb reboot recovery

On the recovery go down using the down volume button to select the "apply update from adb" line, then touch the power button:

 adb sideload out/target/product/[PHONE NAME]/fota/partial/update.zip

Existing build by community

Document Tags and Contributors

 Last updated by: chrisdavidmills,