Universal Firefox on a USB Key

From Open Source@Seneca

Jump to: navigation, search

Contents

Universal Firefox on a USB Key

Project Description

Create a portable USB installation of Firefox that will work on all of Windows, Linux, and Mac. Currently there are binaries for doing this with Windows/Linux. You'll need to get binaries for the app on each platform, figure out how to share a common profile, and get it all on a single USB key.

Resources: sxip/dick, http://developer.mozilla.org/en/docs/Chrome_Registration#platform_.28Platform-specific_packages.29, http://developer.mozilla.org/en/docs/Bundles#Platform-specific_Subdirectories, http://ted.mielczarek.org/code/mozilla/crashme.xpi

Project Details

Version 0.1

We have approached the project from a packaging perspective as such we have been working on a proof of concept script to manage Firefox's directory structure in order to use a universal profile.

We have decided to write a script that allows firefox to read the profile from a directory on the USB Key instead the default folder on Windows, which is the Application Data\Mozilla folder. We decided to create our Univerisal Firefox with the following file structure:

. (root of the usb key)
.\Firefoxes\
.\Firefoxes\XP
.\Firefoxes\Linux
.\Firefoxes\Mac
.\Firefoxes\Profiles

Each OS will have their own binary/script that will read the single common profile folder.


For 0.1 we decided to start the project on the Windows platform. We installed Firefox 2 on a USB Key and comfirmed that the program is running from the Key by adding an alert box to one of the buttons on the browser. We further confirmed that Firefox is running from the USB Key by testing it on a Windows XP image that only had the default installation and no Firefox previously installed. At this point Firefox on the USB Key would create a default profile on the local machine hard drive.

We wanted to alter this behavior so that Firefox would read the common profile on the USB Key. We researched for ways to redirect where Firefox was looking for its profiles. We realized that Firefox looked up Profiles.ini in the Windows Application Data folder for the location of each profile. We later discovered that there is a program switch to tell Firefox where to get its profile. We initially hard coded the profile location used by the command line switch as follows:

  firefox.exe -profile "G:\Seneca\firefoxWindowsInstallToStick\Profiles\q928eerv.default"

Using an absolute path name we managed to have Firefox read and write the profile on the USB Key. Next we wanted to change the absolute path into a relative path via a batch script. The following script succeeding in giving us the relative path as long as it was run from the directory where the batch file resided.

@echo off
set currDir=%CD%\
set ff=firefox
set profile=Profiles\q928eerv.default
set q="
set profileDir=%q%%currDir%%profile%%q%

set total=%ff% -profile %profileDir% 
echo currDir = %currDir%
echo ff = %ff%
echo profile  = %profile%
echo profileDir = %profileDir%
echo q = %q%
echo total = %total%
rem this is the concatenated command that is executed
rem %total%

The challenge was to write a script that would capture the batch file's location no matter where it was run from (e.g. executing the batch file from the C: drive). To solve this problem in the batch script, we added code to find the location of the batch file, have it execute the Firefox call from there and then return to the original directory that he user was on.

@echo off
cls
for /f %%i in ("%0") do set batchpath=%%~dpi   <----this line returns the current directory of the batch file
echo Starting Firefox From USB
echo batchpath=%batchpath%
%batchpath%\XP\firefox --no-remote -profile %batchpath%\Profiles\UniversalProfile
echo Exit 0

Our next step is to study shell scripting to get the same effect for Firefox on Linux. The Linux distribution also has a default start up script, that we hope take advantage of. We confirmed that Linux Firefox can read the same universal profile structure that we have designed. Our next goal is to duplicate the same behavior on Linux as we have for Windows.

Version 0.2

For 0.2 we have created a linux script, and after much experimentaiton, and learning just a tad about shell scripting, we found several ways to get the active directory, eventually using code that was already in the mozilla shell script. Our problem was that the firefox binary has a dependency on libstc++5, and was blowing up on Linux distros that were using libstc++ 6, which include almost all distro's. Our quick fix solution was to add libstc++5 to our stick, and this indeed solved the problem for now. We hope to be able to set the library paths up so that Firefox on a stick will first search the desktop system, then our stick, for all the shared libraries.

Our Linux script is as follows:

 #!/bin/bash 
 echo "Starting Linux Firefox From USB"
 progname="$0"
 curdir=`dirname "$progname"`
 progbase=`basename "$progname"`
 #echo "progname - whole path and name= " $progname
 #echo "curdir   - directory!!        = " $curdir
 #echo "progbase - script name        = " $progbase
 # Testing stuff
 # batchpath=${BASH_SOURCE%/*}
 # script_path=$0
 # [ -e "$script_path" ] || script_path=$(command -v -- "$0")
 # echo $script_path
 $curdir/linux/firefox --no-remote -profile $curdir/Profiles/UniversalProfile <----this line returns the current directory of   the shell script


We asked Ben Hearsum about Firefox using the libstc++ 5 libraries, and he was going to look into it for us. We had also tried doing a Static build of Firefox, which was successful, but it wasn't static enough. Our thoughts were that it might be worth the performance hit to have one huge Firefox binary, that would be totally self reliant, but apparently that isn't a viable option. We have tested our libstc++5 version on Fedora8 at Seneca, as well as on a couple other distro's such as Ubuntu, fedora7, and it works well, without the need to do an apt-get.

The link to all of our files is : http://downloads.sykokillers.com/mozilla/Firefoxes_Official_0.2.zip

Version 0.3

For 0.3 we have modified our Linux script, and spent much of our time getting familiar with the MAC OS system, since neither if us has ever used a mac before. We also investigated the possibility of running ONE script to start Firefox on all three platforms, but found that this was not feasible. We have a proof of concept for MacOS, in that we directly copied the installed Firefox onto our flash drive, as we couldn't get the Web version running.

