[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-dev] Reduce TBB/OSX from 32MB to 23MB



Hi all,

made the following tricks that you can find attached to reduce the size
of TBB/OSX from 32MB to 23MB .

With this tricks it's possible to send TBB/OSX via Gmail using Gettor.

It goes from:
 32M    /tmp/TorBrowser-2.2.34-3-dev-osx-x86_64-en-US.zip
to
 23M    /tmp/TorBrowser-7z-wrap2.2.34-3-dev-osx-x86_64-en-US.zip


Probably it would require some better cleanup and integration, that's
just a working poc.

-naif
# Reducing TBB from 32MB to 23MB 

# PRE-REQ
# Download TBB OSX
cd /tmp/
wget https://www.torproject.org/dist/torbrowser/osx/TorBrowser-2.2.34-3-dev-osx-x86_64-en-US.zip
# Size is 32MB
# du -sh /tmp/TorBrowser-2.2.34-3-dev-osx-x86_64-en-US.zip 
 32M	/tmp/TorBrowser-2.2.34-3-dev-osx-x86_64-en-US.zip

# Install p7zip binary on system
# we use brew https://github.com/mxcl/homebrew
brew install p7zip

# Unzip TBB
 unzip TorBrowser-2.2.34-3-dev-osx-x86_64-en-US.zip

 cd TorBrowser_en-US.app/Contents/MacOS
 cp -pr /usr/local/Cellar/p7zip/9.20.1/ p7zip

# Strip strippable files (-1MB of uncompressed size)
 find . -type f -exec strip -S -x -X {} \; 2> /dev/null

# Compress Firefox.app, Vidalia.app and tor
# Using those parameters we can save 1.5MB of additional size
 p7zip/lib/p7zip/7z a -mx=9 -md=64m -mfb=256 Firefox.app.7z Firefox.app
 p7zip/lib/p7zip/7z a -mx=9 -md=64m -mfb=256 Vidalia.app.7z Vidalia.app
 p7zip/lib/p7zip/7z a -mx=9 -md=64m -mfb=256 tor.7z tor
# Delete the uncompressed version
 rm -rf tor Vidalia.app Firefox.app

# Modify the Shell Script wrapper of TorBrowserBundle 
# To add automatic 1st launch 7zip decompression
 vim TorBrowserBundle

# Decompress at first run
# Move to TorBrowser_en-US.app/Contents/MacOS/ directory
WORKDIR=`dirname $0`
cd $WORKDIR

echo "Verifying if TBB still need to uncompress itself..."
if [[ -f tor.7z && -f Vidalia.app.7z && -f Firefox.app.7z && -f p7zip/lib/p7zip/7z ]];
        then
                echo "Files tor.7z - Vidalia.app.7z - Firefox.app.7z available" 
                echo "Decompressing files..."
                echo -n "...tor.7z..."
                p7zip/lib/p7zip/7z x tor.7z
                echo -n "...Vidalia.app.7z..."
                p7zip/lib/p7zip/7z x Vidalia.app.7z
                echo -n "...Firefox.app.7z..."
                p7zip/lib/p7zip/7z x Firefox.app.7z
                echo "Deleting archives..."
                rm -f tor.7z
                echo -n "...tor.7z..."
                rm -f Vidalia.app.7z
                echo -n "...Vidalia.app.7z..."
                rm -f Firefox.app.7z
                echo -n "...Firefox.app.7z..."
        else
                echo "Compressed files not found: TBB already uncompressed"
        fi


# Make a new ZIP image (better to use DMG)
 cd ../../../
# Current size with built-in 7zip compressed app
 du -sh TorBrowser_en-US.app
 35M	TorBrowser_en-US.app
 
# Create compresed archive
zip -r -9 TorBrowser-7z-wrap2.2.34-3-dev-osx-x86_64-en-US.zip TorBrowser_en-US.app

# New size of Compressed file
 du -sh TorBrowser-7z-wrap2.2.34-3-dev-osx-x86_64-en-US.zip
 23M	TorBrowser-7z-wrap2.2.34-3-dev-osx-x86_64-en-US.zip

# Now move the file in some other place and just download and run it as usual
# The first run will compress and delete the internal .7z file transparently

I tried sending via GMAIL and it works fine.

I am confident that playing another little bit, using this method and going further, it would be possible to make additional reduction in size.

-naif
naif@xxxxxxxxxxxxxx
_______________________________________________
tor-dev mailing list
tor-dev@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev