build 5.7 KB

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