Initially we were working with the Mac release of Firefox from the official website. There was some learning curve to the Mac, so we had invested alot of time just fooling around with the operating system. Even just figuring out the different responses the system did combined with keys took some time. It didn't really help too much, and even confused us further when one Mac behaved differently from another. At some point we realized that the installer file from Firefox's site was actually behaving like an image than really installing the files on to the system. With that in mind we stumbled across how to extract the actual contents and put it on our USB drive.

Having learned that MacOS is working with Linux as its backbone, we modified our Unix script to work for the Mac Firefox. Now we when we executed Firefox for Mac from the USB drive the program hung unexpectedly. It took a long time for the first window to appear and then we could not go any further. In the end we got a working Mac Firefox by taking it off of an existing install.

This is a little script we were playing with to isolate the particular flavor of the OS on Windows. If we have to make any platform specific changes we can add it to the specific OS in question.

@echo off
ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt
echo Machine undetermined.
goto exit
:ver_2003
:Run Windows 2003-specific commands here.
echo Windows 2003
goto exit
:ver_xp
:Run Windows XP-specific commands here.
echo Windows XP
goto exit
:ver_2000
:Run Windows 2000-specific commands here.
echo Windows 2000
goto exit
:ver_nt
:Run Windows NT-specific commands here.
echo Windows NT
goto exit
:exit
pause

Our Mac script RC1 is as follows: (ignore the comments - just for our future reference/reminder)

#!/bin/bash
echo "Starting Linux Firefox From USB"
progname="$0"
curdir=`dirname "$progname"`
progbase=`basename "$progname"`
#echo "progname - whole path and name= " $progname
#echo "curdir   - directory!!        = " $curdir
#echo "progbase - script name        = " $progbase
batchpath=${BASH_SOURCE%/*}
# script_path=$0
# [ -e "$script_path" ] || script_path=$(command -v -- "$0")
# echo $script_path
# echo $batchpath
#echo $batchpath
$curdir/MACOS/firefox --no-remote -profile $curdir/Profiles/UniversalProfile <----this line returns the current directory of   the shell script


Get the 0.3 release here: http://downloads.sykokillers.com/mozilla/Firefoxes_0.3_RC1.zip

Project Leader(s)

Project Contributor(s)

Contributions

Our contributions were limited to the "soft" variety for our class mates, because we were all new to this and our projects were very different. Moral support and helping each other while doing labs.

We used Bugzilla on a couple of occasions to contribute to the community, twice in particular to users who had lost their Profiles. I was bug watching several "profile" bugs and responded to these users with information on how to recover their profiles on Windows systems.

Miscellaneous links and stuff

http://pastebin.mozilla.org/ - a way to collaborate on debugging code snippets, put code of compile results in the box, post it, then share the link for others on IRC to see.


http://wiki.mozilla.org/Breakpad
http://en.wikipedia.org/wiki/XPInstall
http://en.wikipedia.org/wiki/Gecko_(layout_engine)

Related Bugzilla Reports
1. Bug 302087 Inadequate warning before Profile Manager deletes non-Mozilla files
2. Bug 381365 � No default bookmarks for profiles with a non-relative profile location
3. Bug 249150 (lostbookmarks) � Bookmarks file is overwritten (deleted) randomly in Firefox versions without places (edit)
4. Bug 264209 � Installer should provide options if an old profile is found -ehc
5. Bug 230032 � Profile completely overwritten including passwords and bookmarks

random links
http://mxr.mozilla.org/seamonkey/source/browser/app/mozilla.in
http://lxr.mozilla.org/mozilla1.8.0/source/toolkit/profile/src/nsToolkitProfileService.cpp#774
http://mxr.mozilla.org/firefox/source/build/
\-- http://mxr.mozilla.org/firefox/source/build/unix/run-mozilla.sh
http://lxr.mozilla.org/mozilla1.8.0/source/profile/resources/content/profileManager.js#50
http://lxr.mozilla.org/mozilla1.8.0/source/profile/resources/jar.mn#12
CREATE PROFILE default directory - see gDefaultProfileParent parmameter link below!
http://lxr.mozilla.org/mozilla1.8.0/source/toolkit/profile/content/createProfileWizard.js
http://lxr.mozilla.org/mozilla1.8.0/source/profile/src/nsProfile.cpp#777


http://mxr.mozilla.org/firefox/source/xpcom/io/nsAppFileLocationProvider.cpp#322 (App Data)
https://bugzilla.mozilla.org/show_bug.cgi?id=211628
http://technet.microsoft.com/en-us/library/bb490909.aspx

0.2 links
Linux Script stuff
http://www.linuxquestions.org/questions/linux-software-2/how-can-a-shell-script-determine-its-own-location-when-being-sourced-620704/

http://www.webservertalk.com/archive109-2006-9-1678618.html

http://www.issociate.de/board/post/285661/Bash_script_own_path.html .. more on finding the scrip path


linux script that works....must resolve the missing shared libraries!!! progname="$0" curdir=`dirname "$progname"` progbase=`basename "$progname"` echo "progname - whole path and name= " $progname echo "curdir - directory!! = " $curdir echo "progbase - script name = " $progbase

Static Build http://www.digitalmars.com/d/archives/digitalmars/D/How_to_create_a_static_build_61213.html

Project News

Feb 14, 2008: Firefox is running from the USB key and reading the profile onboard.

Jan 31, 2008: Chris introduced us to Dick Hardt - Founder & CEO of Sxip

Personal tools
special sections