Commit 3463a71b authored by Tails developers's avatar Tails developers
Browse files

Merge remote-tracking branch 'origin/feature/8031-refactor-10-rbb-hook' into testing

parents 35acec67 6dcf6bb4
......@@ -4,27 +4,6 @@ set -eu
echo "Install the Tor Browser"
# Get the below with `grep "tor-browser-linux32-.*\.tar.xz" sha256sums.txt`
BUNDLES="$(cat <<EOF
473780a5145859a8d516e76cb27be25b0baf16007ba50cd8ba78a536bc806fc5 tor-browser-linux32-tbb-nightly_ar.tar.xz
3e3d6fd1ea47067fc00625b8cd62d23079ef71dc91734bfb823542c26ce192cf tor-browser-linux32-tbb-nightly_en-US.tar.xz
df4745725e7b3fe99c218166ffbe38eef8e9d636c42b72c8a2b8229fc3bdd83b tor-browser-linux32-tbb-nightly_ru.tar.xz
b624b1f9a16e4ff4cffb3478f63249ed73ae902732b64fca0f183ad73ed1b5ac tor-browser-linux32-tbb-nightly_zh-CN.tar.xz
EOF
)"
MAIN_BUNDLE="$(echo "${BUNDLES}" | grep -o "tor-browser-linux32-.*_en-US.tar.xz")"
#VERSION="$(echo "${MAIN_BUNDLE}" | sed 's/tor-browser-linux32-\(.*\)_en-US.tar.xz/\1/')"
VERSION=tbb-nightly-2014-10-07
# Note that we cannot use https here since apt-cacher-ng (used by vagrant)
# gets confused and throws a 403. It doesn't matter, though, since we verify
# the checksums of each file downloaded.
#TBB_DIST_URL="http://archive.torproject.org/tor-package-archive/torbrowser/${VERSION}"
#TBB_DIST_URL="http://www.torproject.org/dist/torbrowser/${VERSION}/"
#TBB_DIST_URL="http://people.torproject.org/~mikeperry/builds/${VERSION}/"
#TBB_DIST_URL="http://people.torproject.org/~gk/testbuilds/${VERSION}"
TBB_DIST_URL="http://people.torproject.org/~linus/builds/${VERSION}"
# Import the TBB_INSTALL, TBB_PROFILE and TBB_EXT variables, which
# contains the paths we will split TBB's actual browser (binaries
# etc), user data and extension into. While this differs from how the
......@@ -32,129 +11,212 @@ TBB_DIST_URL="http://people.torproject.org/~linus/builds/${VERSION}"
# practical since when creating a new browser profile we can simply
# copy the profile directory without duplicating all extensions.
. /usr/local/lib/tails-shell-library/tor-browser.sh
mkdir -p "${TBB_INSTALL}" "${TBB_PROFILE}" "${TBB_EXT}"
# Use the builder's caching APT proxy, if any
APT_PROXY="$(apt-config --format '%v' dump Acquire::http::Proxy)"
if [ -n "${APT_PROXY}" ]; then
export HTTP_PROXY="${APT_PROXY}"
export http_proxy="${APT_PROXY}"
export HTTPS_PROXY="${APT_PROXY}"
export https_proxy="${APT_PROXY}"
fi
TMP="$(mktemp -d)"
echo "${BUNDLES}" | while read expected_sha256 tarball; do
(
cd "${TMP}"
echo "Fetching ${TBB_DIST_URL}/${tarball} ..."
curl --remote-name "${TBB_DIST_URL}/${tarball}"
)
actual_sha256="$(sha256sum "${TMP}/${tarball}" | cut -d' ' -f1)"
if [ "${actual_sha256}" != "${expected_sha256}" ]; then
echo "SHA256 mismatch for ${tarball}" >&2
exit 1
fi
done
# We'll use the en-US bundle as our basis...
tar -xf "${TMP}/${MAIN_BUNDLE}" -C "${TMP}" tor-browser_en-US
TBB_PREP="${TMP}"/tor-browser_en-US
# ... only extracting the localization addon from the other ones, which
# we'll put in a global extensions directory that we'll symlink to so
# we don't have to deal with wasteful copies.
for tarball in "${TMP}"/tor-browser-*.tar.xz; do
locale="$(echo "${tarball}" | sed "s@^.*/tor-browser-.*_\(.*\)\.tar\.xz@\1@")"
if [ "${locale}" = en-US ]; then
continue
download_and_verify_files() {
local base_url bundles destination apt_proxy
base_url="${1}"
bundles="${2}"
destination="${3}"
# Use the builder's caching APT proxy, if any
apt_proxy="$(apt-config --format '%v' dump Acquire::http::Proxy)"
if [ -n "${apt_proxy}" ]; then
export HTTP_PROXY="${apt_proxy}"
export http_proxy="${apt_proxy}"
export HTTPS_PROXY="${apt_proxy}"
export https_proxy="${apt_proxy}"
fi
xpi="tor-browser_${locale}/Browser/TorBrowser/Data/Browser/profile.default/extensions/langpack-${locale}@firefox.mozilla.org.xpi"
(
cd "${TMP}"
tar -xf "${tarball}" "${xpi}"
mv "${xpi}" "${TBB_EXT}"
)
done
# Enable our myspell/hunspell dictionaries. TBB only provides the one
# for en-US, but Debian's seems more comprehensive, so we'll only use
# Debian's dictionaries.
rm -f "${TBB_PREP}"/Browser/dictionaries/*
for f in /usr/share/hunspell/*.aff /usr/share/hunspell/*.dic; do
name="$(basename "${f}")"
ln -s "${f}" "${TBB_PREP}"/Browser/dictionaries/"${name}"
done
# We don't want tor-launcher to be part of the regular browser
# profile. Moreover, for the stand-alone tor-launcher we use, we need
# our patched version. So, the version shipped in the TB really is not
# useful for us.
rm "${TBB_PREP}/Browser/TorBrowser/Data/Browser/profile.default/extensions/tor-launcher@torproject.org.xpi"
# Remove TBB's torbutton since the "Tor test" will fail and about:tor
# will report an error. We'll install our own Torbutton later, which
# has the extensions.torbutton.test_enabled boolean pref as a workaround.
rm "${TBB_PREP}/Browser/TorBrowser/Data/Browser/profile.default/extensions/torbutton@torproject.org.xpi"
# See comment below why we need the Browser sub-dir
mv "${TBB_PREP}/Browser" "${TBB_INSTALL}"/Browser
# The Tor Browser will fail, complaining about an incomplete profile,
# unless there's a readable Browser/TorBrowser/Data/Browser/Caches
# in the directory where the firefox executable is located.
mkdir -p "${TBB_INSTALL}"/Browser/TorBrowser/Data/Browser/Caches
# Let's put all the bundled extensions in the global extensions directory
mv "${TBB_INSTALL}"/Browser/TorBrowser/Data/Browser/profile.default/extensions/* "${TBB_EXT}"
rmdir "${TBB_INSTALL}"/Browser/TorBrowser/Data/Browser/profile.default/extensions
echo "${bundles}" | while read expected_sha256 tarball; do
(
cd "${destination}"
echo "Fetching ${base_url}/${tarball} ..."
curl --remote-name "${base_url}/${tarball}"
)
actual_sha256="$(sha256sum "${destination}/${tarball}" | cut -d' ' -f1)"
if [ "${actual_sha256}" != "${expected_sha256}" ]; then
echo "SHA256 mismatch for ${tarball}" >&2
exit 1
fi
done
}
install_tor_browser() {
local bundle destination tmp prep
bundle="${1}"
destination="${2}"
tmp="$(mktemp -d)"
tar -xf "${bundle}" -C "${tmp}" tor-browser_en-US
prep="${tmp}"/tor-browser_en-US/Browser
# Enable our myspell/hunspell dictionaries. TBB only provides the
# one for en-US, but Debian's seems more comprehensive, so we'll
# only use Debian's dictionaries.
rm -f "${prep}"/dictionaries/*
for f in /usr/share/hunspell/*.aff /usr/share/hunspell/*.dic; do
ln -s "${f}" "${prep}"/dictionaries/
done
# We don't need the Tor binary (and shared libraries) and
# documentation shipped in the TBB.
rm -r "${prep}"/TorBrowser/Tor "${prep}"/TorBrowser/Docs
# We don't want tor-launcher to be part of the regular browser
# profile. Moreover, for the stand-alone tor-launcher we use, we
# need our patched version. So, the version shipped in the TB
# really is not useful for us.
rm "${prep}/TorBrowser/Data/Browser/profile.default/extensions/tor-launcher@torproject.org.xpi"
# Remove TBB's torbutton since the "Tor test" will fail and about:tor
# will report an error. We'll install our own Torbutton later, which
# has the extensions.torbutton.test_enabled boolean pref as a workaround.
rm "${prep}/TorBrowser/Data/Browser/profile.default/extensions/torbutton@torproject.org.xpi"
# The Tor Browser will fail, complaining about an incomplete profile,
# unless there's a readable TorBrowser/Data/Browser/Caches
# in the directory where the firefox executable is located.
mkdir -p "${prep}"/TorBrowser/Data/Browser/Caches
mv "${prep}" "${destination}"
rm -r "${tmp}"
}
install_langpacks_from_bundles() {
local bundles_dir destination
bundles_dir="${1}"
destination="${2}"
for tarball in "${bundles_dir}"/tor-browser-*.tar.xz; do
locale="$(echo "${tarball}" | sed "s@^.*/tor-browser-.*_\(.*\)\.tar\.xz@\1@")"
if [ "${locale}" = en-US ]; then
continue
fi
xpi="tor-browser_${locale}/Browser/TorBrowser/Data/Browser/profile.default/extensions/langpack-${locale}@firefox.mozilla.org.xpi"
(
cd "${bundles_dir}"
tar -xf "${tarball}" "${xpi}"
mv "${xpi}" "${destination}"
)
done
}
get_firefox_version() {
# The application.ini file
local appini
appini="${1}"
sed -n 's/^Version=\(.*\)$/\1/p' "${appini}"
}
# Create and install a fake iceweasel package so we can install our
# desired Debian-packaged Iceweasel addons
apt-get install --yes equivs
FAKE_ICEWEASEL_VERSION=$(sed -n 's/^Version=\(.*\)$/\1/p' "${TBB_INSTALL}"/Browser/application.ini)+fake1
cat > "${TMP}"/iceweasel.control << EOF
install_fake_iceweasel_pkg() {
local fake_version tmp
fake_version="${1}"
tmp="$(mktemp -d)"
apt-get install --yes equivs
cat > "${tmp}"/iceweasel.control << EOF
Section: web
Priority: optional
Homepage: https://tails.boum.org/
Standards-Version: 3.6.2
Package: iceweasel
Version: ${FAKE_ICEWEASEL_VERSION}
Version: ${fake_version}
Maintainer: Tails developers <amnesia@boum.org>
Architecture: all
Description: (Fake) Iceweasel
Make it possible to install Debian's Iceweasel addons without having to
install a real Iceweasel.
EOF
(
cd "${TMP}"
equivs-build "${TMP}"/iceweasel.control
dpkg -i "${TMP}"/iceweasel_"${FAKE_ICEWEASEL_VERSION}"_all.deb
)
(
cd "${tmp}"
equivs-build "${tmp}"/iceweasel.control
dpkg -i "${tmp}"/iceweasel_"${fake_version}"_all.deb
)
rm -R "${tmp}"
}
install_debian_extensions() {
local destination
destination="${1}"
apt-get install --yes xul-ext-adblock-plus xul-ext-torbutton
ln -s /usr/share/xul-ext/adblock-plus/ \
"${destination}"/'{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}'
ln -s /usr/share/xul-ext/torbutton/ \
"${destination}"/torbutton@torproject.org
}
create_default_profile() {
local tbb_profile extensions_dir destination
tbb_profile="${1}"
tbb_extensions_dir="${2}"
destination="${3}"
rsync -a --exclude bookmarks.html --exclude extensions \
"${tbb_profile}"/ "${destination}"/
# Remove TBB's default bridges
sed -i '/extensions\.torlauncher\.default_bridge\./d' "${destination}"/preferences/extension-overrides.js
mkdir -p "${destination}"/extensions
for ext in "${tbb_extensions_dir}"/*; do
ln -s "${ext}" "${destination}"/extensions/
done
}
apt-get install --yes xul-ext-adblock-plus xul-ext-torbutton
# Get the below with `grep "tor-browser-linux32-.*\.tar.xz" sha256sums.txt`
BUNDLES="$(cat <<EOF
473780a5145859a8d516e76cb27be25b0baf16007ba50cd8ba78a536bc806fc5 tor-browser-linux32-tbb-nightly_ar.tar.xz
3e3d6fd1ea47067fc00625b8cd62d23079ef71dc91734bfb823542c26ce192cf tor-browser-linux32-tbb-nightly_en-US.tar.xz
df4745725e7b3fe99c218166ffbe38eef8e9d636c42b72c8a2b8229fc3bdd83b tor-browser-linux32-tbb-nightly_ru.tar.xz
b624b1f9a16e4ff4cffb3478f63249ed73ae902732b64fca0f183ad73ed1b5ac tor-browser-linux32-tbb-nightly_zh-CN.tar.xz
EOF
)"
ln -s /usr/share/xul-ext/adblock-plus/ "${TBB_EXT}"/'{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}'
ln -s /usr/share/xul-ext/torbutton/ "${TBB_EXT}"/torbutton@torproject.org
# We'll use the en-US bundle as our basis; only langpacks will be
# installed from the other bundles.
MAIN_BUNDLE="$(echo "${BUNDLES}" | grep -o "tor-browser-linux32-.*_en-US.tar.xz")"
#VERSION="$(echo "${MAIN_BUNDLE}" | sed 's/tor-browser-linux32-\(.*\)_en-US.tar.xz/\1/')"
VERSION=tbb-nightly-2014-10-07
# Note that we cannot use https here since apt-cacher-ng (used by vagrant)
# gets confused and throws a 403. It doesn't matter, though, since we verify
# the checksums of each file downloaded.
#TBB_DIST_URL="http://archive.torproject.org/tor-package-archive/torbrowser/${VERSION}"
#TBB_DIST_URL="http://www.torproject.org/dist/torbrowser/${VERSION}/"
#TBB_DIST_URL="http://people.torproject.org/~mikeperry/builds/${VERSION}/"
#TBB_DIST_URL="http://people.torproject.org/~gk/testbuilds/${VERSION}"
TBB_DIST_URL="http://people.torproject.org/~linus/builds/${VERSION}"
TMP="$(mktemp -d)"
download_and_verify_files "${TBB_DIST_URL}" "${BUNDLES}" "${TMP}"
install_tor_browser "${TMP}/${MAIN_BUNDLE}" "${TBB_INSTALL}"
rsync -a --exclude bookmarks.html --exclude extensions \
"${TBB_INSTALL}"/Browser/TorBrowser/Data/Browser/profile.default/ \
"${TBB_PROFILE}"/
mkdir -p "${TBB_EXT}"
install_langpacks_from_bundles "${TMP}" "${TBB_EXT}"
rm -r "${TMP}"
# Remove TBB's default bridges
sed -i '/extensions\.torlauncher\.default_bridge\./d' "${TBB_PROFILE}"/preferences/extension-overrides.js
# Let's put all the extensions from TBB in the global extensions
# directory...
mv "${TBB_INSTALL}"/TorBrowser/Data/Browser/profile.default/extensions/* "${TBB_EXT}"
rmdir "${TBB_INSTALL}"/TorBrowser/Data/Browser/profile.default/extensions
mkdir -p "${TBB_PROFILE}"/extensions
for ext in "${TBB_EXT}"/*; do
ln -s "${ext}" "${TBB_PROFILE}"/extensions/
done
# ... and then install a few Iceweasel extension by using a fake
# Iceweasel equivs package to satisfy the dependencies.
FIREFOX_VERSION=$(get_firefox_version "${TBB_INSTALL}"/application.ini)
FAKE_ICEWEASEL_VERSION=${FIREFOX_VERSION}+fake1
install_fake_iceweasel_pkg "${FAKE_ICEWEASEL_VERSION}"
install_debian_extensions "${TBB_EXT}"
mkdir -p "${TBB_PROFILE}"
create_default_profile "${TBB_INSTALL}"/TorBrowser/Data/Browser/profile.default "${TBB_EXT}" "${TBB_PROFILE}"
chown -R root:root "${TBB_INSTALL}" "${TBB_PROFILE}" "${TBB_EXT}"
chmod -R a+rX "${TBB_INSTALL}" "${TBB_PROFILE}" "${TBB_EXT}"
rm -r "${TMP}"
# Make the Tor Browser into the system's default web browser
update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/local/bin/tor-browser 99
update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser /usr/local/bin/tor-browser 99
......@@ -9,7 +9,7 @@ echo "Removing unwanted browser search plugins"
# Import the TBB_INSTALL variable
. /usr/local/lib/tails-shell-library/tor-browser.sh
PLUGIN_DIR="${TBB_INSTALL}"/Browser/browser/searchplugins
PLUGIN_DIR="${TBB_INSTALL}"/browser/searchplugins
rm "${PLUGIN_DIR}"/amazon*.xml
rm "${PLUGIN_DIR}"/bing*.xml
rm "${PLUGIN_DIR}"/eBay*.xml
......
......@@ -4,7 +4,10 @@ set -e
echo "Overriding TBB branding with our own"
# Import the TBB_PROFILE variable.
. /usr/local/lib/tails-shell-library/tor-browser.sh
install --owner root --group root --mode 0755 --directory /etc/xul-ext
install --owner root --group root --mode 0644 \
/etc/tor-browser/profile/extensions/branding@amnesia.boum.org/defaults/preferences/prefs.js \
"${TBB_PROFILE}"/extensions/branding@amnesia.boum.org/defaults/preferences/prefs.js \
/etc/xul-ext/torbutton.js
......@@ -27,9 +27,9 @@ for LANGUAGE in $(find /usr/share/amnesia/browser/searchplugins/locale -maxdepth
continue
fi
for LOCALE in $LOCALES; do
mkdir -p "${TBB_INSTALL}"/Browser/distribution/searchplugins/locale/$LOCALE
mkdir -p "${TBB_INSTALL}"/distribution/searchplugins/locale/$LOCALE
for SEARCHPLUGIN in $(find "/usr/share/amnesia/browser/searchplugins/locale/$LANGUAGE" -maxdepth 1 -type f); do
ln -s "$SEARCHPLUGIN" "${TBB_INSTALL}"/Browser/distribution/searchplugins/locale/$LOCALE
ln -s "$SEARCHPLUGIN" "${TBB_INSTALL}"/distribution/searchplugins/locale/$LOCALE
done
done
done
......@@ -5,7 +5,7 @@ set -eu
# Import the TBB_INSTALL variable
. /usr/local/lib/tails-shell-library/tor-browser.sh
ua="$(unzip -q -p "${TBB_INSTALL}"/Browser/browser/omni.ja \
ua="$(unzip -q -p "${TBB_INSTALL}"/browser/omni.ja \
defaults/preferences/000-tor-browser.js | \
sed -n 's@^pref("general\.useragent\.override", "\(.*\)");$@\1@p')"
......
......@@ -2,10 +2,10 @@
TBB_INSTALL=/usr/local/lib/tor-browser
TBB_PROFILE=/etc/tor-browser/profile
TBB_EXT="${TBB_INSTALL}/extensions"
TBB_EXT=/usr/local/share/tor-browser-extensions
exec_firefox() {
LD_LIBRARY_PATH="${TBB_INSTALL}"/Browser
LD_LIBRARY_PATH="${TBB_INSTALL}"
export LD_LIBRARY_PATH
exec "${TBB_INSTALL}"/Browser/firefox "${@}"
exec "${TBB_INSTALL}"/firefox "${@}"
}
......@@ -25,8 +25,8 @@ START_PAGE="http://127.0.0.1:7657"
# Import the TBB_INSTALL, TBB_EXT and TBB_PROFILE variables
. /usr/local/lib/tails-shell-library/tor-browser.sh
NOSCRIPT="${TBB_INSTALL}/extensions/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
TORBUTTON="${TBB_INSTALL}/extensions/torbutton@torproject.org"
NOSCRIPT="${TBB_EXT}/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
TORBUTTON="${TBB_EXT}/torbutton@torproject.org"
NAME="`gettext \"I2P Browser\"`"
if [ -e /var/lib/gdm3/tails.camouflage ]; then
......@@ -122,7 +122,7 @@ set_chroot_browser_name () {
TOP=browser/chrome
REST=${SHORT}/locale
else
PACK="${CHROOT}/${TBB_INSTALL}/Browser/browser/omni.ja"
PACK="${CHROOT}/${TBB_INSTALL}/browser/omni.ja"
TOP=chrome
REST=en-US/locale
fi
......
......@@ -20,8 +20,8 @@ for icon in /usr/share/icons/hicolor/*/apps/pidgin.png; do
done
# Set Tor Browser application icon
for icon in "${TBB_INSTALL}"/Browser/browser/chrome/icons/default/*.png \
"${TBB_INSTALL}"/Browser/browser/icons/*.png; do
for icon in "${TBB_INSTALL}"/browser/chrome/icons/default/*.png \
"${TBB_INSTALL}"/browser/icons/*.png; do
rm "$icon"
ln -s "/usr/share/icons/Windows8/apps/iceweasel.png" "$icon"
done
......
......@@ -122,7 +122,7 @@ set_chroot_browser_name () {
TOP=browser/chrome
REST=${SHORT}/locale
else
PACK="${CHROOT}/${TBB_INSTALL}/Browser/browser/omni.ja"
PACK="${CHROOT}/${TBB_INSTALL}/browser/omni.ja"
TOP=chrome
REST=en-US/locale
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment