build 5.41 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') %]
23
24
25
26
[% IF c("var/linux") && c("var/nightly") %]
  tar -C /var/tmp/dist -xf [% c('input_files_by_name/rust') %]
  export PATH=/var/tmp/dist/rust/bin:$PATH
[% END %]
boklm's avatar
boklm committed
27
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
28
29
libeventdir=/var/tmp/dist/libevent
openssldir=/var/tmp/dist/openssl
boklm's avatar
boklm committed
30
31

[% IF c("var/windows") %]
boklm's avatar
boklm committed
32
33
  tar -C /var/tmp/build -xf [% c('input_files_by_name/zlib') %]
  zlibdir=/var/tmp/build/zlib
34
  mingwlibs=/var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/bin/
boklm's avatar
boklm committed
35
  cp $zlibdir/lib/*.dll $openssldir/bin/*.dll $libeventdir/bin/*.dll \
36
      $gcclibs/*.dll $mingwlibs/libwinpthread-1.dll $distdir/Tor/
boklm's avatar
boklm committed
37
38
39
[% END %]

[% IF c("var/linux") %]
boklm's avatar
boklm committed
40
41
42
  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/"
43
  cp $libeventdir/lib/libevent-2.1.so.6 "$distdir/Tor/"
boklm's avatar
boklm committed
44
45
46
47
48
49
  # 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.
50
51
  mkdir -p "$distdir/Tor/libstdc++"
  cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libstdc++.so.6 "$distdir/Tor/libstdc++/"
52
  [% IF c("var/asan") -%]
53
    cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libasan.so.3 "$distdir/Tor/"
54
55
    cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libubsan.so.0 "$distdir/Tor/"
  [% END -%]
boklm's avatar
boklm committed
56
  chmod 700 "$distdir"/Tor/*.so*
57
  chmod 700 "$distdir"/Tor/libstdc++/*.so*
boklm's avatar
boklm committed
58
59
  # This is needed to make RPATH unavailable. See bug 9150.
  export LD_LIBRARY_PATH="$distdir/Tor/"
60
61
  # Add libstdc++ to LD_LIBRARY_PATH to avoid rust link issue (bug 27101)
  export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$distdir/Tor/libstdc++/"
boklm's avatar
boklm committed
62
63
[% END %]

64
[% IF c("var/osx") %]
boklm's avatar
boklm committed
65
  cp $libeventdir/lib/libevent-*.dylib $TORBINDIR/
66
67
[% END %]

boklm's avatar
boklm committed
68
cd /var/tmp/build/[% project %]-[% c('version') %]
69
70
# add git hash to micro-revision.i for #24995
echo '"[% c("abbrev", { abbrev_length => 16 }) %]"' > micro-revision.i
boklm's avatar
boklm committed
71
./autogen.sh
72
find -type f -print0 | xargs -0 [% c("var/touch") %]
73
[% IF c("var/linux") && c("var/nightly") %]TOR_RUST_DEPENDENCIES=`pwd`/src/ext/rust/crates[% END %] ./configure --disable-asciidoc --with-libevent-dir="$libeventdir" --with-openssl-dir="$openssldir" \
boklm's avatar
boklm committed
74
    [% IF c("var/asan") %]--enable-fragile-hardening[% END %] \
boklm's avatar
boklm committed
75
    [% IF c("var/windows") %]--with-zlib-dir="$zlibdir"[% END %] \
76
    [% IF c("var/osx") %]--enable-static-openssl[% END %] \
77
    [% IF c("var/linux") && c("var/nightly") %]--enable-rust[% END %] \
boklm's avatar
boklm committed
78
    --prefix="$distdir" [% c("var/configure_opt") %]
79
80
[% IF c("var/osx") || c("var/windows") -%]
  export LD_PRELOAD=[% c("var/faketime_path") %]
boklm's avatar
boklm committed
81
82
  export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]"
[% END -%]
83
make -j[% c("buildconf/num_procs") %]
boklm's avatar
boklm committed
84
make install
boklm's avatar
boklm committed
85
86
87
[% IF c("var/osx") -%]
  unset LD_PRELOAD
[% END -%]
boklm's avatar
boklm committed
88
89
cp $distdir/share/tor/geoip $TORCONFIGDIR
cp $distdir/share/tor/geoip6 $TORCONFIGDIR
boklm's avatar
boklm committed
90

boklm's avatar
boklm committed
91
[% IF c("var/osx") %]
boklm's avatar
boklm committed
92
93
94
95
  LIBEVENT_FILE=`basename $libeventdir/lib/libevent-*.dylib`
  cd $distdir
  cp bin/tor $TORBINDIR/
  cd $TORBINDIR/
96
  x86_64-apple-darwin11-install_name_tool -change $libeventdir/lib/$LIBEVENT_FILE @executable_path/$LIBEVENT_FILE tor
boklm's avatar
boklm committed
97
[% END %]
boklm's avatar
boklm committed
98
99
100

cd $distdir
[% IF c("var/windows") %]
boklm's avatar
boklm committed
101
  install -s $distdir/bin/tor.exe $distdir/Tor/
boklm's avatar
boklm committed
102
[% IF c("var/expert_bundle") %]
boklm's avatar
boklm committed
103
  install -s $distdir/bin/tor-gencert.exe $distdir/Tor/
boklm's avatar
boklm committed
104
105
106
107
[% END %]
[% END %]

[% IF c("var/linux") %]
boklm's avatar
boklm committed
108
109
110
111
112
113
114
115
116
117
118
  # 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
119
120
121
[% END %]

mkdir -p [% dest_dir _ '/' _ c('filename') %]
boklm's avatar
boklm committed
122
[%
boklm's avatar
boklm committed
123
   IF c("var/expert_bundle");
124
     SET win_arch = c('var/windows-x86_64') ? 'win64' : 'win32';
boklm's avatar
boklm committed
125
126
     c('zip', {
        zip_src => [ 'Data', 'Tor', ],
127
        zip_args => dest_dir _ '/' _ c('filename') _ '/tor-' _ win_arch _ '-' _ c("version") _ '.zip',
boklm's avatar
boklm committed
128
      });
boklm's avatar
boklm committed
129
   ELSE;
boklm's avatar
boklm committed
130
131
132
133
134
135
136
137
138
     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
139
   END;
boklm's avatar
boklm committed
140
%]
boklm's avatar
boklm committed
141
142
143
144

[% IF c("var/linux") %]
[% c('tar', {
        tar_src => [ 'Debug' ],
145
        tar_args => '-cJf ' _ dest_dir _ '/' _ c('filename') _ '/tor-debug.tar.xz',
boklm's avatar
boklm committed
146
147
    }) %]
[% END %]