Change TorBrowser startup script in order for it to setup needed files outside guix store. Remove tests which are not needed on guix system. --- torbrowser-68.10.0esr-9.5-1/tbb-scripts/projects/tor-browser/RelativeLink/start-tor-browser.orig 2020-07-05 18:47:40.685485004 -0300 +++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/projects/tor-browser/RelativeLink/start-tor-browser 2020-07-23 18:13:32.426282743 -0300 @@ -5,6 +5,16 @@ # # Copyright 2017 The Tor Project. See LICENSE for licensing information. +TBB_HOME="${HOME}/.local/share/torbrowser" +TBB_LOGFILE="${TBB_HOME}/torbrowser.log" +TBB_DATA="${TBB_HOME}/Data" +TBB_PROFILE="${TBB_DATA}/Browser/profile.default" +TBB_STORE_PATH=$(dirname $(realpath "$0")) +TBB_STORE_DATA="${TBB_STORE_PATH}/TorBrowser/Data" +TORRC="${TBB_DATA}/Tor/torrc-defaults" +#TORRC_BRIDGE="${TORRC}-appendix" +PT_PREFS="${TBB_DATA}/Browser/bridge-prefs-js-appendix" + complain_dialog_title="Tor Browser" # First, make sure DISPLAY is set. If it isn't, we're hosed; scream @@ -134,8 +144,8 @@ ;; -l | --log) if [ -z "$2" -o "${2:0:1}" == "-" ]; then - printf "Logging Tor Browser debug information to tor-browser.log\n" - logfile="../tor-browser.log" + printf "Logging Tor Browser debug information to torbrowser.log\n" + logfile="${TBB_LOGFILE}" elif [ "${2:0:1}" == "/" -o "${2:0:1}" == "~" ]; then printf "Logging Tor Browser debug information to %s\n" "$2" logfile="$2" @@ -187,41 +197,23 @@ export XAUTHORITY fi -# If this script is being run through a symlink, we need to know where -# in the filesystem the script itself is, not where the symlink is. -myname="$0" -if [ -L "$myname" ]; then - # XXX readlink is not POSIX, but is present in GNU coreutils - # and on FreeBSD. Unfortunately, the -f option (which follows - # a whole chain of symlinks until it reaches a non-symlink - # path name) is a GNUism, so we have to have a fallback for - # FreeBSD. Fortunately, FreeBSD has realpath instead; - # unfortunately, that's also non-POSIX and is not present in - # GNU coreutils. - # - # If this launcher were a C program, we could just use the - # realpath function, which *is* POSIX. Too bad POSIX didn't - # make that function accessible to shell scripts. - - # If realpath is available, use it; it Does The Right Thing. - possibly_my_real_name="`realpath "$myname" 2>/dev/null`" - if [ "$?" -eq 0 ]; then - myname="$possibly_my_real_name" - else - # realpath is not available; hopefully readlink -f works. - myname="`readlink -f "$myname" 2>/dev/null`" - if [ "$?" -ne 0 ]; then - # Ugh. - complain "start-tor-browser cannot be run using a symlink on this operating system." - fi - fi +# Try to be agnostic to where we're being started from, check if files are on its +# default paths and chdir to TBB_HOME +if [ -e "${TORRC}" ]; then + cd "${TBB_HOME}" +else + mkdir -p "${TBB_HOME}" + cp -R "${TBB_STORE_DATA}" "${TBB_HOME}" + chmod -R 700 "${TBB_HOME}" + mkdir -p "${TBB_PROFILE}" + echo "user_pref(\"extensions.torlauncher.torrc-defaults_path\", \"${TORRC}\");"\ + > "${TBB_PROFILE}/user.js" + grep -v 'default_bridge\.snowflake' "${PT_PREFS}" >> "${TBB_PROFILE}/user.js" + echo "ClientTransportPlugin meek_lite,obfs2,obfs3,obfs4,scramblesuit exec ${TBB_STORE_PATH}/TorBrowser/Tor/PluggableTransports/obfs4proxy"\ + >> "${TORRC}" + cd "${TBB_HOME}" fi -# Try to be agnostic to where we're being started from, chdir to where -# the script is. -mydir="`dirname "$myname"`" -test -d "$mydir" && cd "$mydir" - # If ${PWD} results in a zero length string, we can try something else... if [ ! "${PWD}" ]; then # "hacking around some braindamage" @@ -236,16 +228,9 @@ ln -nsf ~/.config/ibus/bus .config/ibus fi -# Fix up .desktop Icon and Exec Paths, and update the .desktop file from the -# canonical version if it was changed by the updater. -cp start-tor-browser.desktop ../ -sed -i -e "s,^Name=.*,Name=Tor Browser,g" ../start-tor-browser.desktop -sed -i -e "s,^Icon=.*,Icon=$PWD/browser/chrome/icons/default/default128.png,g" ../start-tor-browser.desktop -sed -i -e "s,^Exec=.*,Exec=sh -c '\"$PWD/start-tor-browser\" --detach || ([ ! -x \"$PWD/start-tor-browser\" ] \&\& \"\$(dirname \"\$*\")\"/Browser/start-tor-browser --detach)' dummy %k,g" ../start-tor-browser.desktop - if [ "$register_desktop_app" -eq 1 ]; then mkdir -p "$HOME/.local/share/applications/" - cp ../start-tor-browser.desktop "$HOME/.local/share/applications/" + cp "${TBB_STORE_PATH}/start-tor-browser.desktop" "$HOME/.local/share/applications/" update-desktop-database "$HOME/.local/share/applications/" printf "Tor Browser has been registered as a desktop app for this user in ~/.local/share/applications/\n" exit 0 @@ -265,21 +250,6 @@ HOME="${PWD}" export HOME -SYSARCHITECTURE=$(getconf LONG_BIT) -TORARCHITECTURE=$(expr "$(file TorBrowser/Tor/tor)" : '.*ELF \([[:digit:]]*\)') - -if [ $SYSARCHITECTURE -ne $TORARCHITECTURE ]; then - complain "Wrong architecture? 32-bit vs. 64-bit." - exit 1 -fi - -[% IF c("var/asan") -%] -# We need to disable LSan which is enabled by default now. Otherwise we'll get -# a crash during shutdown: https://bugs.torproject.org/10599#comment:59 -ASAN_OPTIONS="detect_leaks=0" -export ASAN_OPTIONS -[% END -%] - function setControlPortPasswd() { local ctrlPasswd=$1 @@ -342,13 +312,15 @@ # your password in the following line where the word “secret” is: setControlPortPasswd ${TOR_CONTROL_PASSWD:='"secret"'} -# Set up custom bundled fonts. See fonts-conf(5). -export FONTCONFIG_PATH="${HOME}/TorBrowser/Data/fontconfig" -export FONTCONFIG_FILE="fonts.conf" - # Avoid overwriting user's dconf values. Fixes #27903. export GSETTINGS_BACKEND=memory +# Set up custom bundled fonts. See fonts-conf(5). +export FONTCONFIG_FILE="${HOME}/Data/fontconfig/fonts.conf" + +sed -i "${FONTCONFIG_FILE}"\ + -e "s,