build 4.02 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
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 %]

56
57
58
59
[% IF c("var/osx") %]
cp $libeventdir/lib/libevent-*.dylib $TORBINDIR/
[% END %]

boklm's avatar
boklm committed
60
61
cd /var/tmp/build/[% project %]-[% c('version') %]
./autogen.sh
62
find -type f -print0 | xargs -0 [% c("var/touch") %]
boklm's avatar
boklm committed
63
64
./configure --disable-asciidoc --with-libevent-dir="$libeventdir" --with-openssl-dir="$openssldir" \
    [% IF c("var/windows") %]--with-zlib-dir="$zlibdir"[% END %] \
65
    [% IF c("var/osx") %]--enable-static-openssl[% END %] \
boklm's avatar
boklm committed
66
    --prefix="$distdir" [% c("var/configure_opt") %]
boklm's avatar
boklm committed
67
68
69
70
[% 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
71
72
make -j4
make install
boklm's avatar
boklm committed
73
74
75
[% IF c("var/osx") -%]
  unset LD_PRELOAD
[% END -%]
boklm's avatar
boklm committed
76
77
cp $distdir/share/tor/geoip $TORCONFIGDIR
cp $distdir/share/tor/geoip6 $TORCONFIGDIR
boklm's avatar
boklm committed
78

boklm's avatar
boklm committed
79
80
81
82
83
84
85
[% 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

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
110
111
[%
   IF c("var/osx");
112
     SET tarsrcdir = [ 'Contents' ];
boklm's avatar
boklm committed
113
114
115
116
117
   ELSE;
     SET tarsrcdir = [ 'Data', 'Tor', ];
   END;
   c('tar', {
        tar_src => tarsrcdir,
boklm's avatar
boklm committed
118
119
120
121
122
123
124
125
126
        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 %]