Friday, 1 October 2010

LFS - Firefox from Source

OK, I have buckled under the pressure of being sick fucking fed up of text only browsing. Actually, when I looked at it, with the packages I have installed, there are only two dependencies needed to get firefox up and running. So, firefox it is.

cd /sources/extras

The first dependency here is something to do with Interface Definition Language files. Apparently firefox needs to use them, whatever they actually are. Absolutely simply installation commands.
wget http://ftp.gnome.org/pub/gnome/sources/libIDL/0.8/libIDL-0.8.14.tar.bz2
tar -xjvf /sources/extras/libIDL-0.8.14.tar.bz2
cd libIDL-0.8.14
./configure --prefix=/usr &&
make
make install
cd ..
rm -rvf libIDL-0.8.14

Next up is Python. Frankly I am surprised it has taken until now for this to be installed. Python is another language like C or Perl.
wget http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tar.bz2
wget http://www.linuxfromscratch.org/patches/blfs/svn/Python-2.6.4-bdb_4.8-1.patch
wget http://docs.python.org/ftp/python/doc/2.6/python-2.6-docs-html.tar.bz2
tar -xjvf /sources/extras/Python-2.6.4.tar.bz2
cd Python-2.6.4

We need to fix a potential build problem with a quick [sed]. I have no idea whatsoever what the patch is supposed to fix, BLFS is silent on the issue.
sed -i "s/ndbm_libs = \[\]/ndbm_libs = ['gdbm', 'gdbm_compat']/" setup.py
patch -Np1 -i /sources/extras/Python-2.6.4-bdb_4.8-1.patch
./configure --prefix=/usr --enable-shared
make
make test
make install
chmod -v 755 /usr/lib/libpython2.6.so.1.0

We also want to install Python's documentation, we downloaded it after all. We also need to set a system variable to get the documentation to work properly.
install -v -m755 -d /usr/share/doc/Python-2.6.4/html
tar --strip-components=1 --no-same-owner --no-same-permissions -C /usr/share/doc/Python-2.6.4/html -xvf /sources/extras/python-2.6-docs-html.tar.bz2
cat >> /etc/profile << "EOF"
export PYTHONDOCS=/usr/share/doc/Python-2.6.4/html
EOF
cd ..
rm -rvf Python-2.6.4

And now we come to Firefox itself. This is probably the most complicated build we have done up until now. In fact it is so complicated that we need to create a separate file just to feed the configuration options to the make command.
wget http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.8/source/firefox-3.6.8.source.tar.bz2
tar -xjvf /sources/extras/firefox-3.6.8.source.tar.bz2
cd moz*

The folder created by the unpacking is called [mozilla]-something or other. Using the previous command is a simple way to ensure that we definitely move into that folder, no matter what its specific name. Now lets set up the config file. There are two ways to go with firefox. It comes with quite a lot of its dependencies built in. If you have these packages installed in the system, it is best to use those versions. For the missing dependencies we could download and install the latest versions, but that is too much of a pain in the arse frankly. Some of the packages we can use, like cairo, jpeg, png, and zlib because we have installed those. If you are dealing with a more mature BLFS install, you may have more system packages you can enable.
cat > .mozconfig << "EOF"
ac_add_options --enable-application=browser
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../firefox-build
ac_add_options --prefix=/opt/firefox
ac_add_options --enable-optimize
ac_add_options --enable-system-cairo
ac_add_options --with-system-jpeg
ac_add_options --with-system-png
ac_add_options --with-pthreads
ac_add_options --with-system-zlib
ac_add_options --disable-accessibility
ac_add_options --disable-crashreporter
ac_add_options --disable-dbus
ac_add_options --disable-gnomevfs
ac_add_options --disable-necko-wifi
ac_add_options --disable-installer
ac_add_options --disable-javaxpcom
ac_add_options --disable-tests
ac_add_options --disable-updater
ac_add_options --disable-libnotify
ac_add_options --enable-official-branding
ac_add_options --enable-safe-browsing
ac_add_options --enable-strip
EOF

Now you run the compilation. This takes just over 20 minutes on my quad core, so it is a biggie. You might want to benchmark by [time]ing the build.
time make $CORES_TO_USE -f client.mk build
make -f client.mk install
cd ..
rm -rvf moz*

Now may be a good time to install two special firefox plugins: Flash and Java.

First Flash. In the first instance I will try flash 9, because Flashplayer 10 has compatibility problems with firefox.
wget http://fpdownload.macromedia.com/get/flashplayer/installers/archive/fp9_archive.zip
unzip /sources/extras/fp9_archive.zip
cd fp9_archive/9r246
tar -xzvf flashplayer9r246_linux.tar.gz
cd install_flash_player_9_linux
cp ./libflashplayer.so /opt/firefox/lib/firefox-3.6.8/plugins
cd ../../..
rm -rf  fp9_archive

Just in case they have fixed Flash 10, you can get it from here:
wget http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.tar.gz
tar -xzvf install_flash_player_10_linux.tar.gz
cp -v libflashplayer.so /opt/firefox/lib/firefox-3.6.8/plugins

For Java, you need to download the binary install file, which is only available from Sun's website. You should now be using Firefox to browse so just save the appropriate file into the /sources/extras folder from this link.

Then, from the directory you download this to, run:
chmod +x /sources/extras/jdk-6u21-linux-i586.bin
/sources/extras/jdk-6u21-linux-i586.bin
cd jdk1.6.0_21
install -v -m755 -d /opt/jdk-6u21
mv -v * /opt/jdk-6u21
chown -v -R root:root /opt/jdk-6u21
ln -v -sf xawt/libmawt.so /opt/jdk-6u21/jre/lib/i386/
cd ..
sed -i 's@XINERAMA@FAKEEXTN@g' /opt/jdk-6u21/jre/lib/i386/xawt/libmawt.so
ln -v -nsf jdk-6u21 /opt/jdk

Java needs quite complicated environment variables to be set, so we'll create a profile file:
cat >> /etc/profile.d/30-jdk.sh << "EOF"
# Begin /etc/profile.d/30-jdk.sh

# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk

# Adjust PATH
pathappend ${JAVA_HOME}/bin PATH

# Auto Java CLASSPATH
# Copy jar files to, or create symlinks in this directory
AUTO_CLASSPATH_DIR=/usr/lib/classpath
pathprepend . CLASSPATH
for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
pathappend $dir CLASSPATH
done

export JAVA_HOME CLASSPATH
unset AUTO_CLASSPATH_DIR
unset dir

# End /etc/profile.d/30-jdk.sh
EOF

Either log out and in or run the following command to load the new environment settings:
source /etc/profile

The Java plugin for firefox needs to be installed by way of symbolic link, just copying it will not work for some reason:

ln -sv /opt/jdk/jre/lib/i386/libnpjp2.so /opt/firefox/lib/firefox-3.6.8/plugins

No comments:

Post a Comment