123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- #!/bin/bash
- [% c("var/set_default_env") -%]
- [% 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") %]
- TORCONFIGDIR="$distdir/Data/Tor"
- mkdir -p $TORCONFIGDIR
- mkdir -p "$distdir/Tor"
- [% END %]
- [% IF c("var/osx") %]
- [% IF c("var/nightly") %]
- # We are compiling Tor with Rust enabled for nightlies.
- export TOR_RUST_TARGET=x86_64-apple-darwin
- [% END %]
- TORBINDIR="$distdir/Contents/MacOS/Tor"
- TORCONFIGDIR="$distdir/Contents/Resources/TorBrowser/Tor"
- mkdir -p $distdir/bin
- mkdir -p $TORBINDIR
- mkdir -p $TORCONFIGDIR
- [% END %]
- tar -C /var/tmp/dist -xf [% c('input_files_by_name/openssl') %]
- tar -C /var/tmp/dist -xf [% c('input_files_by_name/libevent') %]
- [% IF !c("var/android") && c("var/nightly") %]
- tar -C /var/tmp/dist -xf [% c('input_files_by_name/rust') %]
- export PATH=/var/tmp/dist/rust/bin:$PATH
- [% END %]
- tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
- libeventdir=/var/tmp/dist/libevent
- openssldir=/var/tmp/dist/openssl
- [% IF c("var/windows") %]
- [% IF c("var/nightly") %]
- # We are compiling Tor with Rust enabled for nightlies.
- export TOR_RUST_TARGET=[% c("arch") %]-pc-windows-gnu
- [% END %]
- tar -C /var/tmp/build -xf [% c('input_files_by_name/zlib') %]
- zlibdir=/var/tmp/build/zlib
- mingwlibs=/var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/bin/
- cp $zlibdir/lib/*.dll $openssldir/bin/*.dll $libeventdir/bin/*.dll \
- $gcclibs/*.dll $mingwlibs/libwinpthread-1.dll $distdir/Tor/
- [% END %]
- [% IF c("var/linux-i686") && c("var/nightly") -%]
- export TOR_RUST_TARGET=i686-unknown-linux-gnu
- [% 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.1.so.6 "$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.
- mkdir -p "$distdir/Tor/libstdc++"
- cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libstdc++.so.6 "$distdir/Tor/libstdc++/"
- [% IF c("var/asan") -%]
- cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libasan.so.3 "$distdir/Tor/"
- cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libubsan.so.0 "$distdir/Tor/"
- [% END -%]
- chmod 700 "$distdir"/Tor/*.so*
- chmod 700 "$distdir"/Tor/libstdc++/*.so*
- # This is needed to make RPATH unavailable. See bug 9150.
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$distdir/Tor/"
- [% END %]
- [% IF c("var/osx") %]
- cp $libeventdir/lib/libevent-*.dylib $TORBINDIR/
- [% END %]
- cd /var/tmp/build/[% project %]-[% c('version') %]
- # add git hash to micro-revision.i for #24995
- echo '"[% c("abbrev", { abbrev_length => 16 }) %]"' > micro-revision.i
- ./autogen.sh
- find -type f -print0 | xargs -0 [% c("var/touch") %]
- [% IF !c("var/android") && c("var/nightly") %]TOR_RUST_DEPENDENCIES=`pwd`/src/ext/rust/crates[% END %] ./configure --disable-asciidoc --with-libevent-dir="$libeventdir" --with-openssl-dir="$openssldir" \
- [% IF c("var/asan") %]--enable-fragile-hardening[% END %] \
- [% IF c("var/windows") %]--with-zlib-dir="$zlibdir"[% END %] \
- [% IF c("var/osx") %]--enable-static-openssl[% END %] \
- [% IF !c("var/android") && c("var/nightly") %]--enable-rust[% END %] \
- --prefix="$distdir" [% c("var/configure_opt") %]
- [% IF c("var/osx") || c("var/windows") -%]
- export LD_PRELOAD=[% c("var/faketime_path") %]
- export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]"
- [% END -%]
- make -j[% c("buildconf/num_procs") %]
- make install
- [% IF c("var/osx") -%]
- unset LD_PRELOAD
- [% END -%]
- cp $distdir/share/tor/geoip $TORCONFIGDIR
- cp $distdir/share/tor/geoip6 $TORCONFIGDIR
- [% IF c("var/osx") %]
- LIBEVENT_FILE=`basename $libeventdir/lib/libevent-*.dylib`
- cd $distdir
- cp bin/tor $TORBINDIR/
- cd $TORBINDIR/
- x86_64-apple-darwin11-install_name_tool -change $libeventdir/lib/$LIBEVENT_FILE @executable_path/$LIBEVENT_FILE tor
- [% END %]
- 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') %]
- [%
- IF c("var/expert_bundle");
- SET win_arch = c('var/windows-x86_64') ? 'win64' : 'win32';
- c('zip', {
- zip_src => [ 'Data', 'Tor', ],
- zip_args => dest_dir _ '/' _ c('filename') _ '/tor-' _ win_arch _ '-' _ c("version") _ '.zip',
- });
- ELSE;
- 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',
- });
- END;
- %]
- [% IF c("var/linux") %]
- [% c('tar', {
- tar_src => [ 'Debug' ],
- tar_args => '-cJf ' _ dest_dir _ '/' _ c('filename') _ '/tor-debug.tar.xz',
- }) %]
- [% END %]
|