build 4.77 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
  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/"
47
  [% IF c("var/asan") -%]
48
    cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libasan.so.3 "$distdir/Tor/"
49
50
    cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libubsan.so.0 "$distdir/Tor/"
  [% END -%]
boklm's avatar
boklm committed
51
52
53
  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
54
55
[% END %]

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

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

boklm's avatar
boklm committed
82
[% IF c("var/osx") %]
boklm's avatar
boklm committed
83
84
85
86
87
  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
88
[% END %]
boklm's avatar
boklm committed
89
90
91

cd $distdir
[% IF c("var/windows") %]
boklm's avatar
boklm committed
92
  install -s $distdir/bin/tor.exe $distdir/Tor/
boklm's avatar
boklm committed
93
[% IF c("var/expert_bundle") %]
boklm's avatar
boklm committed
94
  install -s $distdir/bin/tor-gencert.exe $distdir/Tor/
boklm's avatar
boklm committed
95
96
97
98
[% END %]
[% END %]

[% IF c("var/linux") %]
boklm's avatar
boklm committed
99
100
101
102
103
104
105
106
107
108
109
  # 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
110
111
112
[% END %]

mkdir -p [% dest_dir _ '/' _ c('filename') %]
boklm's avatar
boklm committed
113
[%
boklm's avatar
boklm committed
114
   IF c("var/expert_bundle");
115
     SET win_arch = c('var/windows-x86_64') ? 'win64' : 'win32';
boklm's avatar
boklm committed
116
117
     c('zip', {
        zip_src => [ 'Data', 'Tor', ],
118
        zip_args => dest_dir _ '/' _ c('filename') _ '/tor-' _ win_arch _ '-' _ c("version") _ '.zip',
boklm's avatar
boklm committed
119
      });
boklm's avatar
boklm committed
120
   ELSE;
boklm's avatar
boklm committed
121
122
123
124
125
126
127
128
129
     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
130
   END;
boklm's avatar
boklm committed
131
%]
boklm's avatar
boklm committed
132
133
134
135

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