build 3.94 KB
Newer Older
boklm's avatar
boklm committed
1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
set -e
rootdir=$(pwd)
export TZ=UTC
export LC_ALL=C
umask 0022
[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
distdir=/var/tmp/dist/[% project %]
mkdir -p /var/tmp/build

[% IF c("var/linux") || c("var/windows") %]
boklm's avatar
boklm committed
12
13
TORCONFIGDIR="$distdir/Data/Tor"
mkdir -p $TORCONFIGDIR
boklm's avatar
boklm committed
14
15
16
mkdir -p "$distdir/Tor"
[% END %]

boklm's avatar
boklm committed
17
[% IF c("var/osx") %]
18
19
TORBINDIR="$distdir/Contents/MacOS/Tor"
TORCONFIGDIR="$distdir/Contents/Resources/TorBrowser/Tor"
boklm's avatar
boklm committed
20
21
22
23
24
mkdir -p $distdir/bin
mkdir -p $TORBINDIR
mkdir -p $TORCONFIGDIR
[% END %]

boklm's avatar
boklm committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
tar -C /var/tmp/build -xf [% c('input_files_by_name/openssl') %]
tar -C /var/tmp/build -xf [% c('input_files_by_name/libevent') %]
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
libeventdir=/var/tmp/build/libevent
openssldir=/var/tmp/build/openssl

[% IF c("var/windows") %]
tar -C /var/tmp/build -xf [% c('input_files_by_name/zlib') %]
zlibdir=/var/tmp/build/zlib
cp $zlibdir/lib/*.dll $openssldir/bin/*.dll $libeventdir/bin/*.dll \
    $gcclibs/*.dll $distdir/Tor/
[% END %]


[% IF c("var/linux") %]
mkdir -p "$distdir/Debug/Tor"
cp $openssldir/lib/libssl.so.1.0.0 "$distdir/Tor/"
cp $openssldir/lib/libcrypto.so.1.0.0 "$distdir/Tor/"
cp $libeventdir/lib/libevent-2.0.so.5 "$distdir/Tor/"
# We need to copy the libstdc++.so.6 for Tor Browser on older Linux distros.
# Copying it into /Browser, which feels more natural, and amending
# LD_LIBRARY_PATH breaks updates from a Tor Browser with the old
# LD_LIBRARY_PATH value to the Tor Browser with the newer one. Thus, we copy
# the libstdc++ into the directory with the libs tor depends on, too. See bug
# 13359 for further details.
cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libstdc++.so.6 "$distdir/Tor/"
chmod 700 "$distdir"/Tor/*.so*
# This is needed to make RPATH unavailable. See bug 9150.
export LD_LIBRARY_PATH="$distdir/Tor/"
[% END %]

cd /var/tmp/build/[% project %]-[% c('version') %]
./autogen.sh
58
find -type f -print0 | xargs -0 [% c("var/touch") %]
boklm's avatar
boklm committed
59
60
./configure --disable-asciidoc --with-libevent-dir="$libeventdir" --with-openssl-dir="$openssldir" \
    [% IF c("var/windows") %]--with-zlib-dir="$zlibdir"[% END %] \
61
    [% IF c("var/osx") %]--enable-static-openssl[% END %] \
boklm's avatar
boklm committed
62
    --prefix="$distdir" [% c("var/configure_opt") %]
boklm's avatar
boklm committed
63
64
65
66
[% IF c("var/osx") -%]
  export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
  export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]"
[% END -%]
boklm's avatar
boklm committed
67
68
make -j4
make install
boklm's avatar
boklm committed
69
70
71
[% IF c("var/osx") -%]
  unset LD_PRELOAD
[% END -%]
boklm's avatar
boklm committed
72
73
cp $distdir/share/tor/geoip $TORCONFIGDIR
cp $distdir/share/tor/geoip6 $TORCONFIGDIR
boklm's avatar
boklm committed
74

boklm's avatar
boklm committed
75
76
77
78
79
80
81
[% IF c("var/osx") %]
LIBEVENT_FILE=`basename $libeventdir/lib/libevent-*.dylib`
cd $distdir
cp bin/tor $TORBINDIR/
cd $TORBINDIR/
x86_64-apple-darwin10-install_name_tool -change $libeventdir/lib/$LIBEVENT_FILE @executable_path/$LIBEVENT_FILE tor
[% END %]
boklm's avatar
boklm committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

cd $distdir
[% IF c("var/windows") %]
install -s $distdir/bin/tor.exe $distdir/Tor/
[% IF c("var/expert_bundle") %]
install -s $distdir/bin/tor-gencert.exe $distdir/Tor/
[% END %]
[% END %]

[% IF c("var/linux") %]
# Strip and generate debuginfo for libs
objcopy --only-keep-debug $distdir/bin/tor $distdir/Debug/Tor/tor
install -s $distdir/bin/tor $distdir/Tor/
objcopy --add-gnu-debuglink=./Debug/Tor/tor $distdir/Tor/tor
for i in $distdir/Tor/*so*
do
    LIB=`basename $i`
    objcopy --only-keep-debug $distdir/Tor/$LIB $distdir/Debug/Tor/$LIB
    strip $distdir/Tor/$LIB
    objcopy --add-gnu-debuglink=./Debug/Tor/$LIB $distdir/Tor/$LIB
done
[% END %]

mkdir -p [% dest_dir _ '/' _ c('filename') %]
boklm's avatar
boklm committed
106
107
[%
   IF c("var/osx");
108
     SET tarsrcdir = [ 'Contents' ];
boklm's avatar
boklm committed
109
110
111
112
113
   ELSE;
     SET tarsrcdir = [ 'Data', 'Tor', ];
   END;
   c('tar', {
        tar_src => tarsrcdir,
boklm's avatar
boklm committed
114
115
116
117
118
119
120
121
122
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename') _ '/tor.tar.gz',
    }) %]

[% IF c("var/linux") %]
[% c('tar', {
        tar_src => [ 'Debug' ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename') _ '/tor-debug.tar.gz',
    }) %]
[% END %]