123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- #!/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 $distdir
- mkdir -p /var/tmp/build
- [% IF c("var/android") %]
- # We need to make sure our ZSTD dependencey is properly picked up.
- # --enable-zstd is not enough.
- export ZSTD_CFLAGS=-I/var/tmp/dist/zstd/include
- export ZSTD_LIBS=/var/tmp/dist/zstd/lib/libzstd.a
- [% END %]
- TORDATADIR="$distdir/data"
- TORBINDIR="$distdir/tor"
- mkdir $TORDATADIR
- mkdir $TORBINDIR
- [% 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 %]
- 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") %]
- TORDEBUGDIR="$distdir/debug"
- mkdir "$TORDEBUGDIR"
- cp $openssldir/lib/libssl.so.1.1 "$TORBINDIR"
- cp $openssldir/lib/libcrypto.so.1.1 "$TORBINDIR"
- cp $libeventdir/lib/libevent-2.1.so.7 "$TORBINDIR"
- # 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 "$TORBINDIR"
- [% IF c("var/asan") -%]
- cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libasan.so.6 "$TORBINDIR"
- cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libubsan.so.1 "$TORBINDIR"
- [% END -%]
- chmod 700 "$TORBINDIR"/*.so*
- # This is needed to make RPATH unavailable. See bug 9150.
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$TORBINDIR"
- [% END %]
- [% IF c("var/macos") %]
- cp $libeventdir/lib/libevent-*.dylib "$TORBINDIR"
- [% END %]
- [% IF c("var/windows") %]
- export CC=[% c("arch") %]-w64-mingw32-cc
- [% 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("touch") %]
- ./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/macos") %]--enable-static-openssl[% END %] \
- [% IF c("var/windows") %]--enable-static-libevent --enable-static-openssl --enable-static-zlib[% END %] \
- --prefix="$distdir" [% c("var/configure_opt") %]
- [% IF c("var/macos") -%]
- 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("num_procs") %]
- make install
- [% IF c("var/macos") -%]
- unset LD_PRELOAD
- [% END -%]
- cp $distdir/share/tor/geoip "$TORDATADIR"
- cp $distdir/share/tor/geoip6 "$TORDATADIR"
- [% IF c("var/macos") %]
- LIBEVENT_FILE=`basename $libeventdir/lib/libevent-*.dylib`
- cd $distdir
- cp bin/tor "$TORBINDIR"
- cd "$TORBINDIR"
- [% c("var/build_target") %]-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 "$TORBINDIR"
- install -s $distdir/bin/tor-gencert.exe "$TORBINDIR"
- [% END %]
- [% IF c("var/linux") %]
- # Strip and generate debuginfo for libs
- objcopy --only-keep-debug $distdir/bin/tor "$TORDEBUGDIR/tor"
- install -s $distdir/bin/tor "$TORBINDIR"
- objcopy --add-gnu-debuglink="$TORDEBUGDIR/tor" "$TORBINDIR/tor"
- for i in "$TORBINDIR"/*so*
- do
- LIB=`basename $i`
- if [ $LIB == 'libstdc++.so.6' ]; then
- # keeping this separate to maintain reproducibility; we can probably
- # treat this the same as the rest (though it seems libstdc++ doesn't come with
- # any useful debug symbols since we don't build it, so maybe we should figure
- # out how to package them
- strip "$TORBINDIR/$LIB"
- else
- objcopy --only-keep-debug "$TORBINDIR/$LIB" "$TORDEBUGDIR/$LIB"
- strip "$TORBINDIR/$LIB"
- objcopy --add-gnu-debuglink="$TORDEBUGDIR/$LIB" "$TORBINDIR/$LIB"
- fi
- done
- [% END %]
- [% IF c("var/android") %]
- install -s --strip-program=[% c("var/cross_prefix") %]-strip "$distdir/bin/tor" "$TORBINDIR/libTor.so"
- [% END %]
- [%
- SET tar_src = [ "tor", "data" ];
- IF c("var/linux");
- tar_src.push("debug");
- END;
- c('tar', {
- tar_src => tar_src,
- tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
- });
- %]
|