5 echo "Install the Tor Browser"
7 # Import the TBB_INSTALL, TBB_PROFILE and TBB_EXT variables, which
8 # contains the paths we will split TBB's actual browser (binaries
9 # etc), user data and extension into. While this differs from how the
10 # TBB organizes the files, the end result will be the same, and it's
11 # practical since when creating a new browser profile we can simply
12 # copy the profile directory without duplicating all extensions.
13 .
/usr
/local
/lib
/tails-shell-library
/tor-browser.sh
15 download_and_verify_files
() {
16 local base_url bundles destination apt_proxy
21 # Use the builder's caching APT proxy, if any
22 apt_proxy
="$(apt-config --format '%v' dump Acquire::http::Proxy)"
23 if [ -n "${apt_proxy}" ]; then
24 export HTTP_PROXY
="${apt_proxy}"
25 export http_proxy
="${apt_proxy}"
26 export HTTPS_PROXY
="${apt_proxy}"
27 export https_proxy
="${apt_proxy}"
30 echo "${bundles}" |
while read expected_sha256 tarball
; do
33 echo "Fetching ${base_url}/${tarball} ..."
34 curl
--remote-name "${base_url}/${tarball}"
36 actual_sha256
="$(sha256sum "${destination}/${tarball}" | cut -d' ' -f1)"
37 if [ "${actual_sha256}" != "${expected_sha256}" ]; then
38 echo "SHA256 mismatch for ${tarball}" >&2
44 install_tor_browser
() {
45 local bundle destination tmp prep
50 tar -xf "${bundle}" -C "${tmp}" tor-browser_en-US
51 prep
="${tmp}"/tor-browser_en-US
/Browser
53 # Enable our myspell/hunspell dictionaries. TBB only provides the
54 # one for en-US, but Debian's seems more comprehensive, so we'll
55 # only use Debian's dictionaries.
56 rm -f "${prep}"/dictionaries
/*
57 for f
in /usr
/share
/hunspell
/*.aff
/usr
/share
/hunspell
/*.dic
; do
58 ln -s "${f}" "${prep}"/dictionaries
/
61 # The libstdc++6 package in Wheezy is too old, so we need the
63 cp "${prep}"/TorBrowser
/Tor
/libstdc
++.so
.6 "${prep}"
65 # We don't need the Tor binary, the shared libraries Tor needs
66 # (but Firefox doesn't) and documentation shipped in the TBB.
67 rm -r "${prep}"/TorBrowser
/Tor
"${prep}"/TorBrowser
/Docs
69 # We don't want tor-launcher to be part of the regular browser
70 # profile. Moreover, for the stand-alone tor-launcher we use, we
71 # need our patched version. So, the version shipped in the TB
72 # really is not useful for us.
73 rm "${prep}/TorBrowser/Data/Browser/profile.default/extensions/tor-launcher@torproject.org.xpi"
75 # Remove TBB's torbutton since the "Tor test" will fail and about:tor
76 # will report an error. We'll install our own Torbutton later, which
77 # has the extensions.torbutton.test_enabled boolean pref as a workaround.
78 rm "${prep}/TorBrowser/Data/Browser/profile.default/extensions/torbutton@torproject.org.xpi"
80 # The Tor Browser will fail, complaining about an incomplete profile,
81 # unless there's a readable TorBrowser/Data/Browser/Caches
82 # in the directory where the firefox executable is located.
83 mkdir
-p "${prep}"/TorBrowser
/Data
/Browser
/Caches
85 mv "${prep}" "${destination}"
90 install_langpacks_from_bundles
() {
91 local bundles_dir destination
95 for tarball
in "${bundles_dir}"/tor-browser-
*.
tar.xz
; do
96 locale
="$(echo "${tarball}" | sed "s@^.
*/tor-browser-.
*_\
(.
*\
)\.
tar\.xz@\
1@
")"
97 if [ "${locale}" = en-US
]; then
100 xpi
="tor-browser_${locale}/Browser/TorBrowser/Data/Browser/profile.default/extensions/langpack-${locale}@firefox.mozilla.org.xpi"
103 tar -xf "${tarball}" "${xpi}"
104 mv "${xpi}" "${destination}"
109 get_firefox_version
() {
110 # The application.ini file
113 sed -n 's/^Version=\(.*\)$/\1/p' "${appini}"
116 # Create and install a fake iceweasel package so we can install our
117 # desired Debian-packaged Iceweasel addons
118 install_fake_iceweasel_pkg
() {
119 local fake_version tmp
122 apt-get
install --yes equivs
123 cat > "${tmp}"/iceweasel.control
<< EOF
126 Homepage: https://tails.boum.org/
127 Standards-Version: 3.6.2
130 Version: ${fake_version}
131 Maintainer: Tails developers <amnesia@boum.org>
133 Description: (Fake) Iceweasel
134 Make it possible to install Debian's Iceweasel addons without having to
135 install a real Iceweasel.
139 equivs-build
"${tmp}"/iceweasel.control
140 dpkg
-i "${tmp}"/iceweasel_
"${fake_version}"_all.deb
145 install_debian_extensions
() {
149 apt-get
install --yes "${@}"
150 ln -s /usr
/share
/xul-ext
/adblock-plus
/ \
151 "${destination}"/'{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}'
152 ln -s /usr
/share
/xul-ext
/torbutton
/ \
153 "${destination}"/torbutton@torproject.org
156 create_default_profile
() {
157 local tbb_profile extensions_dir destination
159 tbb_extensions_dir
="${2}"
162 rsync
-a --exclude bookmarks.html
--exclude extensions \
163 "${tbb_profile}"/ "${destination}"/
165 # Remove TBB's default bridges
166 sed -i '/extensions\.torlauncher\.default_bridge\./d' "${destination}"/preferences
/extension-overrides.js
168 mkdir
-p "${destination}"/extensions
169 for ext
in "${tbb_extensions_dir}"/*; do
170 ln -s "${ext}" "${destination}"/extensions
/
174 TBB_SHA256SUMS_FILE
=/usr
/share
/tails
/tbb-sha256sums.txt
175 TBB_TARBALLS
="$(grep "\
<tor-browser-linux32-.
*\.
tar.xz$
" "${TBB_SHA256SUMS_FILE}")"
177 # We'll use the en-US bundle as our basis; only langpacks will be
178 # installed from the other bundles.
179 MAIN_TARBALL
="$(echo "${TBB_TARBALLS}" | grep -o "tor-browser-linux32-.
*_en-US.
tar.xz
")"
180 VERSION
="$(echo "${MAIN_TARBALL}" | sed 's/tor-browser-linux32-\(.*\)_en-US.tar.xz/\1/')"
181 TBB_DIST_URL_FILE
=/usr
/share
/tails
/tbb-dist-url.txt
182 TBB_TARBALLS_BASE_URL
="$(cat "${TBB_DIST_URL_FILE}")/${VERSION}"
184 # The Debian Iceweasel extensions we want to install and make
185 # available in the Tor Browser.
186 DEBIAN_EXT_PKGS
="xul-ext-adblock-plus xul-ext-torbutton"
189 download_and_verify_files
"${TBB_TARBALLS_BASE_URL}" "${TBB_TARBALLS}" "${TMP}"
191 install_tor_browser
"${TMP}/${MAIN_TARBALL}" "${TBB_INSTALL}"
193 mkdir
-p "${TBB_EXT}"
194 install_langpacks_from_bundles
"${TMP}" "${TBB_EXT}"
198 # Let's put all the extensions from TBB in the global extensions
200 mv "${TBB_INSTALL}"/TorBrowser
/Data
/Browser
/profile.default
/extensions
/* "${TBB_EXT}"
201 rmdir "${TBB_INSTALL}"/TorBrowser
/Data
/Browser
/profile.default
/extensions
203 # ... and then install a few Iceweasel extension by using a fake
204 # Iceweasel equivs package to satisfy the dependencies.
205 FIREFOX_VERSION
=$
(get_firefox_version
"${TBB_INSTALL}"/application.ini
)
206 FAKE_ICEWEASEL_VERSION
=${FIREFOX_VERSION}+fake1
207 install_fake_iceweasel_pkg
"${FAKE_ICEWEASEL_VERSION}"
208 install_debian_extensions
"${TBB_EXT}" ${DEBIAN_EXT_PKGS}
210 mkdir
-p "${TBB_PROFILE}"
211 create_default_profile
"${TBB_INSTALL}"/TorBrowser/Data/Browser/profile.default "${TBB_EXT}" "${TBB_PROFILE}"
213 chown
-R root
:root
"${TBB_INSTALL}" "${TBB_PROFILE}" "${TBB_EXT}"
214 chmod -R a
+rX
"${TBB_INSTALL}" "${TBB_PROFILE}" "${TBB_EXT}"
216 # Make the Tor Browser into the system's default web browser
217 update-alternatives
--install /usr
/bin
/x-www-browser x-www-browser
/usr
/local
/bin
/tor-browser
99
218 update-alternatives
--install /usr
/bin
/gnome-www-browser gnome-www-browser
/usr
/local
/bin
/tor-browser
99
219 sed -i 's/\<iceweasel\.desktop\>/tor-browser.desktop/' /etc
/gnome
/defaults.list