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.
#!/bin/bash
#
# installnewfirefox.sh
#               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:      installnewfirefox.sh  1.91  31-Aug-2006  termite10@yahoo.com
# 
#
#######

## 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
  PLUGINPATH=/usr/lib/mozilla-firefox/plugins
elif grep -q "6.06" /etc/issue ; then
  PLUGINPATH=/usr/lib/firefox/plugins
else
  echo "This script only works on Breezy or Dapper."
  exit 1
fi


## Get available localizations
LOCALIZATIONS=( `wget -q -O - http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/2.0rc3/linux-i686/ | grep 'a href="' | grep -v "xpi" | grep -v "Name" | sed -e 's/.*@@'` )

LIMIT=${#LOCALIZATIONS[*]}

## 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++))
do
  echo "$i: ${LOCALIZATIONS[$i]}"
done

CHOICE=$(($LIMIT + 1))

echo -n "Enter your choice of localization: "
while [ "$CHOICE" -gt "$(($LIMIT-1))" -o "$CHOICE" -lt "0" ]
do
  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))
    continue
  elif [ -z "$CHOICE" ]; then
    echo -n "Please enter the number of your choice from the list: "
    CHOICE=$(($LIMIT + 1))
    continue
  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: "
  fi
done

echo -n "You have chosen localization \"${LOCALIZATIONS[$CHOICE]}\". Is that correct [y/n]? "
while true
do
  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] " ;;
  esac
done

## 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`
else
  echo -e "\nOld firefox preferences not found. Nothing to back up. Proceeding with installation.\n"
fi

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

echo -e "\nDownloading Firefox from the Mozilla site\n"
wget -c http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/2.0rc3/linux-i686/${LOCALIZATIONS[$CHOICE]}/firefox-2.0rc3.tar.gz

echo -e "\nDownloading Firefox signature from the Mozilla site\n"
wget -c http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/2.0rc3/linux-i686/${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 subkeys.pgp.net --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."

exit
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 :)