build 4.33 KB
Newer Older
boklm's avatar
boklm committed
1
#!/bin/bash
2
[% c("var/set_default_env") -%]
boklm's avatar
boklm committed
3
4
5
6
7
[% 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
8
9
10
  TORCONFIGDIR="$distdir/Data/Tor"
  mkdir -p $TORCONFIGDIR
  mkdir -p "$distdir/Tor"
boklm's avatar
boklm committed
11
12
[% END %]

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

21
22
tar -C /var/tmp/dist -xf [% c('input_files_by_name/openssl') %]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/libevent') %]
boklm's avatar
boklm committed
23
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
24
25
libeventdir=/var/tmp/dist/libevent
openssldir=/var/tmp/dist/openssl
boklm's avatar
boklm committed
26
27

[% IF c("var/windows") %]
boklm's avatar
boklm committed
28
29
30
31
  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/
boklm's avatar
boklm committed
32
33
34
35
[% END %]


[% IF c("var/linux") %]
boklm's avatar
boklm committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  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/"
boklm's avatar
boklm committed
50
51
[% END %]

52
[% IF c("var/osx") %]
boklm's avatar
boklm committed
53
  cp $libeventdir/lib/libevent-*.dylib $TORBINDIR/
54
55
[% END %]

boklm's avatar
boklm committed
56
57
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") %]
63
64
[% IF c("var/osx") || c("var/windows") -%]
  export LD_PRELOAD=[% c("var/faketime_path") %]
boklm's avatar
boklm committed
65
66
  export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]"
[% END -%]
67
make -j[% c("buildconf/num_procs") %]
boklm's avatar
boklm committed
68
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
[% IF c("var/osx") %]
boklm's avatar
boklm committed
76
77
78
79
80
  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
boklm's avatar
boklm committed
81
[% END %]
boklm's avatar
boklm committed
82
83
84

cd $distdir
[% IF c("var/windows") %]
boklm's avatar
boklm committed
85
  install -s $distdir/bin/tor.exe $distdir/Tor/
boklm's avatar
boklm committed
86
[% IF c("var/expert_bundle") %]
boklm's avatar
boklm committed
87
  install -s $distdir/bin/tor-gencert.exe $distdir/Tor/
boklm's avatar
boklm committed
88
89
90
91
[% END %]
[% END %]

[% IF c("var/linux") %]
boklm's avatar
boklm committed
92
93
94
95
96
97
98
99
100
101
102
  # 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
boklm's avatar
boklm committed
103
104
105
[% END %]

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

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