Friday, June 18, 2010

How to build a basic Firefox package for Debian Lenny or Ubuntu 64-bit.

Do you run Debian 5 or 8.04+ Ubuntu on a 64-bit chip? Do you want a new Firefox as a 64-bit application? Here are some build instructions to create a basic package (no menu integration, etc.) from the Firefox source. If you want to add Flash, put the 64-bit beta plugin files into your home directory, e.g. ~/.mozilla, or the file tree specified by the option:
ac_add_options --with-default-mozilla-five-home=


Download source

Firefox source
I will use 3.5.9.

Unpack

Change to your workspace directory.
mkdir src
cd src
tar jxvf ../firefox-3.5.9.source.tar.bz2
cd ..

Prepare for building

sudo aptitude install build-essential libidl-dev autoconf2.13 xorg-dev gcc g++ libgtk2.0-dev libnotify-dev libnotify-dev-gtk2.10 libnotifymm-dev libiw-dev libcurl4-gnutls-dev

Prepare ~/.mozconfig

Put the following in ~/.mozconfig. Edit as needed. This file contains the build and configuration options used by Mozilla's Firefox build process. As documented here, this process will create a package that installs the new Firefox into /usr/local/apps/firefox-3.5.9-1. NOTE: update the version string in the prefix and default-mozilla-five-home to reflect the version you are building.
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@
ac_add_options --enable-application=browser
mk_add_options MOZ_CO_PROJECT=browser
mk_add_options MOZ_MAKE_FLAGS="-j4"
ac_add_options --disable-tests
ac_add_options --prefix=/usr/local/apps/firefox-3.5.9-1
ac_add_options --enable-optimize
ac_add_options --enable-official-branding
ac_add_options --enable-canvas
ac_add_options --enable-strip
ac_add_options --enable-xinerama
ac_add_options --with-default-mozilla-five-home=/usr/local/tmp/firefox-3.5.9-1/lib/firefox-3.5

Build it

mkdir -p package/firefox3.5_3.5.9-1_amd64
Note the package name, firefox3.5. This will keep it from stepping on system packages.
cd src
make -f client.mk clean && make -f client.mk build && make -f client.mk DESTDIR="`pwd`/../package/firefox3.5_3.5.9-1_amd64/" install
It takes ~15 minutes to build from scratch on an quad core Intel machine with 6GB of RAM.

Make the package

cd ../package/firefox3.5_3.5.9-1_amd64/
mkdir DEBIAN
cd DEBIAN
Create a file called "control" with the following contents. Edit the package name and version as needed. Use your own credentials for the maintainer field.
Package: firefox3.5
Version: 3.5.9-1
Architecture: amd64
Maintainer: First Last <name@somedomain>
Installed-Size: 90372
Depends: fontconfig, psmisc, procps, debianutils (>= 1.16), libc6 (>= 2.7-1), libglib2.0-0 (>= 2.12.0), libgtk2.0-0 (>= 2.12.0), libnspr4-0d (>= 1.8.0.10), libstdc++6 (>= 4.1.1), xulrunner-1.9 (>= 1.9.0.3-1)
Suggests: xulrunner-1.9-gnome-support, latex-xft-fonts, xfonts-mathml, ttf-mathematica4.1, xprint, mozplugger, libkrb53
Conflicts:
Replaces:
Provides:
Section: web
Priority: optional
Description: lightweight web browser based on Mozilla
* Get size
cd ..
du -sk usr
cd DEBIAN
* Edit "control" file to fill the output of the above du command into the Installed-Size: field.
* Create the "md5sums" file
cd ..
DIRS=`/bin/ls -1 | grep -v DEBIAN` && find $DIRS -type f -exec md5sum {} \; > ./DEBIAN/md5sums
cd DEBIAN
* Create "postinst" file with following content
#!/bin/sh

if [ ! -d /usr/local/tmp ]
then
  mkdir -p /usr/local/tmp
fi

echo "################################################"
echo ""
echo "Run: /usr/local/apps/firefox-3.5.9-1/bin/firefox"
echo ""
echo "################################################"
Make the script executable
chmod a+xr postinst
Create the package file
cd ../..
dpkg -ba firefox3.5_3.5.9-1_amd64

Install firefox

sudo dpkg -i firefox3.5_3.5.9-1_amd64.deb

Make a Launcher icon

Gnome:

  1. Right click on "Applications" menu
  2. Choose "Edit Menu"
  3. Click on "Internet"
  4. Click on "New Item"
  5. Name: Firefox3.5
  6. Command: /usr/local/apps/firefox-3.5.9-1/bin/firefox
  7. Comment: Firefox Browser, version 3.5.9
  8. Click on OK
  9. Click OK

KDE:

  1. Right click on desktop and choose "Create New"
  2. Choose "Link to Application..."
  3. Name the link "Firefox3.5"
  4. Click the Application tab
  5. Click the icon
  6. Chose a good web browser icon
  7. Description: Firefox Browser, version 3.5.9
  8. Command: /usr/local/apps/firefox-3.5.9-1/bin/firefox
  9. Click OK
  10. Open a terminal window
  11. Run: sudo cp ~/Desktop/Firefox3.5.desktop /usr/share/applications/

References

[1] http://markshroyer.com/blog/2009/07/firefox-35-debian-amd64.html