Playing around with upstream Mozilla Firefox on Debian GNU/Linux 7.0 (wheezy)

Because of a situation with the Debian Iceweasel maintainers’ packages for the current release (18) on Testing (wheezy), I decided I could as well take this opportunity to try to install upstream Firefox in the cleanest fashion possible.

I have actually run upstream Firefox on Debian GNU/Linux (even Nightly, or Minefield back when it was called that) in the past on multiple occasions, facing various awkward desktop integration issues along the way. Additionally, the Firefox binaries had to reside deep within my home directory, which seemed a little tacky. But I just found out that this does not necessarily have to be the case.

While searching for information about installing the original-brand Firefox on Debian, I came across this forum topic and quickly worked out my way from the instructions presented there. I think I’m missing the OP’s context for the switch (Iceweasel 3.5 on squeeze maybe?), but that is not terribly important now, three years after the fact.

There are alternative guides floating around which advise adding foreign distribution repositories to your APT sources. Needless to say, this is a really bad idea unless you are very sure of what you are doing. (Hint: You are not.)

Many of the following instructions are pretty much the same as in the forum post, just adapted to account for some minor changes over time, as well as some personal preferences. I also find my version of this guide much more palatable in presentational terms. Additionally, I am particularly adamant about not changing anything in /usr for this procedure, preferring /usr/local instead in order to avoid package conflicts in the future.

WARNING!
The steps below involve modifying your system installation and configuration as root. I am not responsible for any problems resulting from following this guide or failing to perform some specific step correctly. When in doubt about some particular command, you should consult the relevant documentation first.

You need to obtain the appropriate Firefox build for your architecture (x86 or x86_64) from ftp.mozilla.org. The default build offered in www.mozilla.org for Linux systems is ALWAYS x86 (32-bit), which is most likely not what you want on x86_64 (64-bit). I’m not going to stop you from trying x86 Firefox on x86_64 — it will most likely work, but plugin compatibility issues may arise, or you might get the ugly fallback Gtk+ theme unless your Gtk+ theme engine of choice is available through multiarch. It’s your choice.

What Mozilla doesn’t tell you is that you can obtain x86_64 builds from them directly.

As of this writing, ftp://ftp.mozilla.org/pub/firefox/releases/latest/ always holds builds for the latest version of Firefox from the release channel. Figuring out where Aurora and Nightly channel builds reside is left as an exercise for more adventurous readers. (Hint: ascend a few levels.)

First of all, purge Iceweasel and any related packages that you don’t need, unless you actually do — for instance, the Mozilla javascript library (provided by libmozjs<var>XX</var>d, XX being any given major version number) is required by gxine (a graphical front-end to Xine), of all things.

# apt-get purge iceweasel xulrunner-.\* libmozjs.\*d

At the very least, getting Iceweasel and the binaries and alternatives it installs on /usr out of the way should be paramount for the rest of this procedure. The guide I previously mentioned recommended to hold Iceweasel and friends instead, but that’s not really necessary since you can actually accomplish a lot with /usr/local and /opt without messing with files installed by existing stock Debian packages. Not to mention that holding obsolete packages just so your local modifications aren’t overwritten by upgrades can actually become a major hassle later on, once you decide or need to upgrade your distribution.

Now, unpack the Firefox tarball you previously downloaded from ftp.mozilla.org into /opt:

# cd /opt
# tar -xvf /home/john/Downloads/firefox-18.0.1.tar.bz2

If you succeed with the above step (e.g. the download wasn’t broken), you will now have a directory /opt/firefox containing Firefox’s binary and resource files. You should change file and directory permissions there so that Firefox can update itself automatically later, when running as your regular user (john in this example):

# chown john:john -R /opt/firefox/

Now add a symbolic link to help it find your system-wide plugins:

# ln -s /usr/lib/mozilla/plugins/ /opt/firefox/plugins

Optional: If you want to be able to run Firefox directly from a terminal without typing the full path every time, and you are not willing to edit the PATH environment variable in every user’s profile to account for the fact that the it resides in a non-standard directory, you will find it more convenient to create a symbolic link to it in /usr/local/bin (which is in PATH on most configurations):

# ln -s /opt/firefox/firefox /usr/local/bin/firefox

And this is the end of the file installation and set-up step. But we are not done yet, as we obviously want to tell our desktop manager and Debian’s ‘alternatives’ system about our newly installed web browser.

First you will want a desktop menu entry that you can copy as a launcher in your desktop directory, or add to favorites, or whatever your desktop environment has. For this, you must create a file named firefox.desktop in /usr/local/share/applications (again, to avoid conflicts with packages) with the following contents:

[Desktop Entry]
Name=Firefox Web Browser
GenericName=Web Browser
Comment=Browse the World Wide Web
Exec=/opt/firefox/firefox %u
Terminal=false
Icon=/opt/firefox/browser/icons/mozicon128.png
Type=Application
Categories=Application;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupWMClass=Firefox-bin
StartupNotify=true

Or you can just download the file from here.

Now, the Debian alternatives system, used to deal with simultaneously installed packages providing equivalent functionality (e.g. Iceweasel vs. Chromium). This part is also pretty much just like the post I linked, but in order to force Firefox being selected as the default in automatic mode, I ramped up the priority arguments a bit (900 instead of 100):

# update-alternatives --install /usr/bin/x-www-browser x-www-browser /opt/firefox/firefox 900
# update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser /opt/firefox/firefox 900

Also note that the older guide does not mention the gnome-www-browser alternative. I do not use GNOME, but I would suspect there is some relation between both.

You can now update any file associations in your desktop environment as necessary, in particular the text/html and application/xhtml+xml associations. I will not go into details about this step because it varies from platform to platform, but for KDE SC 4.8 it is pretty straightforward:

  1. Go into System Settings → File Associations.
  2. Type ‘html’ in the search pattern field.
  3. Locate application/xhtml+xml and text/html amongst the filtered types, and change the Application Preference Order accordingly. Firefox should already appear on the list of candidates. If it doesn’t, try logging out and back to your desktop.

Once you have sorted this out, applications complying with your desktop environment’s configuration should automatically launch or open a new tab in Firefox whenever you click on an external link.

Even now, though, things may not necessarily work as you expect with KDE applications, as they may first attempt to detect the target document type (HTML page, PNG image, etc.) and launch the associated program afterwards. This means that you while Firefox will launch for web pages, other kinds of files will open in their respective applications (Gwenview, etc.). If this is not what you want, you can force applications to always open URLs in Firefox irrespective of their content:

  1. Go into System Settings → Default Applications.
  2. Choose Web Browser from the list.
  3. Choose to Open http and https URLs in the following browser, and click on the button to pick Firefox from your desktop menu. Or just enter ‘firefox’ in the textbox.

That’s it! You are done installing and configuring the original vanilla Mozilla Firefox to run on your Debian system, and as long as you run it as the user holding ownership of the files in /opt/firefox, you will also be able to automatically update it from upstream as new versions are published in whatever channel you chose when downloading.

Since Iceweasel is basically just a rebranded Mozilla Firefox with additional backported patches and tweaks added to the mix, you can use your existing Iceweasel profile with Mozilla Firefox and will not notice a difference.

Now, I cannot guarantee that Mozilla knows their crap better than the Debian Mozilla packagers. I would say there is plenty of historical evidence suggesting that they can screw up pretty badly from time to time, but then again, this is software made by humans for humans; you cannot expect perfection.

I cannot guarantee either that this guide will not eat your dog, set your computer on fire, or compromise your moral integrity. But I hope someone out there will find it to be useful. And in any case, how many people actually prefer the bland white critter to the pretty trademarked fox?

Changelog:

2013-05-27
Updated application icon path since mozicon128.png was relocated from /icons to /browser/icons in the official Firefox distribution starting from version 21.
2013-01-22
Updated sample firefox.desktop file with additional MIME types and other stuff, and added downloadable version
2013-01-21
Added information about KDE’s “open http and https URLs in an application based on the contents of the URL” option