Skip to content

Commit

Permalink
1. Statically linking openssl | libevent in tor for mac
Browse files Browse the repository at this point in the history
2. Correct binary naming for windows and linux
3. Move hashes/keys to env.sh
  • Loading branch information
jumde committed May 18, 2018
1 parent 944617c commit 9b194ab
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 22 deletions.
29 changes: 19 additions & 10 deletions Dockerfile-linux
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
FROM ubuntu:xenial
MAINTAINER Pranjal <pranjal@brave.com>

ARG zlib_version=1.2.11
ARG libevent_version=2.1.8-stable
ARG openssl_version=1.0.2m
ARG tor_version=0.3.2.10
ARG zlib_version
ARG zlib_hash

ARG libevent_version
ARG libevent_hash
ARG libevent_key

ARG openssl_version
ARG openssl_hash

ARG tor_version
ARG tor_hash
ARG tor_key

RUN \
apt-get update && \
apt-get install -y build-essential curl autotools-dev automake gnupg2

RUN \
curl -fsSL "https://zlib.net/zlib-${zlib_version}.tar.gz" -o zlib-$zlib_version.tar.gz && \
echo "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 zlib-$zlib_version.tar.gz" | shasum -a 256 -c - && \
echo "$zlib_hash zlib-$zlib_version.tar.gz" | shasum -a 256 -c - && \
tar -zxvf zlib-$zlib_version.tar.gz && \
cd zlib-$zlib_version && \
./configure --prefix=$PWD/install && \
Expand All @@ -21,9 +30,9 @@ RUN \
RUN \
curl -fsSL "https://github.com/libevent/libevent/releases/download/release-$libevent_version/libevent-$libevent_version.tar.gz" -o libevent-$libevent_version.tar.gz && \
curl -fsSL "https://github.com/libevent/libevent/releases/download/release-$libevent_version/libevent-$libevent_version.tar.gz.asc" -o libevent-$libevent_version.tar.gz.asc && \
gpg --keyserver pgp.mit.edu/ --recv B86086848EF8686D && \
gpg --keyserver pgp.mit.edu/ --recv $libevent_key && \
gpg libevent-$libevent_version.tar.gz.asc && \
echo "965cc5a8bb46ce4199a47e9b2c9e1cae3b137e8356ffdad6d94d3b9069b71dc2 libevent-$libevent_version.tar.gz" | shasum -a 256 -c - && \
echo "$libevent_hash libevent-$libevent_version.tar.gz" | shasum -a 256 -c - && \
tar -zxvf libevent-$libevent_version.tar.gz && \
cd libevent-$libevent_version && \
./configure --prefix=$PWD/install \
Expand All @@ -34,7 +43,7 @@ RUN \

RUN \
curl -fsSL "https://www.openssl.org/source/openssl-$openssl_version.tar.gz" -o openssl-$openssl_version.tar.gz && \
echo "8c6ff15ec6b319b50788f42c7abc2890c08ba5a1cdcd3810eb9092deada37b0f openssl-$openssl_version.tar.gz" | shasum -a 256 -c - && \
echo "$openssl_hash openssl-$openssl_version.tar.gz" | shasum -a 256 -c - && \
tar -xvzf openssl-$openssl_version.tar.gz && \
cd openssl-$openssl_version && \
./config --prefix=$PWD/install no-shared no-dso && \
Expand All @@ -43,9 +52,9 @@ RUN \
RUN \
curl -fsSL "https://www.torproject.org/dist/tor-$tor_version.tar.gz" -o tor-$tor_version.tar.gz && \
curl -fsSL "https://www.torproject.org/dist/tor-$tor_version.tar.gz.asc" -o tor-$tor_version.tar.gz.asc && \
gpg --keyserver pgp.mit.edu/ --recv FE43009C4607B1FB && \
gpg --keyserver pgp.mit.edu/ --recv $tor_key && \
gpg tor-$tor_version.tar.gz.asc && \
echo "60df77c31dcf94fdd686c8ca8c34f3b70243b33a7344ecc0b719d5ca2617cbee tor-$tor_version.tar.gz" | shasum -a 256 -c - && \
echo "$tor_hash tor-$tor_version.tar.gz" | shasum -a 256 -c - && \
tar -xvzf tor-$tor_version.tar.gz && \
cd tor-$tor_version && \
./configure --prefix=$PWD/install \
Expand Down
47 changes: 40 additions & 7 deletions build_darwin.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
#!/bin/sh
set -eu

curl -fsSL "https://www.torproject.org/dist/tor-0.3.2.10.tar.gz" -o tor-0.3.2.10.tar.gz
curl -fsSL "https://www.torproject.org/dist/tor-0.3.2.10.tar.gz.asc" -o tor-0.3.2.10.tar.gz.asc
curl -fsSL "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" -o openssl-$OPENSSL_VERSION.tar.gz && \
echo "$OPENSSL_HASH openssl-$OPENSSL_VERSION.tar.gz" | shasum -a 256 -c - && \
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz && \
cd openssl-$OPENSSL_VERSION && \
./config --prefix=$PWD/install no-shared no-dso && \
make

gpg --keyserver pgp.mit.edu/ --recv FE43009C4607B1FB
gpg tor-0.3.2.10.tar.gz.asc
cd ..

