build 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  4. distdir=/var/tmp/dist/[% project %]
  5. mkdir -p /var/tmp/build
  6. [% IF c("var/linux") || c("var/windows") %]
  7. TORCONFIGDIR="$distdir/Data/Tor"
  8. mkdir -p $TORCONFIGDIR
  9. mkdir -p "$distdir/Tor"
  10. [% END %]
  11. [% IF c("var/osx") %]
  12. [% IF c("var/nightly") %]
  13. # We are compiling Tor with Rust enabled for nightlies.
  14. export TOR_RUST_TARGET=x86_64-apple-darwin
  15. [% END %]
  16. TORBINDIR="$distdir/Contents/MacOS/Tor"
  17. TORCONFIGDIR="$distdir/Contents/Resources/TorBrowser/Tor"
  18. mkdir -p $distdir/bin
  19. mkdir -p $TORBINDIR
  20. mkdir -p $TORCONFIGDIR
  21. [% END %]
  22. tar -C /var/tmp/dist -xf [% c('input_files_by_name/openssl') %]
  23. tar -C /var/tmp/dist -xf [% c('input_files_by_name/libevent') %]
  24. [% IF !c("var/android") && c("var/nightly") %]
  25. tar -C /var/tmp/dist -xf [% c('input_files_by_name/rust') %]
  26. export PATH=/var/tmp/dist/rust/bin:$PATH
  27. [% END %]
  28. tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
  29. libeventdir=/var/tmp/dist/libevent
  30. openssldir=/var/tmp/dist/openssl/openssl
  31. [% IF c("var/windows") %]
  32. [% IF c("var/nightly") %]
  33. # We are compiling Tor with Rust enabled for nightlies.
  34. export TOR_RUST_TARGET=[% c("arch") %]-pc-windows-gnu
  35. [% END %]
  36. tar -C /var/tmp/build -xf [% c('input_files_by_name/zlib') %]
  37. zlibdir=/var/tmp/build/zlib
  38. # XXX: It's a bit unfortunate but we need the pthread dll here as libevent
  39. # gets compiled with pthread support once it is enabled in GCC, which we need
  40. # to do as otherwise the Rust compilaton breaks.
  41. mingwlibs=/var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/bin/
  42. cp $zlibdir/lib/*.dll $openssldir/bin/*.dll $libeventdir/bin/*.dll \
  43. $gcclibs/*.dll $mingwlibs/libwinpthread-1.dll $distdir/Tor/
  44. [% END %]
  45. [% IF c("var/linux-i686") && c("var/nightly") -%]
  46. export TOR_RUST_TARGET=i686-unknown-linux-gnu
  47. [% END -%]
  48. [% IF c("var/linux") %]
  49. mkdir -p "$distdir/Debug/Tor"
  50. cp $openssldir/lib/libssl.so.1.1 "$distdir/Tor/"
  51. cp $openssldir/lib/libcrypto.so.1.1 "$distdir/Tor/"
  52. cp $libeventdir/lib/libevent-2.1.so.6 "$distdir/Tor/"
  53. # We need to copy the libstdc++.so.6 for Tor Browser on older Linux distros.
  54. # Copying it into /Browser, which feels more natural, and amending
  55. # LD_LIBRARY_PATH breaks updates from a Tor Browser with the old
  56. # LD_LIBRARY_PATH value to the Tor Browser with the newer one. Thus, we copy
  57. # the libstdc++ into the directory with the libs tor depends on, too. See bug
  58. # 13359 for further details.
  59. mkdir -p "$distdir/Tor/libstdc++"
  60. cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libstdc++.so.6 "$distdir/Tor/libstdc++/"
  61. [% IF c("var/asan") -%]
  62. cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libasan.so.5 "$distdir/Tor/"
  63. cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libubsan.so.1 "$distdir/Tor/"
  64. [% END -%]
  65. chmod 700 "$distdir"/Tor/*.so*
  66. chmod 700 "$distdir"/Tor/libstdc++/*.so*
  67. # This is needed to make RPATH unavailable. See bug 9150.
  68. export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$distdir/Tor/"
  69. [% END %]
  70. [% IF c("var/osx") %]
  71. cp $libeventdir/lib/libevent-*.dylib $TORBINDIR/
  72. # The target version needs to be set before the configure step.
  73. export MACOSX_DEPLOYMENT_TARGET=[% c("var/macosx_deployment_target") %]
  74. [% END %]
  75. cd /var/tmp/build/[% project %]-[% c('version') %]
  76. # add git hash to micro-revision.i for #24995
  77. echo '"[% c("abbrev", { abbrev_length => 16 }) %]"' > micro-revision.i
  78. ./autogen.sh
  79. find -type f -print0 | xargs -0 [% c("var/touch") %]
  80. [% 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" \
  81. [% IF c("var/asan") %]--enable-fragile-hardening[% END %] \
  82. [% IF c("var/windows") %]--with-zlib-dir="$zlibdir"[% END %] \
  83. [% IF c("var/osx") %]--enable-static-openssl[% END %] \
  84. [% IF !c("var/android") && c("var/nightly") %]--enable-rust[% END %] \
  85. --prefix="$distdir" [% c("var/configure_opt") %]
  86. [% IF c("var/osx") -%]
  87. export LD_PRELOAD=[% c("var/faketime_path") %]
  88. export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]"
  89. [% END -%]
  90. make -j[% c("buildconf/num_procs") %]
  91. make install
  92. [% IF c("var/osx") -%]
  93. unset LD_PRELOAD
  94. [% END -%]
  95. cp $distdir/share/tor/geoip $TORCONFIGDIR
  96. cp $distdir/share/tor/geoip6 $TORCONFIGDIR
  97. [% IF c("var/osx") %]
  98. LIBEVENT_FILE=`basename $libeventdir/lib/libevent-*.dylib`
  99. cd $distdir
  100. cp bin/tor $TORBINDIR/
  101. cd $TORBINDIR/
  102. x86_64-apple-darwin11-install_name_tool -change $libeventdir/lib/$LIBEVENT_FILE @executable_path/$LIBEVENT_FILE tor
  103. [% END %]
  104. cd $distdir
  105. [% IF c("var/windows") %]
  106. install -s $distdir/bin/tor.exe $distdir/Tor/
  107. [% IF c("var/expert_bundle") %]
  108. install -s $distdir/bin/tor-gencert.exe $distdir/Tor/
  109. [% END %]
  110. [% END %]
  111. [% IF c("var/linux") %]
  112. # Strip and generate debuginfo for libs
  113. objcopy --only-keep-debug $distdir/bin/tor $distdir/Debug/Tor/tor
  114. install -s $distdir/bin/tor $distdir/Tor/
  115. objcopy --add-gnu-debuglink=./Debug/Tor/tor $distdir/Tor/tor
  116. for i in $distdir/Tor/*so*
  117. do
  118. LIB=`basename $i`
  119. objcopy --only-keep-debug $distdir/Tor/$LIB $distdir/Debug/Tor/$LIB
  120. strip $distdir/Tor/$LIB
  121. objcopy --add-gnu-debuglink=./Debug/Tor/$LIB $distdir/Tor/$LIB
  122. done
  123. [% END %]
  124. mkdir -p [% dest_dir _ '/' _ c('filename') %]
  125. [%
  126. IF c("var/expert_bundle");
  127. SET win_arch = c('var/windows-x86_64') ? 'win64' : 'win32';
  128. c('zip', {
  129. zip_src => [ 'Data', 'Tor', ],
  130. zip_args => dest_dir _ '/' _ c('filename') _ '/tor-' _ win_arch _ '-' _ c("version") _ '.zip',
  131. });
  132. ELSE;
  133. IF c("var/osx");
  134. SET tarsrcdir = [ 'Contents' ];
  135. ELSE;
  136. SET tarsrcdir = [ 'Data', 'Tor', ];
  137. END;
  138. c('tar', {
  139. tar_src => tarsrcdir,
  140. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename') _ '/tor.tar.gz',
  141. });
  142. END;
  143. %]
  144. [% IF c("var/linux") %]
  145. [% c('tar', {
  146. tar_src => [ 'Debug' ],
  147. tar_args => '-cJf ' _ dest_dir _ '/' _ c('filename') _ '/tor-debug.tar.xz',
  148. }) %]
  149. [% END %]