2011-04-15 16:39:35 +00:00
|
|
|
|
|
|
|
// 2011/04/15 this document is a bit out of date. We will be updating to use
|
|
|
|
// the standalone cross-compiler that is offered by the Android NDK soon
|
|
|
|
|
|
|
|
This document explains how to properly build an Android package of Orbot from
|
2009-10-25 06:38:14 +00:00
|
|
|
source. It covers building on Debian Lenny (5.0.3).
|
2009-10-25 00:01:12 +00:00
|
|
|
|
2009-10-25 02:47:27 +00:00
|
|
|
Please install the following prerequisites (instructions for each follows):
|
2009-10-25 04:49:06 +00:00
|
|
|
ant: http://ant.apache.org/
|
|
|
|
Android OS SDK: http://source.android.com/download
|
2009-10-25 00:01:12 +00:00
|
|
|
droid-wrapper: http://github.com/tmurakam/droid-wrapper
|
2009-10-25 04:49:06 +00:00
|
|
|
libevent source (1.4.12-stable from svn)
|
2009-10-25 00:01:12 +00:00
|
|
|
Tor source (most recent git master branch)
|
2010-03-18 04:52:53 +00:00
|
|
|
Privoxy source (http://sourceforge.net/projects/ijbswa/)
|
|
|
|
|
2009-10-25 00:47:19 +00:00
|
|
|
Install and prepare the Android OS SDK ( http://source.android.com/download )
|
|
|
|
on Debian Lenny:
|
|
|
|
|
|
|
|
sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf \
|
|
|
|
libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip \
|
2009-10-27 04:20:30 +00:00
|
|
|
curl libncurses5-dev zlib1g-dev valgrind libtool automake \
|
|
|
|
ruby subversion
|
2009-10-25 01:06:59 +00:00
|
|
|
update-java-alternatives -s java-1.5.0-sun
|
2009-10-25 00:47:19 +00:00
|
|
|
|
2011-10-28 15:00:26 +00:00
|
|
|
mkdir ~/bin
|
|
|
|
PATH=~/bin:$PATH
|
|
|
|
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
|
2009-10-25 00:47:19 +00:00
|
|
|
chmod a+x ~/bin/repo
|
|
|
|
|
|
|
|
mkdir ~/mydroid
|
|
|
|
cd ~/mydroid
|
|
|
|
|
2011-10-28 15:00:26 +00:00
|
|
|
repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.7_r1
|
2009-10-25 00:47:19 +00:00
|
|
|
repo sync
|
|
|
|
|
|
|
|
# Paste in key from http://source.android.com/download next...
|
|
|
|
gpg --import
|
|
|
|
|
|
|
|
cd ~/mydroid
|
2009-10-25 00:52:32 +00:00
|
|
|
|
|
|
|
# This takes a long while...
|
2009-10-25 00:47:19 +00:00
|
|
|
make
|
|
|
|
|
2009-10-25 00:52:32 +00:00
|
|
|
Install droid-wrapper:
|
|
|
|
|
|
|
|
cd /tmp
|
|
|
|
git clone git://github.com/tmurakam/droid-wrapper.git
|
|
|
|
cd droid-wrapper
|
|
|
|
sudo make install
|
|
|
|
|
2009-10-25 02:47:27 +00:00
|
|
|
zlib and OpenSSL are included with the Android OS SDK. You'll need to build
|
2010-02-08 20:39:42 +00:00
|
|
|
libevent, Privoxy and finally Tor. We'll create an externals directory for this code:
|
2009-10-25 01:06:59 +00:00
|
|
|
|
2010-02-08 20:39:42 +00:00
|
|
|
mkdir -p ~/mydroid/external/{libevent,tor,privoxy}
|
2009-10-25 01:06:59 +00:00
|
|
|
|
2009-10-25 02:47:27 +00:00
|
|
|
We need to set to environment variables for droid-gcc:
|
|
|
|
export DROID_ROOT=~/mydroid/
|
|
|
|
export DROID_TARGET=generic
|
|
|
|
|
2011-10-28 15:00:26 +00:00
|
|
|
Fetch and build Privoxy:c
|
2010-02-08 20:39:42 +00:00
|
|
|
cd ~/mydroid/external/privoxy
|
|
|
|
wget http://sourceforge.net/projects/ijbswa/files/Sources/3.0.12%20%28stable%29/privoxy-3.0.12-stable-src.tar.gz/download
|
|
|
|
tar xzvf privoxy-3.0.12-stable-src.tar.gz
|
|
|
|
cd privoxy-3.0.12-stable
|
|
|
|
autoheader
|
|
|
|
autoconf
|
|
|
|
#need to disable setpgrp check in configure
|
2010-03-18 04:52:53 +00:00
|
|
|
export ac_cv_func_setpgrp_void=yes
|
2011-10-28 15:00:26 +00:00
|
|
|
CC=droid-gcc LD=droid-ld CPPFLAGS="-I$DROID_ROOT/external/zlib/" ./configure --host=arm-none-linux-gnueabi
|
2010-02-23 04:45:50 +00:00
|
|
|
#don't mind the "unrecognized option '-pthread'" error message that you'll see when you run make
|
2010-03-18 04:52:53 +00:00
|
|
|
make
|
2010-02-08 20:39:42 +00:00
|
|
|
|
2009-10-25 02:47:27 +00:00
|
|
|
Fetch and build libevent:
|
|
|
|
|
|
|
|
cd ~/mydroid/external/libevent
|
2011-10-28 15:00:26 +00:00
|
|
|
svn co https://levent.svn.sourceforge.net/svnroot/levent/tags/release-1.4.13-stable/libevent/ .
|
2011-05-10 02:08:50 +00:00
|
|
|
export LIBEVENTDIR=`cd $DROID_ROOT/external/libevent && pwd`
|
2009-10-25 02:47:27 +00:00
|
|
|
./autogen.sh
|
2009-10-25 04:49:06 +00:00
|
|
|
# Put the contents of http://pastebin.ca/1577207 in /tmp/libevent-patch
|
2011-10-28 15:00:26 +00:00
|
|
|
# path no longer needed: patch < /tmp/libevent-patch
|
2009-10-25 02:47:27 +00:00
|
|
|
CC=droid-gcc LD=droid-ld ./configure --host=arm-none-linux-gnueabi
|
|
|
|
make
|
|
|
|
|
2009-10-25 04:17:53 +00:00
|
|
|
Copy over the libevent library:
|
2011-05-10 02:08:50 +00:00
|
|
|
cp .libs/libevent.a $DROID_ROOT/out/target/product/generic/obj/lib
|
2009-10-25 04:17:53 +00:00
|
|
|
|
2009-10-25 02:47:27 +00:00
|
|
|
Fetch and build Tor:
|
|
|
|
|
2011-05-10 02:08:50 +00:00
|
|
|
export OPENSSLDIR=`cd $DROID_ROOT/external/openssl/include/ && pwd`
|
|
|
|
export ZLIBDIR=`cd $DROID_ROOT/external/zlib && pwd`
|
2009-10-25 02:47:27 +00:00
|
|
|
|
2011-05-10 02:08:50 +00:00
|
|
|
cd $DROID_ROOT/external/tor
|
2010-02-08 20:39:42 +00:00
|
|
|
git clone git://git.torproject.org/git/tor.git
|
2009-10-25 02:47:27 +00:00
|
|
|
cd tor/
|
2009-10-27 04:20:30 +00:00
|
|
|
./autogen.sh
|
2009-10-25 02:47:27 +00:00
|
|
|
CC=droid-gcc LD=droid-ld ./configure --host=arm-none-linux-gnueabi \
|
|
|
|
--with-libevent-dir=$LIBEVENTDIR --with-openssl-dir=$OPENSSLDIR \
|
2010-05-28 16:47:45 +00:00
|
|
|
--with-zlib-dir=$ZLIBDIR --disable-asciidoc
|
2009-10-25 02:47:27 +00:00
|
|
|
make
|
|
|
|
|
|
|
|
At this point, you'll have a Tor binary that can be run on an Android handset.
|
2011-05-10 02:08:50 +00:00
|
|
|
You can verify the ARM binary was properly built using the following command:
|
2009-10-25 01:06:59 +00:00
|
|
|
|
2011-05-10 02:08:50 +00:00
|
|
|
file src/or/tor
|
|
|
|
|
|
|
|
You should see something like:
|
|
|
|
src/or/tor: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
|
2009-10-25 05:06:49 +00:00
|
|
|
|
2011-05-10 02:08:50 +00:00
|
|
|
This isn't enough though and we'll now sew up the binary into a small package
|
|
|
|
that will handle basic Tor controlling features.
|
2009-10-25 05:06:49 +00:00
|
|
|
|
2010-03-18 04:52:53 +00:00
|
|
|
We need to get the TorControl library for Java:
|
|
|
|
(see also https://svn.torproject.org/svn/torctl/trunk/doc/howto.txt)
|
2009-11-28 15:41:28 +00:00
|
|
|
|
|
|
|
git clone git://git.torproject.org/git/jtorctl
|
|
|
|
cd jtorctl
|
|
|
|
mkdir bin
|
|
|
|
javac net/freehaven/tor/control/TorControlConnection.java -d bin
|
|
|
|
cd bin
|
|
|
|
jar cvf jtorctrl.jar *
|
|
|
|
cp jtorctrl.jar {Orbot Home}/libs
|
|
|
|
|
2009-10-25 04:33:05 +00:00
|
|
|
Finally, we'll make a proper Android package with ant and the Android App SDK:
|
|
|
|
|
2009-10-25 04:35:51 +00:00
|
|
|
export APP_SDK=~/Documents/projects/android/android-sdk-linux_x86-1.5_r3/tools
|
2009-10-25 05:06:49 +00:00
|
|
|
cd ../Orbot/
|
2011-05-10 02:08:50 +00:00
|
|
|
cp $DROID_ROOT/external/privoxy/privoxy-3.0.12-stable/privoxy assets/privoxy
|
2011-07-25 21:35:39 +00:00
|
|
|
|
|
|
|
Now you need to split and copy the tor binary into res/raw. We split it into < 1M chunks
|
|
|
|
because some Android devices don't like resources larger than 1M.
|
|
|
|
|
|
|
|
split --bytes=1m $DROID_ROOT/external/tor/tor/src/or/tor res/raw/tor
|
|
|
|
|
|
|
|
Now build the Android app
|
2010-07-29 15:00:10 +00:00
|
|
|
$APP_SDK/android update project --name Orbot --target 3 --path .
|
2009-10-25 04:33:05 +00:00
|
|
|
ant release
|
|
|
|
|
2009-10-25 05:11:16 +00:00
|
|
|
This will produce an unsigned Tor package in ./bin/Orbot-unsigned.apk!
|
2009-10-25 05:27:19 +00:00
|
|
|
|
|
|
|
To produce a usable package, you'll need to sign the .apk. The basics on
|
|
|
|
signing can be found on the Android developer site:
|
|
|
|
|
|
|
|
http://developer.android.com/guide/publishing/app-signing.html
|
|
|
|
|
|
|
|
The three steps are quite simple. First, you'll generate a key. Secondly,
|
|
|
|
you'll sign the application. Thirdly, you'll verify the the apk.
|
|
|
|
|
|
|
|
Generating a signing key:
|
|
|
|
|
|
|
|
keytool -genkey -v -keystore my-release-key.keystore \
|
|
|
|
-alias orbots_key -keyalg RSA -validity 10000
|
|
|
|
|
|
|
|
Sign the apk:
|
|
|
|
|
|
|
|
jarsigner -verbose -keystore my-release-key.keystore \
|
|
|
|
bin/Orbot-unsigned.apk orbots_key
|
|
|
|
|
|
|
|
Verify the signature for the apk:
|
|
|
|
|
|
|
|
jarsigner -verify bin/Orbot-unsigned.apk
|
|
|
|
mv bin/Orbot-unsigned.apk bin/Orbot-signed-alpha.apk
|
|
|
|
|
2010-02-23 04:45:50 +00:00
|
|
|
You can also GPG sign the apk and generate an .asc:
|
|
|
|
|
|
|
|
gpg -ab Orbot-signed-alpha.apk
|
|
|
|
|
2009-10-25 05:27:19 +00:00
|
|
|
Now you should have a fully signed and production ready alpha release of Orbot!
|
|
|
|
Give bin/Orbot-signed-alpha.apk an install and send us bug reports!
|
2010-03-18 04:52:53 +00:00
|
|
|
|