Building Firefox from source
I just want to get the code, edit some stuff, and build it, just that, why it is so complicated?
I tried this guide which seemed to be what I need, but if you see the original guide it is completely different and complicated, using bzr
and stuff.
I follow the script:
sudo apt-get build-dep firefox
sudo apt-get install -y fakeroot
apt-get source firefox
# here it gets firefox_55.0.2+build1-0ubuntu0.16.04.1.debian.tar.xz, firefox_55.0.2+build1-0ubuntu0.16.04.1.dsc and firefox_55.0.2+build1.orig.tar.xz
tar xf firefox_55.0.2+build1-0ubuntu0.16.04.1.debian.tar.xz
tar xf firefox_55.0.2+build1.orig.tar.xz
vim debian/config/mozconfig.in
# trying to fix https://bugs.launchpad.net/ubuntu/+source/firefox/+bug/1710993
# echo 'ac_add_options --enable-alsa' >> debian/config/mozconfig.in
dpkg-buildpackage -b -us -uc
# some bugs of missing SOURCE_CHANGESET file
touch SOURCE_CHANGESET
dpkg-buildpackage -b -us -uc
# some issues with missing browser/config/version.txt file
ln -s firefox-55.0.2+build1 browser
touch browser/config/version.txt
dpkg-buildpackage -b -us -uc
It seems to depend of a lot of locales and keeps criticizing the message debian/build/rules.mk:366: *** We aren't in the full source directory. Please use "TARBALL=<path_to_orig.tar.bzr>". Stop.
.
I am on the same directory I extracted the files, the source is there, I don’t need to change any other package for now, how can I build it?
Compiling the development version of Firefox (‘Nightly’) can be done with some careful preparation. (This is the best version to use when producing patches and improvements for ‘upstream’). It is mandatory to undertake such a task far away from a production installation of Ubuntu and I would very strongly recommend the use of a Virtual Machine dedicated to this task only.
The technique below was tested with Ubuntu Zesty Zerus 17.04 (running in a dedicated Virtual Machine!) and it would be best to always use the most modern version of Ubuntu to compile Firefox as dependencies used will for the most part be quite modern. I have not tinkered with endless build options but feel free to do so yourself on your own build!
Note: The build system needs a huge amount of RAM as well as a very large amount of Disk space. I would suggest 8GB RAM, 30GB of free Disk space and as many cores as your VM will allow, this combination certainly worked on my system. Note: the build system will fail with lesser allowances of RAM, HDD space and available cores…
1. Build Dependencies:
First install some build dependencies, starting with the very latest stable rust compiler:
wget -O - https://static.rust-lang.org/rustup.sh | sh
Then a more standard installation from the Ubuntu Repositories:
sudo apt-get install autoconf2.13 libgtk-3-dev mercurial llvm-4.0 clang-4.0
libgconf2-dev libdbus-glib-1-dev libpulse-dev yasm build-essential libgtk2.0-dev
libxt-dev
2. Clone the Firefox Development Repository:
Next to clone the Firefox Mercurial repository, make yourself a cup of tea while this one is downloading:
cd $HOME && hg clone https://hg.mozilla.org/mozilla-central
3. Build Firefox:
Finally to build the source code itself, time for another cup of tea and probably have a sandwich as well as this will take a very long time to build on even the fastest computer:
cd $HOME/mozilla-central && ./mach build
And when this complete you should see this message:
43:58.38 We know it took a while, but your build finally finished successfully!
To view resource usage of the build, run |mach resource-usage|.
To take your build for a test drive, run: |mach run|
As well as a link with a few tips on where to go next…
4. Run Firefox:
Now simply run:
cd $HOME/mozilla-central && ./mach run
and you are running the latest development version of Firefox! You can now start hacking the source code and if your patches are up to scratch you can then submit them and get you work included in this great browser.
5. Updating the source:
You should periodically update the source by changing to the source directory and updating with standard mercurial repository commands. The following one line should accomplish this for you:
cd $HOME/mozilla-central && hg pull && hg update
Here is a standard update run on my own system:
andrew@ithaca:~/mozilla-central$ hg pull
pulling from https://hg.mozilla.org/mozilla-central
searching for changes
adding changesets
adding manifests
adding file changes
added 767 changesets with 4619 changes to 3590 files
(run 'hg update' to get a working copy)
andrew@ithaca:~/mozilla-central$ hg update
3581 files updated, 0 files merged, 141 files removed, 0 files unresolved
Following this you should recompile:
cd $HOME/mozilla-central && ./mach build
And perhaps take a walk while this is recompiling :).
6. Gratuitous screenshot:
Below is a screen shot of the latest ‘Nightly’ running on my 17.04 system:
And remember: ‘Have Fun!!’
Notes:
- Contributing to the Mozilla code base: The starting steps to incorporating your patches into the Firefox code base…
- Mozilla Firefox: Linux build preparation: A good starter for this project although a few modifications and additions were required. I could not get the
bootstrap.py
installer to work so instructions for this were given manually. - The rust compiler in Ubuntu 17.04 was too old so instructions for installing directly from the rust site were given. Rust has a 6 week release cycle so this may be the better option for those who prefer the bleeding edge. Some notes here…
- Firefox Nightly: Some more detail about the Firefox Nightly development and release model.