Building a FirefoxOS build environment

This will be the first in a short series of posts about hacking FirefoxOS onto devices. I will be using an older Samsung Galaxy S2 for the examples and tutorial, so if you want to follow along, get one!

First up, we will be configuring our build environment. I use Ubuntu-14.04 in the examples, but it should be pretty similar on many other distros and OS’s

One quick note before we start, is that you will need at least 30GB free drive space, as well as at least 4GB RAM to get this right…

The first step is to get the bare essentials

sudo apt-get update
sudo apt-get install autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib git ia32-libs lib32ncurses5-dev lib32z1-dev libgl1-mesa-dev libx11-dev make zip

You will also need a JDK from this PPA

Next, you need the i386 arch repos in order to grab a lot of i386 dependencies for the build.

sudo dpkg --add-architecture i386
sudo apt-get update

You then need to install

sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0

Add in the alternatives for gcc-4.6

sudo apt-get install --no-install-recommends autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib gcc-4.6 g++-4.6 g++-4.6-multilib git lib32ncurses5-dev lib32z1-dev zlib1g:amd64 zlib1g-dev:amd64 zlib1g:i386 zlib1g-dev:i386 libgl1-mesa-dev libx11-dev make zip libxml2-utils 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 1 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 2 
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 1 
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 2 
sudo update-alternatives --set gcc "/usr/bin/gcc-4.6" 
sudo update-alternatives --set g++ "/usr/bin/g++-4.6"

Great! You should have a pretty decent working environment now! Congratulations!

Since we are building for Samsung Galaxy, we will need Heimdall too

sudo apt-get install heimdall-flash

The heimdall flash (64bit) from Ubuntu repos works best.

Now cconfigure ccache. The buld system uses ccache to make things quicker and easier. I really recommend you use it!

ccache --max-size 10GB

You may need to also update your udev rules now too, but generally on Ubuntu, Heimdall will do that for you.

Install and configure ADB also, and then do a backup

adb pull /system <backup target dir>/system

You are now ready to go and grab the FirefoxOS code!
Next article will detail this, coming soon!

Liked this post? Follow this blog to get more.