Installing Firefox2rc3 in Ubuntu "Dapper Drake"

27 Oct 2006
Posted by stylesen
On October 24th, 2006 we had the new release of Firefox ie., version 2.0 Release Candidate (RC) 3. I have Ubuntu Dapper Drake in my laptop and wanted to update my firefox to the new version. I found the installation of firefox is somewhat tricky because it does not have the usual way of configure/make/make install cycle. There was also another happy news today that Ubuntu's latest release Edgy (6.10) is out which has all the latest softwares including Firefox2.0. But I was not in a position to update my Dapper to Edgy today, but I decided to get Firefox2 in my Dapper and this is how I did it with the help of the following script which I obtained from Ubuntu forum: Assumption: You have your old firefox installation in Dapper system intact.
#               Script to automatically download and install the newest firefox version for linux, on an Ubuntu system.
#               Requires an internet connection to work (obviously).
# Author:       Termite 
# Based on version by nanotube .
# Modified by  : Senthil Kumaran S  
# Version:  1.91  31-Aug-2006

## Make sure that we exit if any commands do not complete successfully.
set -o errexit
trap 'echo "Previous command did not complete successfully. Exiting."' ERR

## Set version-specific variables
if grep -q "5.10" /etc/issue ; then
elif grep -q "6.06" /etc/issue ; then
  echo "This script only works on Breezy or Dapper."
  exit 1

## Get available localizations
LOCALIZATIONS=( `wget -q -O - | grep 'a href="' | grep -v "xpi" | grep -v "Name" | sed -e 's/.*@@'` )


## Get user choice of localization

echo "Please choose the localization (language) for firefox. Enter the number of your choice from the list below."
for ((i=0; i < LIMIT ; i++))
  echo "$i: ${LOCALIZATIONS[$i]}"

CHOICE=$(($LIMIT + 1))

echo -n "Enter your choice of localization: "
while [ "$CHOICE" -gt "$(($LIMIT-1))" -o "$CHOICE" -lt "0" ]
  read CHOICE
  if echo -n "$CHOICE" | grep -q "[^0-9]"; then
    echo -n "Your input contains non-numeric characters. Please try again: "
    CHOICE=$(($LIMIT + 1))
  elif [ -z "$CHOICE" ]; then
    echo -n "Please enter the number of your choice from the list: "
    CHOICE=$(($LIMIT + 1))
  elif [ "$CHOICE" -gt "$(($LIMIT-1))" -o "$CHOICE" -lt "0" ]; then
    echo -n "Your input is not in the range of available localizations. Please try again: "

echo -n "You have chosen localization \"${LOCALIZATIONS[$CHOICE]}\". Is that correct [y/n]? "
while true
  read ans
  case $ans in
       Y|y) break ;;
  [Yy][Ee][Ss]) break ;;
       N|n) echo "In that case, start over by running this script again."; exit ;;
  [Nn][Oo]) echo "In that case, start over by running this script again."; exit ;;
         *) echo -n "Invalid command. Please answer yes or no [y/n] " ;;

## Proceed to download and install firefox.

echo -e "\nUpdating repositories list\n"
sudo aptitude update

echo -e "\nMaking sure libstdc++5 and the old Firefox are installed\n"
sudo aptitude install firefox libstdc++5

if [ -d ~/.mozilla ]; then
  echo -e "\nBacking up old Firefox preferences\n"
  cp -R ~/.mozilla ~/.mozilla_backup_`date -Iseconds`
  echo -e "\nOld firefox preferences not found. Nothing to back up. Proceeding with installation.\n"

echo -e "\nChanging to home directory\n"

echo -e "\nDownloading Firefox from the Mozilla site\n"
wget -c${LOCALIZATIONS[$CHOICE]}/firefox-2.0rc3.tar.gz

echo -e "\nDownloading Firefox signature from the Mozilla site\n"
wget -c${LOCALIZATIONS[$CHOICE]}/firefox-2.0rc3.tar.gz.asc

echo -e "\nImporting Mozilla Software Releases public key\n"
echo -e "Note that if you have never used gpg before on this system, and this is your first time running this script, there may be a delay of about a minute during the generation of a gpg keypair. This is normal and expected behavior.\n"
gpg --keyserver --recv 1AF32821

echo -e "\nVerifying signature...\nNote: do not worry about \"untrusted key\" warnings. That is normal behavior for newly imported keys.\n"
gpg --verify firefox-2.0rc3.tar.gz.asc firefox-2.0rc3.tar.gz

echo -e "\nUnzipping the .tar.gz file\n"
sudo tar -C /opt -xzf firefox-2.0rc3.tar.gz

echo -e "\nRemoving the unzipped .tar.gz\n"
rm -f firefox-2.0rc3.tar.gz firefox-2.0rc3.tar.gz.asc

echo -e "\nLinking plugins\n"
cd /opt/firefox/plugins/
sudo ln -s -f $PLUGINPATH/* .

echo -e "\nLinking launcher to new Firefox\n"
sudo dpkg-divert --divert /usr/bin/firefox.ubuntu --rename /usr/bin/firefox
sudo ln -s /opt/firefox/firefox /usr/bin/firefox
sudo dpkg-divert --divert /usr/bin/mozilla-firefox.ubuntu --rename /usr/bin/mozilla-firefox
sudo ln -s /opt/firefox/firefox /usr/bin/mozilla-firefox

echo -e "\nThe new Firefox version 2.0rc3 has been installed successfully."

NOTE: The above script was originally written for installing firefox2.0 beta 2 release. I modified it to work for firefox2.0 rc3. Hmmm... Now I have firefox2.0 stable release in my Dapper box :)