repackage_browser.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. # Overwrite extracted tor-browser with locally built files and move to _repackaged folder
  45. cp -r firefox/* tor-browser_en-US/Browser
  46. rm -rf firefox "${TOR_FILENAME}"
  47. REPACKAGED_DIR="$DIRNAME"/_repackaged/
  48. mkdir -p "$REPACKAGED_DIR"
  49. mv tor-browser_en-US "$REPACKAGED_DIR"/tor-browser-"$(date '+%Y%m%d%H%M%S')"
  50. rm -rf "$TMPDIR"
  51. )