== Dependencies

=== Cygwin

Cygwin is used to provide a shell environment and other commands. We
don't actually use the Cygwin compatibility layer.

http://cygwin.com/install.html
http://cygwin.com/setup.exe
http://cygwin.com/setup.exe.sig

Verify the signature (do it on another machine if you don't already have
GnuPG installed locally).
	$ gpg --verify setup.exe.sig
You need to install at least the following packages:
	bash
	coreutils
	gnupg
	grep
	make
	mingw-gcc-core
	perl
	zip
Don't install the Cygwin python package. Use Python's own Windows
installer as described in the next section.

=== Python

Get the latest 32-bit installer in the 2.x series.

http://python.org/download/
http://python.org/ftp/python/2.7.3/python-2.7.3.msi
http://python.org/ftp/python/2.7.3/python-2.7.3.msi.asc

Verify the signature (instructions are on the download page).
	$ gpg --verify python-2.7.3.msi.asc
Run the installer. "Install for all users". Disable "Tcl/Tk",
"Documentation", "Utility Scripts", and "Test suite".

Set the PATH environment variable as described at
http://docs.python.org/2/using/windows.html#configuring-python:
	PATH=<existing path>;C:\Python27
You will have to restart your Cygwin shells to pick up the new PATH.

=== py2exe

http://sourceforge.net/projects/py2exe/files/py2exe/
http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.7.exe/download

The sha256sum of the package I used was

610a8800de3d973ed5ed4ac505ab42ad058add18a68609ac09e6cf3598ef056c  py2exe-0.6.9.win32-py2.7.exe

=== OpenSSL

https://openssl.org/source/
https://openssl.org/source/openssl-1.0.1c.tar.gz
https://openssl.org/source/openssl-1.0.1c.tar.gz.asc

Verify the signature.
	$ gpg --verify openssl-1.0.1c.tar.gz.asc
Build OpenSSL from source using Cygwin and MinGW. Install the Cygwin
package mingw-gcc-core if it's not already installed. Run these commands
in the OpenSSL source directory:
	CROSS_COMPILE=i686-pc-mingw32- ./Configure shared mingw
	make
	make install
Then, add C:\cygwin\usr\local\ssl\bin to PATH as you did with Python
above.

=== SWIG

This is a prerequisite for building M2Crypto.

http://www.swig.org/download.html
http://downloads.sourceforge.net/project/swig/swigwin/swigwin-2.0.8/swigwin-2.0.8.zip

The sha256sum of the package I used was

35bc3013d43e0034677c08bab30bfc94ed6d44fbfffa4c5158f5788d29f4636d  swigwin-2.0.8.zip

Just extract the zip in the same directory in which you will extract
M2Crypto.

=== M2Crypto

http://chandlerproject.org/Projects/MeTooCrypto#Downloads
http://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.21.1.tar.gz
http://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.21.1.tar.gz.asc

There are binary installers on the M2Crypto page, but it says they are
"provided by volunteers, untested by M2Crypto author." Instead build
from source.

The distutils build_ext command hardcodes the compiler name "gcc" when
using the "mingw32" compiler. Make a copy of the MinGW compiler with
that name.
	$ cp /usr/bin/i686-pc-mingw32-gcc /usr/bin/gcc
Build the package.
	$ PATH=$PATH:../swigwin-2.0.8 python setup.py build_ext -c mingw32 --openssl C:\\cygwin\\usr\\local\\ssl -L C:\\cygwin\\usr\\local\\ssl\\bin
	$ python setup.py bdist_wininst
This will leave an MSI installer in the dist directory. Double-click it
to install M2Crypto amid the other Python files.

=== 7-Zip

This is used to build a self-extracting bundle executable. The p7zip
package from Cywin doesn't work because the self-extracting executables
it produces requrie cygwin1.dll.

http://7-zip.org/download.html
http://downloads.sourceforge.net/project/sevenzip/7-Zip/9.20/7z920.msi

The sha256sum of the package I used was

fe4807b4698ec89f82de7d85d32deaa4c772fc871537e31fb0fccf4473455cb8 7z920.msi

=== PyCrypto

This is a dependency of obfsproxy and Twisted.

https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz
https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz.asc

To install run:

	$ /cygdrive/c/Python27/python.exe setup.py install

=== setuptools

This is needed solely to install the zopeinterface egg in the next step.

http://pypi.python.org/pypi/setuptools
http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe

The sha256sum of the package I used was

676d0add7ece45aaee7dddb6ecb883cb531c68f064f56376f529b47228c467eb setuptools-0.6c11.win32-py2.7.exe

=== zope.interface

This is a dependency of Twisted.

http://pypi.python.org/pypi/zope.interface#download
http://pypi.python.org/packages/2.7/z/zope.interface/zope.interface-4.0.3-py2.7-win32.egg

The sha256sum of the package I used was

3898e9ff89121aae1e8387bf2da75535911d8422dad3a194176d78766573b5d2 zope.interface-4.0.3-py2.7-win32.egg

	$ /cygdrive/c/Python27/Scripts/easy_install zope.interface-4.0.3-py2.7-win32.egg

=== Twisted

http://twistedmatrix.com/trac/wiki/Downloads
http://twistedmatrix.com/Releases/Twisted/12.3/Twisted-12.3.0.win32-py2.7.msi
http://twistedmatrix.com/Releases/twisted-12.3.0-md5sums.txt

	$ gpg --verify twisted-12.3.0-md5sums.txt
	$ grep win32-py2\\.7\\.msi twisted-12.3.0-md5sums.txt
	$ md5sum Twisted-12.3.0.win32-py2.7.msi

== Browser bundle

Clone pyptlib, obfsproxy, and flashproxy. Set each one to the branch you
want to include in the builds; e.g., "git pull" or "git checkout 1.0".

	$ cd
	$ git clone https://git.torproject.org/pluggable-transports/pyptlib.git
	$ git clone https://git.torproject.org/pluggable-transports/obfsproxy.git
	$ git clone https://git.torproject.org/flashproxy.git

Enter the doc directory and edit the top of Makefile to set the version
numbers you want to use.
	BUNDLE_VERSION = ...
	BUNDLE_RELEASE = ...
	PT_BUNDLE_RELEASE = pt1
The latest Tor Browser Bundle version number can be found at
https://www.torproject.org/projects/torbrowser.html.en#Download-torbrowserbundlealpha.
PT_BUNDLE_RELEASE release should increment each time you build a new
bundle with the same BUNDLE_VERSION and BUNDLE_RELEASE, and be reset to
"pt1" when either of those change.

	$ make windows PYTHON=/cygdrive/c/Python27/python

Test running the bundle. Extract into a separate directory, double-click
the icon and "Start Tor Browser.exe".
