Friday 29 October 2010

Making a Maverick Live CD

This is a simple update of my live CD instructions, but this time updated for Maverick Meercat. This time I am going to leave the original CD image on removable media to cut down the space taken up by this operation.

First of all we are going to need some extra packages for our running system to manipulate the CD image. To install these, run this command from a terminal window.

sudo aptitude install squashfs-tools genisoimage

The CD image contains one large archive file which stores all of the disk environment for the LiveCD. The squashfs-tools handles this archive. Basically, we unpack everything, add our extra packages, and then repack everything. The genisoimage [gen]erates the final [iso] [image] which we put onto the USB Key in due course.

Now, make a working directory in [~] home, and copy the image file into it:

mkdir ~/live
cd ~/live

Next we are going to actually mount the CD image so we can use it as if we had burned it to a CD and inserted it. We need to create the mount point first of all:

mkdir mnt
sudo mount -o loop /media/[whatever]/ubuntu-10.10-desktop-i386.iso mnt

The [whatever] will differ depending on exactly where your system mounts the USB Key you just plugged in. The loop [o]ption allows us to mount the image file as a folder.

Now we need to copy all of the files off the mounted image APART from the large squashed file. Again we want a separate folder to store these files:

mkdir extract-cd
rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd

Next we need to extract the big archive file:

sudo unsquashfs mnt/casper/filesystem.squashfs

It uncompresses to a folder name we want to change by the typical linux method of [m]o[v]ing it.

sudo mv squashfs-root edit

We are going to be chrooting into the filesystem we just unpacked, and we want to use some of the files on our existing machine to point the way to the internet, and to give us access to our current hardware:

sudo cp /etc/resolv.conf edit/etc/
sudo cp /etc/hosts edit/etc/
sudo mount --bind /dev/ edit/dev

Now we chroot in and mount some virtual filesystems:

sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts

We also need to set some system variables and create a symbolic link for some reason or another.

export HOME=/root
export LC_ALL=C
dbus-uuidgen > /var/lib/dbus/machine-id
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl

I think the dbus command generates a code for this specific machine that some installation stuff may need. No idea what the [initctl] stuff is all about.
Excellent. We are now at the point where we can start to install stuff. First of all, and this was fucking frustrating trying to work this out, we need to enable the universe and multiverse repositories if we want to install packages from them. We need to do this in command line:

sudo nano /etc/apt/sources.list

This next command adds an external repository to the list of places we can download stuff from. It's a biggie but it basically is just a series of commands that run in sequence.

sudo wget http://www.medibuntu.org/sources.list.d/`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list; sudo apt-get -q update; sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring; sudo apt-get -q update

Before installing stuff, it might be a good idea to clean out some stuff we are not going to use. First of all have a look at all the installed packages in order of size:

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | less

The first on the list looks like a massive package, but what you have to understand is that this is showing you the UNCOMPRESSED sizes. Yeah, thanks for that. If you check on http://packages.ubuntu.com/lucid for the ubuntu-docs information, you find it is only taking up a few hundred Kb when squashed.
So what can you remove? Evolution is a prime candidate. Not much use on a LiveCD. You will be using webmail from a LiveCD.

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | grep evolution

This will show you all packages which have evolution in the title. It should look like this:

9760 evolution-common
5160 libevolution
2916 evolution-exchange
1540 evolution-data-server
1152 evolution-webcal
1076 evolution
700 evolution-plugins
368 evolution-data-server-common
128 evolution-indicator
128 evolution-couchdb

You can remove all, apart from evolution-data-server-common which is needed by other applications, by running this command:

apt-get remove --purge evolution-common libevolution evolution-exchange evolution-data-server evolution-webcal evolution evolution-plugins evolution-indicator evolution-couchdb

The language packs also take up a lot of space, and I do not need anything but English. Find these by running:

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | grep language-

and then remove the ones we do not want:

apt-get remove --purge language-pack-gnome-xh-base language-pack-xh-base language-pack-gnome-zh-hans-base language-pack-zh-hans-base language-pack-gnome-es-base language-pack-gnome-pt-base language-pack-gnome-de-base language-pack-pt-base language-pack-es-base language-pack-de-base language-pack-gnome-bn-base language-pack-bn-base

