Commit 6f6a8fdc authored by Tails developers's avatar Tails developers
Browse files

Refactor chroot browsers' set_chroot_browser_name().

parent eb9d3d4c
...@@ -64,3 +64,29 @@ setup_browser_chroot () { ...@@ -64,3 +64,29 @@ setup_browser_chroot () {
# Workaround for #6110 # Workaround for #6110
chmod -t ${cow} chmod -t ${cow}
} }
set_chroot_browser_name () {
local chroot="${1}"
local name="${2}"
local locale="${3}"
local ext_dir=${chroot}/"${TBB_EXT}"
local pack top rest
if [ "${locale}" != en-US ]; then
pack="${ext_dir}/langpack-${locale}@firefox.mozilla.org.xpi"
top=browser/chrome
rest=${locale}/locale
else
pack="${chroot}/${TBB_INSTALL}/browser/omni.ja"
top=chrome
rest=en-US/locale
fi
local tmp=$(mktemp -d)
local branding="${top}/${rest}/branding/brand.dtd"
# Non-zero exit code due to non-standard ZIP archive.
# The following steps will fail soon if the extraction failed anyway.
7z x -o"${tmp}" "${pack}" "${branding}" || true
sed -i "s/<"'!'"ENTITY\s\+brand\(Full\|Short\)Name.*$/<"'!'"ENTITY brand\1Name \"${name}\">/" "${tmp}/${branding}"
(cd ${tmp} ; 7z u -tzip "${pack}" .)
chmod a+r "${pack}"
rm -Rf "${tmp}"
}
...@@ -71,30 +71,6 @@ show_start_notification () { ...@@ -71,30 +71,6 @@ show_start_notification () {
tails-notify-user "${title}" "${body}" 10000 tails-notify-user "${title}" "${body}" 10000
} }
set_chroot_browser_name () {
NAME="${1}"
LOCALE="${2}"
EXT_DIR=${CHROOT}/"${TBB_EXT}"
if [ "${LOCALE}" != en-US ]; then
PACK="${EXT_DIR}/langpack-${LOCALE}@firefox.mozilla.org.xpi"
TOP=browser/chrome
REST=${LOCALE}/locale
else
PACK="${CHROOT}/${TBB_INSTALL}/browser/omni.ja"
TOP=chrome
REST=en-US/locale
fi
TMP=$(mktemp -d)
BRANDING="${TOP}/${REST}/branding/brand.dtd"
# Non-zero exit code due to non-standard ZIP archive.
# The following steps will fail soon if the extraction failed anyway.
7z x -o"${TMP}" "${PACK}" "${BRANDING}" || true
sed -i "s/<"'!'"ENTITY\s\+brand\(Full\|Short\)Name.*$/<"'!'"ENTITY brand\1Name \"${NAME}\">/" "${TMP}/${BRANDING}"
(cd $TMP ; 7z u -tzip "${PACK}" .)
chmod a+r "${PACK}"
rm -Rf "${TMP}"
}
configure_chroot () { configure_chroot () {
echo "* Configuring chroot" echo "* Configuring chroot"
...@@ -142,7 +118,7 @@ configure_chroot () { ...@@ -142,7 +118,7 @@ configure_chroot () {
${BROWSER_PREFS} ${BROWSER_PREFS}
# Set the name (e.g. window title) of the browser # Set the name (e.g. window title) of the browser
set_chroot_browser_name "`gettext \"I2P Browser\"`" "${BEST_LOCALE}" set_chroot_browser_name ${CHROOT} "`gettext \"I2P Browser\"`" "${BEST_LOCALE}"
# Set start page to the router console # Set start page to the router console
echo 'user_pref("browser.startup.homepage", "'${START_PAGE}'");' >> \ echo 'user_pref("browser.startup.homepage", "'${START_PAGE}'");' >> \
......
...@@ -71,30 +71,6 @@ show_start_notification () { ...@@ -71,30 +71,6 @@ show_start_notification () {
tails-notify-user "${title}" "${body}" 10000 tails-notify-user "${title}" "${body}" 10000
} }
set_chroot_browser_name () {
NAME="${1}"
LOCALE="${2}"
EXT_DIR=${CHROOT}/"${TBB_EXT}"
if [ "${LOCALE}" != en-US ]; then
PACK="${EXT_DIR}/langpack-${LOCALE}@firefox.mozilla.org.xpi"
TOP=browser/chrome
REST=${LOCALE}/locale
else
PACK="${CHROOT}/${TBB_INSTALL}/browser/omni.ja"
TOP=chrome
REST=en-US/locale
fi
TMP=$(mktemp -d)
BRANDING="${TOP}/${REST}/branding/brand.dtd"
# Non-zero exit code due to non-standard ZIP archive.
# The following steps will fail soon if the extraction failed anyway.
7z x -o"${TMP}" "${PACK}" "${BRANDING}" || true
sed -i "s/<"'!'"ENTITY\s\+brand\(Full\|Short\)Name.*$/<"'!'"ENTITY brand\1Name \"${NAME}\">/" "${TMP}/${BRANDING}"
(cd $TMP ; 7z u -tzip "${PACK}" .)
chmod a+r "${PACK}"
rm -Rf "${TMP}"
}
configure_chroot () { configure_chroot () {
echo "* Configuring chroot" echo "* Configuring chroot"
...@@ -138,7 +114,7 @@ configure_chroot () { ...@@ -138,7 +114,7 @@ configure_chroot () {
echo 'user_pref("extensions.getAddons.showPane", false);' >> "${CLEARNET_PREFS}" echo 'user_pref("extensions.getAddons.showPane", false);' >> "${CLEARNET_PREFS}"
# Set the name (e.g. window title) of the browser # Set the name (e.g. window title) of the browser
set_chroot_browser_name "`gettext \"Unsafe Browser\"`" "${BEST_LOCALE}" set_chroot_browser_name ${CHROOT} "`gettext \"Unsafe Browser\"`" "${BEST_LOCALE}"
# Set start page to something that explains what's going on # Set start page to something that explains what's going on
echo 'user_pref("browser.startup.homepage", "'${START_PAGE}'");' >> \ echo 'user_pref("browser.startup.homepage", "'${START_PAGE}'");' >> \
......
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