curl -fsSL "https://github.com/libevent/libevent/releases/download/release-$LIBEVENT_VERSION/libevent-$LIBEVENT_VERSION.tar.gz" -o libevent-$LIBEVENT_VERSION.tar.gz && \
curl -fsSL "https://github.com/libevent/libevent/releases/download/release-$LIBEVENT_VERSION/libevent-$LIBEVENT_VERSION.tar.gz.asc" -o libevent-$LIBEVENT_VERSION.tar.gz.asc && \

gpg --keyserver pgp.mit.edu/ --recv $LIBEVENT_KEY && \
gpg libevent-$LIBEVENT_VERSION.tar.gz.asc && \
echo "$LIBEVENT_HASH libevent-$LIBEVENT_VERSION.tar.gz" | shasum -a 256 -c - && \
tar -zxvf libevent-$LIBEVENT_VERSION.tar.gz && \
cd libevent-$LIBEVENT_VERSION && \
./configure \
LDFLAGS="-L/usr/local/opt/openssl/lib" \
CPPFLAGS="-I/usr/local/opt/openssl/include" \
--prefix=$PWD/install \
--disable-shared \
--enable-static \
--with-pic && \
make && make check && make install

cd ..

curl -fsSL "https://www.torproject.org/dist/tor-$TOR_VERSION.tar.gz" -o tor-$TOR_VERSION.tar.gz
curl -fsSL "https://www.torproject.org/dist/tor-$TOR_VERSION.tar.gz.asc" -o tor-$TOR_VERSION.tar.gz.asc

tar -xvzf tor-0.3.2.10.tar.gz
cd tor-0.3.2.10
./configure && make && make install
gpg --keyserver pgp.mit.edu/ --recv $TOR_KEY
gpg tor-$TOR_VERSION.tar.gz.asc
echo "$TOR_HASH tor-$TOR_VERSION.tar.gz" | shasum -a 256 -c - && \
tar -xvzf tor-$TOR_VERSION.tar.gz
cd tor-$TOR_VERSION && \
./configure --enable-static-libevent \
--enable-static-openssl \
--with-libevent-dir=$PWD/../libevent-$LIBEVENT_VERSION/install \
--with-openssl-dir=$PWD/../openssl-$OPENSSL_VERSION/install \
--disable-asciidoc && \
make && make check
cd ..

cp tor-0.3.2.10/src/or/tor tor-darwin-$TOR_VERSION-brave-$BRAVE_TOR_VERSION
4 changes: 2 additions & 2 deletions build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
set -eu

docker rm -fv tor-brave || true
docker build -t tor-brave -f Dockerfile-linux --build-arg tor_version=$TOR_VERSION --build-arg zlib_version=$ZLIB_VERSION --build-arg libevent_version=$LIBEVENT_VERSION --build-arg openssl_version=$OPENSSL_VERSION .
docker build -t tor-brave -f Dockerfile-linux --build-arg tor_version=$TOR_VERSION --build-arg zlib_version=$ZLIB_VERSION --build-arg libevent_version=$LIBEVENT_VERSION --build-arg openssl_version=$OPENSSL_VERSION --build-arg zlib_hash=$ZLIB_HASH --build-arg libevent_hash=$LIBEVENT_HASH --build-arg libevent_key=$LIBEVENT_KEY --build-arg openssl_hash=$OPENSSL_HASH --build-arg tor_hash=$TOR_HASH --build-arg tor_key=$TOR_KEY .
docker run --name tor-brave -d tor-brave
docker cp tor-brave:/tor-$TOR_VERSION/src/or/tor tor-linux-$TOR_VERSION-brave-$BRAVE_TOR_VERSION
docker cp tor-brave:/tor-$TOR_VERSION/src/or/tor tor-$TOR_VERSION-linux-brave-$BRAVE_TOR_VERSION
4 changes: 2 additions & 2 deletions build_win32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ gpg tor-win32-0.3.2.10.zip.asc

unzip tor-win32-0.3.2.10.zip
cd Tor
zip -r tor-win32-$TOR_VERSION-brave-$BRAVE_TOR_VERSION.zip .
zip -r tor-$TOR_VERSION-win32-brave-$BRAVE_TOR_VERSION.zip .
cd ..
mv Tor/tor-win32-$TOR_VERSION-brave-$BRAVE_TOR_VERSION.zip .
mv Tor/tor-$TOR_VERSION-win32-brave-$BRAVE_TOR_VERSION.zip .
10 changes: 9 additions & 1 deletion env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@ export BRAVE_TOR_VERSION="1"
export TOR_VERSION="0.3.2.10"
export ZLIB_VERSION=1.2.11
export LIBEVENT_VERSION=2.1.8-stable
export OPENSSL_VERSION=1.0.2m
export OPENSSL_VERSION=1.0.2o
export TOR_VERSION=0.3.2.10

export ZLIB_HASH=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
export LIBEVENT_HASH=965cc5a8bb46ce4199a47e9b2c9e1cae3b137e8356ffdad6d94d3b9069b71dc2
export OPENSSL_HASH=ec3f5c9714ba0fd45cb4e087301eb1336c317e0d20b575a125050470e8089e4d
export TOR_HASH=60df77c31dcf94fdd686c8ca8c34f3b70243b33a7344ecc0b719d5ca2617cbee

export LIBEVENT_KEY=B86086848EF8686D
export TOR_KEY=FE43009C4607B1FB

0 comments on commit 9b194ab

Please sign in to comment.