There are other language packs, but they are to small to worry about clearing up unless you are intent on getting this image as small as possible. The final obvious low hanging fruit are foreign font sets. Do a search for [t]rue[t]ype[f]ont packages:

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | grep ttf

12584 ttf-unfonts-core - Korean
6200 ttf-takao-pgothic - Japanese
5456 ttf-thai-tlwg - Thai
5184 ttf-wqy-microhei - Don't know for sure, better keep
4204 ttf-freefont - Latin, keep
2632 ttf-indic-fonts-core - Indian
2564 ttf-dejavu-core - Latin, keep
1724 ttf-liberation - Latin, keep
1708 ttf-opensymbol - Symbols, needed for OpenOffice, keep
592 ttf-khmeros-core Cambodian
216 ttf-punjabi-fonts - Punjabi
144 ttf-lao - Lao, where ever Lao is
116 ttf-kacst-one - Arabic

apt-get remove --purge ttf-unfonts-core ttf-takao-pgothic ttf-thai-tlwg ttf-wqy-microhei ttf-indic-fonts-core ttf-khmeros-core ttf-punjabi-fonts ttf-lao ttf-kacst-one

I am not going to be printing from the LiveCD so I can remove the software and drivers as follows. Do not worry about the ubuntu-desktop meta file - it is just an easy way of ensuring that all the ubuntu basic stuff is installed. As soon as printing is removed, the installation no longer qualifies as an ubuntu desktop but it doesn't actually remove the rest of the stuff.

apt-get remove --purge cups hplip-data

I am also going to remove rhythmbox, because it does take up a lot of space, and like evolution it is really the type of application you need to set up on an installed machine rather than running from a LiveCD.

apt-get remove --purge rhythmbox

Even after all of those deletions, once I recompressed the image I found I had saved a paltry 90Mb or so. Ho hum. Once you have carried out all the removals, a good strategy is to upgrade all your remaining packages to the latest versions. You do NOT want to upgrade the Kernel or Grub because that causes bad things to happen and will stop the Live USB stick booting. So, create the following files to 'pin' those packages to their current versions:

sudo cat > hold_back_kernel << "EOF"
Package: linux-generic linux-headers-generic linux-image-generic linux-restricted-modules-generic
Pin: version 2.6.35.22.23
Pin-Priority: 1001
EOF
sudo mv hold_back_kernel /etc/apt/preferences.d/
sudo cat > hold_back_grub << "EOF"
Package: grub-common
Pin: version 1.98+20100804-5ubuntu3
Pin-Priority: 1001
EOF
sudo mv hold_back_grub /etc/apt/preferences.d/
sudo apt-get update

You can check that the version numbers are correct (they should be for the Live CD you have downloaded) and check the system knows about the new rules by running these commands:

sudo apt-cache policy
dpkg -l linux-generic
dpkg -l grub-common

The last few lines of all of that should look like this (you can see the version numbers match up):

Pinned packages:
     linux-headers-generic -> 2.6.35.22.23
     linux-image-generic -> 2.6.35.22.23
     grub-common -> 1.98+20100804-5ubuntu3
     linux-generic -> 2.6.35.22.23
root@compaq:/# dpkg -l linux-generic
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                      Version                   Description
+++-=========================-=========================-==================================================================
ii  linux-generic             2.6.35.22.23              Complete Generic Linux kernel
root@compaq:/# dpkg -l grub-common
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                      Version                   Description
+++-=========================-=========================-==================================================================
ii  grub-common               1.98+20100804-5ubuntu3    GRand Unified Bootloader, version 2 (common files)

You should now be able to run the upgrade excluding those troublesome packages.

sudo apt-get upgrade

We can now run a massive install command to add the extra packages that we want.

sudo apt-get install \
\
build-essential linux-headers-generic libgtk2.0-dev patch bison texinfo \
\
xul-ext-adblock-plus flashplugin-installer openjdk-6-jre icedtea6-plugin \
\
openoffice.org-writer openoffice.org-java-common openoffice.org-l10n-en-gb openoffice.org-help-en-gb openoffice.org-style-human myspell-en-gb openoffice.org-hyphenation-en-us openoffice.org-thesaurus-en-us openoffice.org-java-common \
\
ttf-mscorefonts-installer \
\
smplayer vlc avidemux audacity pitivi \
\
totem totem-plugins-extra gstreamer0.10-pitfdll gstreamer0.10-ffmpeg gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse \
\
non-free-codecs libavcodec-unstripped-52 libdvdcss2 libdvdread4 libdvdnav4 \
\
lame mjpegtools twolame mpeg2dec liba52-0.7.4-dev ffmpeg ffmpeg2theora w32codecs \
\
keepassx \
\
xchm comix ghostscript ghostscript-x gqview \
\
wine \
\
transmission \
\
f-spot dcraw gimp gimp-data-extras gimp-help-en \
\
celestia celestia-common celestia-common-nonfree stellarium googleearth-package \
\
subversion yasm \
autoconf libtool zlib1g-dev libbz2-dev intltool libglib2.0-dev \
libdbus-glib-1-dev libgtk2.0-dev libgudev-1.0-dev \
libwebkit-dev libnotify-dev libgstreamer0.10-dev \
libgstreamer-plugins-base0.10-dev \
\
monodevelop

To install Google Earth from the package downloaded above, you run:

make-googleearth-package

I also want a couple of bits of software which are not available in the repositories. The first is Handbrake which is used to auto convert between video formats, and then Truecrypt which is a handy encryption system.

The lump of packages near the end of the long list above (subversion to libgstreamer) contains the dependencies for Handbrake. Handbrake itself is installed using the svn system:

cd /tmp
svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
cd hb-trunk
./configure --launch
cd build
make install

Truecrypt is a pain in the arse since they want you to accept their stupid licence instead of just releasing under the GPL.

cd /tmp
wget http://www.truecrypt.org/download/truecrypt-7.0a-linux-x86.tar.gz
tar -xzvf truecrypt-7.0a-linux-x86.tar.gz
./truecrypt-7.0a-setup-x86

Extract the package file - it automatically stores it in /tmp. We need to extract it to /, and it auto installs to the correct folders. So:

cd /
tar -xzvf /tmp/truecrypt_7.0a_i386.tar.gz

And that is that for Truecrypt.

If you were stupid enough to upgrade the kernel package, it is extremely likely that doing a upgrade of all the packages will change the kernel version. To ensure that the new kernel is actually used, you need to go into the ...
~/live/edit/boot
...folder and copy the latest versions of the vmlinuz compressed kernel and the initrd.img files to the ...
~/live/extract-cd/casper
...folder. You then need to delete the existing initrd.lz file, and rename the initrd.img file you just copied over to replace it. Do the same with the vmlinuz files. This has NEVER worked for me so I do not upgrade the kernel package.

If you want the clock in the LiveCD machine to show the proper time, take a moment and set your time zone and keyboard for UK use:

sudo setxkbmap gb
sudo cp -v --remove-destination /usr/share/zoneinfo/Europe/London /etc/localtime

Of course, the keyboard command does not fucking work. I now have no fucking idea how to change the keyboard map from the command line. Brilliant. I mean there must be a file somewhere, anywhere, that actually stores these settings. Where? No fucking clue. Moving on:

We now need to clean up some user account stuff incase any of the installed packages made changes:

awk -F: '$3 > 999' /etc/passwd
usermod -u 500 $hit #where hit is any user ID greater than 999

Right, and we are good to do a general clean up:

