123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- #!/bin/bash
- [% c("var/set_default_env") -%]
- [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
- [% IF c("var/linux-cross") -%]
- [% pc('gcc', 'var/setup', {
- compiler_tarfile => c('input_files_by_name/' _ 'gcc-host'),
- target => [ c('var/channel'), 'torbrowser-linux-x86_64' ]
- }) %]
- [% END -%]
- distdir=/var/tmp/dist/[% project %]
- mkdir -p /var/tmp/build
- [% IF c("var/android") %]
- TORCONFIGDIR="$distdir/assets/common"
- libsdir=$distdir/jniLibs/[% c("var/abi") %]
- mkdir -p $libsdir $TORCONFIGDIR "$distdir/Tor"
- [% END %]
- [% 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 %]
- [% IF c("var/windows") || c("var/android") %]
- tar -C /var/tmp/dist -xf [% c('input_files_by_name/zlib') %]
- zlibdir=/var/tmp/dist/zlib
- [% END %]
- [% IF c("var/android") %]
- tar -C /var/tmp/dist -xf [% c('input_files_by_name/zstd') %]
- [% END %]
- [% 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/dist -xf [% c('input_files_by_name/openssl') %]
- tar -C /var/tmp/dist -xf [% c('input_files_by_name/libevent') %]
- tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
- libeventdir=/var/tmp/dist/libevent
- openssldir=/var/tmp/dist/openssl/openssl
- [% IF c("var/linux-cross") -%]
- # Work around missing libraries. Maybe there's a better way?
- crossdepsdir=/var/tmp/dist/cross-deps-chroot
- mkdir -p $crossdepsdir
- pushd $crossdepsdir
- apt-get --option "APT::Architecture=[% c("var/arch_debian") %]" download $(apt-rdepends zlib1g-dev:[% c("var/arch_debian") %]|grep -v "^ "|grep -v "libc-dev")
- for PACKAGE in ./*.deb; do
- dpkg -x $PACKAGE ./
- done
- popd
- cp --archive --no-clobber $crossdepsdir/usr/include/* /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/include/
- cp --archive --no-clobber $crossdepsdir/usr/lib/[% c("var/crosstarget") %]/lib*.so* /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/
- cp --archive --no-clobber $crossdepsdir/lib/[% c("var/crosstarget") %]/libz*.so* /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/
- cp --archive $crossdepsdir/lib/[% c("var/crosstarget") %]/libz.so.1 /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/libz.so
- [% END -%]
- [% IF c("var/linux-arm") -%]
- [% IF c("var/nightly") %]
- # We are compiling Tor with Rust enabled for nightlies.
- export TOR_RUST_TARGET=armv7-unknown-linux-gnueabihf
- [% END %]
- [% END -%]
- [% 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 %]
- # XXX: It's a bit unfortunate but we need the pthread dll here as libevent
- # gets compiled with pthread support once it is enabled in GCC, which we need
- # to do as otherwise the Rust compilaton breaks.
- 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.1 "$distdir/Tor/"
- cp $openssldir/lib/libcrypto.so.1.1 "$distdir/Tor/"
- cp $libeventdir/lib/libevent-2.1.so.7 "$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 [% c("var/libpath") %]/libstdc++.so.6 "$distdir/Tor/libstdc++/"
- [% IF c("var/asan") -%]
- cp [% c("var/libpath") %]/libasan.so.5 "$distdir/Tor/"
- cp [% c("var/libpath") %]/libubsan.so.1 "$distdir/Tor/"
- [% END -%]
- [% IF c("var/linux-cross") %]
- cp -a /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/libssp.so* "$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/"
- [% IF c("var/linux-cross") -%]
- # Add libstdc++ to LD_LIBRARY_PATH to avoid rust link issue (bug 27101)
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/var/tmp/dist/gcc/lib64/"
- [% END -%]
- [% END %]
- [% IF c("var/osx") %]
- cp $libeventdir/lib/libevent-*.dylib $TORBINDIR/
- # The target version needs to be set before the configure step.
- export MACOSX_DEPLOYMENT_TARGET=[% c("var/macosx_deployment_target") %]
- [% 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") || c("var/android") %]--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") -%]
- 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") %]
- [% IF c("var/linux-cross") -%]
- TARGET_OBJCOPY=/var/tmp/dist/gcc-cross/bin/[% c("var/crosstarget") %]-objcopy
- TARGET_STRIP=/var/tmp/dist/gcc-cross/bin/[% c("var/crosstarget") %]-strip
- [% ELSE -%]
- TARGET_OBJCOPY=objcopy
- TARGET_STRIP=strip
- [% END -%]
- # Strip and generate debuginfo for libs
- $TARGET_OBJCOPY --only-keep-debug $distdir/bin/tor $distdir/Debug/Tor/tor
- install -s --strip-program="$TARGET_STRIP" $distdir/bin/tor $distdir/Tor/
- $TARGET_OBJCOPY --add-gnu-debuglink=./Debug/Tor/tor $distdir/Tor/tor
- for i in $distdir/Tor/*so*
- do
- LIB=`basename $i`
- $TARGET_OBJCOPY --only-keep-debug $distdir/Tor/$LIB $distdir/Debug/Tor/$LIB
- $TARGET_STRIP $distdir/Tor/$LIB
- $TARGET_OBJCOPY --add-gnu-debuglink=./Debug/Tor/$LIB $distdir/Tor/$LIB
- done
- [% END %]
- [% IF c("var/android") %]
- install -s --strip-program=[% c("var/configure_host") %]-strip $distdir/bin/tor $libsdir/libTor.so
- [% 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' ];
- ELSIF c("var/android");
- SET tarsrcdir = [ 'assets', 'jniLibs' ];
- 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 %]
|