repackage_browser.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # This script allows you to repackage a Tor Browser bundle using an
  3. # obj-x86_64-pc-linux-gnu directory from a local tor-browser.git build.
  4. #
  5. # This script will download the current Tor Browser version (using
  6. # var/torbrowser_version from rbm config, or an optional second argument)
  7. # and repackage it with the specified obj directory.
  8. #
  9. # The new repackaged bundle can be found in the _repackaged directory.
  10. set -e
  11. display_usage() {
  12. echo -e "\\nUsage: $0 firefox_obj_path [torbrowser-version]\\n"
  13. }
  14. if [ $# -lt 1 ] || [ $# -gt 2 ]
  15. then
  16. display_usage
  17. exit 1
  18. fi
  19. DIRNAME="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
  20. OBJ_PATH=$1
  21. if [ $# -eq 2 ]
  22. then
  23. TOR_VERSION="$2"
  24. else
  25. TOR_VERSION=$("$DIRNAME"/../rbm/rbm showconf tor-browser var/torbrowser_version)
  26. fi
  27. TOR_FILENAME=tor-browser-linux64-${TOR_VERSION}_en-US.tar.xz
  28. TOR_BROWSER_URL=https://dist.torproject.org/torbrowser/"${TOR_VERSION}"/"${TOR_FILENAME}"
  29. TMPDIR="$(mktemp -d)"
  30. (
  31. cd "$TMPDIR"
  32. wget "$TOR_BROWSER_URL"
  33. wget "$TOR_BROWSER_URL".asc
  34. gpg --no-default-keyring --keyring "$DIRNAME"/../keyring/torbrowser.gpg --verify "${TOR_FILENAME}".asc "${TOR_FILENAME}"
  35. # From projects/firefox/build: replace firefox binary by the wrapper and strip libraries/binaries
  36. tar xf "${TOR_FILENAME}"
  37. cp -r "${OBJ_PATH}"/dist/firefox .
  38. rm firefox/firefox-bin
  39. mv firefox/firefox firefox/firefox.real
  40. for LIB in firefox/*.so firefox/gtk2/*.so firefox/firefox.real firefox/plugin-container firefox/updater
  41. do
  42. strip "$LIB"
  43. done
  44. # Repackage https-everywhere extension
  45. mkdir _omni/
  46. unzip tor-browser_en-US/Browser/omni.ja -d _omni/
  47. cd _omni/
  48. zip -Xmr ../firefox/omni.ja chrome/torbutton/content/extensions/https-everywhere/
  49. cd ..
  50. rm -rf _omni/
  51. # Overwrite extracted tor-browser with locally built files and move to _repackaged folder
  52. cp -r firefox/* tor-browser_en-US/Browser
  53. rm -rf firefox "${TOR_FILENAME}"
  54. REPACKAGED_DIR="$DIRNAME"/_repackaged/
  55. mkdir -p "$REPACKAGED_DIR"
  56. mv tor-browser_en-US "$REPACKAGED_DIR"/tor-browser-"$(date '+%Y%m%d%H%M%S')"
  57. rm -rf "$TMPDIR"
  58. )