apt-get clean
rm -rf /tmp/* ~/.bash_history
rm /etc/resolv.conf
rm /var/lib/dbus/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
umount /proc
umount /sys
umount /dev/pts
exit
sudo umount edit/dev

The [rm] commands obviously [r]e[m]ove stuff, and the remaining commands undo the setup commands we used to get into the [chroot] environment. Virtually every time I do this I get a fucking annoying error telling me that it can't umount these things because they are in use. Well, you know what I say to that? Hello Mr. Reboot.

Once the system has come back on, fire up a terminal and:

cd ~/live

Now, update the .manifest file which is a list of installed packages:
chmod +w extract-cd/casper/filesystem.manifest
sudo chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest
sudo cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/casper/d' extract-cd/casper/filesystem.manifest-desktop

Now delete the existing squashed archive and replace it. Don't worry if it cannot find one, there shouldn't be one the first time you run through these instructions.
sudo rm extract-cd/casper/filesystem.squashfs
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs

That last command will take most time of anything here, as it (re)compressess all the packages we want. If you are feeling particularly narcisstic you can edit the disk details (change the image name) that pop up on boot:

sudo nano extract-cd/README.diskdefines

Now we need to rebuild the md5sum check file:
cd extract-cd
sudo rm md5sum.txt
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt

That will probably take two [sudo] password requests - one for the straight [sudo] and one for the [| sudo] piped version. Do not know why. Irritating as fuck.

And finally we need to build a new iso image:

sudo mkisofs -D -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-10.10-desktop-i386-custom.iso .

Once you have that image you use the unetbootin software (which comes in both windows and linux flavours) to load the image onto the USB Key. You need to use version 494 at least to get it to work with Maverick. Job done.

Tuesday 26 October 2010

Hardware Fuckup 2: The Return

The fucking fucker is fucking fucked a-fucking-gain.

Turned machine off in morning, fine.

Turned machine on this evening, same fucking bastard symptoms as March. Lights come on and the fan spins for half a second then off.

Cockmaster.

The difference this time was that the machine was doing NOTHING when it seems to have failed for no reason at all. It was OFF. The power supply, at least, is untouched, and works fine in another machine.

Bawbag.

Friday 22 October 2010

LFS - Firefox 4 Beta from Source

The new version of Firefox is nearly out, and I wanted to try it with my LFS system. I figured that it should not be too different to Firefox 3.6 which I have installed. I encountered two problems when installing FF4. Firstly, for some strange reason, it can't use the libpng that I have installed. I updated libpng to the latest version, but still nada. It also needed the yasm software which is some programming language stuff.

So:
cd /sources/extras
wget http://www.tortall.net/projects/yasm/releases/yasm-0.8.0.tar.gz
cd /dev/shm
tar -xzvf /sources/extras/yasm-0.8.0.tar.gz
cd yasm-0.8.0
CC="gcc -fPIC" ./configure --prefix=/usr
time make $CORES_TO_USE
make install

And then:

cd /sources/extras
wget ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/4.0b6/source/firefox-4.0b6.source.tar.bz2
cd /dev/shm
tar -xjvf /sources/extras/firefox-4.0b6.source.tar.bz2
cd moz*
cat > .mozconfig << "EOF"
ac_add_options --enable-application=browser
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../firefox-build
mk_add_options MOZ_MAKE_FLAGS="-j4"
ac_add_options --prefix=/opt/firefox4
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
Note - the "-j4" line. Make this j2 for a dual core, or leave it out altogether for single core. I have commented out the libpng line, because I will want it back if I ever find out what is screwed up. I have also changed the install directory so I can install it alongside FF3. Now run:
time make -f client.mk build
make -f client.mk install
cd ..
rm -rvf moz*
I think I may have found the problem with Flash 10. My system is missing some dependencies. Running [ldd] on the library reports the following as missing:
libssl3.so => not found
libsmime3.so => not found
libnss3.so => not found
libplds4.so => not found
libplc4.so => not found
libnspr4.so => not found
All of these libraries are in the Firefox folder - but are NOT available to the system as a whole. So I need to somehow tell the system it can look in the firefox folders to get these things. They way to do this is by adding the firefox path to following file:
cat >> /etc/ld.so.conf << "EOF"
# Extra Path so Firefox's libraries can be used by Flash10
/opt/firefox4/lib/firefox-4.0b6
# End of Extra Path.
EOF
OK. We now get a fucking different problem. It can't find the cURL library. Which it DOESN'T FUCKING ASK FOR when you [ldd] the fucker. OK.
wget http://curl.haxx.se/download/curl-7.20.0.tar.bz2
tar -xjvf curl-7.20.0.tar.bz2
cd curl-7.20.0
./configure --prefix=/usr
make $CORES_TO_USE
Holy fuck the [make check] is the best I have ever seen! It gives you an actual ETA of how long the test is going to take to run! It is awesome. And then it ruins everything by not giving you a final report. Bastard.
make install
find docs -name "Makefile*" -o -name "*.1" -o -name "*.3" | xargs rm
install -v -d -m755 /usr/share/doc/curl-7.20.0
cp -v -R docs/* /usr/share/doc/curl-7.20.0
And, finally, the fucker works. You just install Flashplayer 10 using the following instructions:
wget http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.tar.gz
tar -xzvf install_flash_player_10_linux.tar.gz
mkdir -v /opt/firefox4/lib/firefox-4.0b6/plugins
cp -v libflashplayer.so /opt/firefox4/lib/firefox-4.0b6/plugins
If you have already installed Java, just link it to the new plugins directory:
ln -sv /opt/jdk/jre/lib/i386/libnpjp2.so /opt/firefox4/lib/firefox-4.0b6/plugins

Friday 15 October 2010

LAP - WHDLoad

You need lha & installer

cd ~amiga/shared
wget http://www.whdload.de/whdload/WHDLoad_usr.lha
wget http://www.aminet.net/util/boot/skick346.lha
wget http://aminet.net/util/pack/xfdmaster.lha
cp ~/amiga/roms/1.3.rom ./kick34005.A500
cp ~/amiga/roms/3.1.rom ./kick40068.A1200

lha x shared:WHDLoad_usr.lha ram:
[install to c:]
lha x shared:skick346.lha devs:
copy shared:kick34005.A500 devs:Kickstarts
copy shared:kick40068.A1200 devs:Kickstarts
lha x shared:xfdmaster.lha ram:
copy ram:xfd_User/C/xfddecrunch c:

Friday 8 October 2010

System Info from the Command Line

Bizarrely it can be a frustrating experience to get sensible information about your system from a linux machine. Fortunately, this has been sorted out in the latest versions of Ubuntu which come with the [name of app] which seems to give one a full overview of the hardware installed in the system. Ubuntu's DIsk Usage Analyser is a very useful way of finding out what is taking up space in the system.

Those graphical applications are dependency heavy though, and require you to have the whole of Gnome installed before they are prepared to work. I therefore present herein a non-exhaustive list of commands which get you to the same kind of useful information:

df -h

This gives you the total [d]isk space used and [f]ree in [h]uman readable numbers.

df -hH

This gives you the same information in marketing megabytes, not actual megabytes.

du [dir] -h

Gives you the [d]isk [u]sage of a directory and all its subdirectories individually.

du [dir] -hs

Gives you the [d]isk [u]sage of the whole directory in one number.

top -i
...brings up a fullscreen updating display of the current active processes, and general memory/swap usage.

ps -auxf | sort -nr -k 4 | head -10
...should show you the top ten processes by memory usage.

free -m
...shows you memory usage only in [m]egabytes.

sudo du --max-depth=1 --exclude=*dev* --exclude=*tmp* --exclude=*proc* | sort -n -r

This is a useful command to run from the root directory as it lists the space used by all subfolders to that directory only. It does not go below the subfolder level ([max-depth=1]). It does not work with [-h] as the sort ([| sort -n -r]) gets confused and does not deal with the M or K distinction. In other words a 20000k file is treated as larger than a 20m file. The excludes are useful because proc and dev are virtual and do not take up any space on the disk. I had tmp mounted to a ramdisk when I was doing my Amiga project, so I also wanted to exclude that.

This following does seem to do the sort better (or at all):

du -ks --exclude=*dev* --exclude=*tmp* --exclude=*proc* * | sort -nr | cut -f2 | xargs -d '\n' du -sh

I have no idea what the [cut] or [args] bits do, but they seem to sort out (ha ha) the sorting problem.

To get Battery information from the command line, you use the following two commands:

cat /proc/acpi/battery/BAT1/state
cat /proc/acpi/battery/BAT1/info

The variable here is the [BAT1] bit. Yours may be BAT0 or something else. Just check the contents of the directory and you should find something. There is a useful perl script here which extracts and displays the information produced by the preceding commands.

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