From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MFHVHHEpbV9pCgAA0tVLHw (envelope-from ) for ; Thu, 24 Sep 2020 23:19:13 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id wIO3GHEpbV8/RAAAB5/wlQ (envelope-from ) for ; Thu, 24 Sep 2020 23:19:13 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1E65E940416 for ; Thu, 24 Sep 2020 23:19:12 +0000 (UTC) Received: from localhost ([::1]:41144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLaW7-0002sz-0c for larch@yhetil.org; Thu, 24 Sep 2020 19:19:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLaVy-0002rS-Gm for guix-patches@gnu.org; Thu, 24 Sep 2020 19:19:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLaVy-0000Kz-7a for guix-patches@gnu.org; Thu, 24 Sep 2020 19:19:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kLaVy-0000Qc-2z for guix-patches@gnu.org; Thu, 24 Sep 2020 19:19:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42380] [PATCHv2 9/9] gnu: Add torbrowser-unbundle Resent-From: =?UTF-8?Q?Andr=C3=A9?= Batista Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 24 Sep 2020 23:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42380 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 42380@debbugs.gnu.org Received: via spool by 42380-submit@debbugs.gnu.org id=B42380.16009895211614 (code B ref 42380); Thu, 24 Sep 2020 23:19:02 +0000 Received: (at 42380) by debbugs.gnu.org; 24 Sep 2020 23:18:41 +0000 Received: from localhost ([127.0.0.1]:42005 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLaVW-0000Ps-Kv for submit@debbugs.gnu.org; Thu, 24 Sep 2020 19:18:41 -0400 Received: from mx1.riseup.net ([198.252.153.129]:33396) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLaVP-0000PQ-Jc for 42380@debbugs.gnu.org; Thu, 24 Sep 2020 19:18:31 -0400 Received: from bell.riseup.net (bell-pn.riseup.net [10.0.1.178]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Sectigo RSA Domain Validation Secure Server CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4By9vk4BzZzFdjr for <42380@debbugs.gnu.org>; Thu, 24 Sep 2020 16:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1600989506; bh=fsFfaKKpiuOBXeEFyCB83WhJqAia0KnOl7HEWU0wBF4=; h=Date:From:To:Subject:References:In-Reply-To:From; b=YMFrr6wjYkRoxElMYoqDuNpOo866gTnsE0JLh2vOU/6hZt9JTbUU/QBmx4TLEOdND 7dvX8UGAFDKjZSP7LnsdE5ZPRGzyANON2Yft/MX+LFTYGjDnMBZojpbxFPWJXMkQv8 68II9hFI+6a/goNNrDm/zabr4s+oEpaoKlSifqkY= X-Riseup-User-ID: 2325281948781B9FFD5CCEECDDFFF119C49AED525822A1DF0143085CBB23FB8B Received: from [127.0.0.1] (localhost [127.0.0.1]) by bell.riseup.net (Postfix) with ESMTPSA id 4By9vd6Vk3zJqk0 for <42380@debbugs.gnu.org>; Thu, 24 Sep 2020 16:18:21 -0700 (PDT) Date: Thu, 24 Sep 2020 20:18:14 -0300 From: =?UTF-8?Q?Andr=C3=A9?= Batista Message-ID: <20200924231814.GA29727@andel> References: <20200715211547.GA17146@andel> <20200725144930.GA13751@andel> <20200803125556.GA18868@andel> <87blihhdz6.fsf@gnu.org> <20200909022429.GA24930@andel> <878sdjo1qv.fsf@gnu.org> <20200915142128.GA12025@andel> <20200915151614.GI13296@andel> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1UWUbFP1cBYEclgG" Content-Disposition: inline In-Reply-To: <20200915151614.GI13296@andel> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=riseup.net header.s=squak header.b=YMFrr6wj; dmarc=fail reason="SPF not aligned (relaxed)" header.from=riseup.net (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -1.51 X-TUID: TsbqxoNI2Daw --1UWUbFP1cBYEclgG Content-Type: multipart/mixed; boundary="/04w6evG8XlLl3ft" Content-Disposition: inline --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, This patch updates Tor Browser to version 10.0. I've done some minor testing and everything seems to working. One thing that will need attention in the future is the cleaning of the profile dir, as the upgrade process does not touch it and so older configs and extensions remain on user profile. Main changes from the previous version are: - added a new phase to merge pluggable transports preferences into default tor-browser preferences before configuring the build instead of applying them on user preferences at runtime. - https-everywhere is now a builtin extension and requires further steps to be available at the right place. - defined %tbb-build in order to further differentiate tor-browser and tor-browser-build version tags. --/04w6evG8XlLl3ft Content-Type: text/plain; charset=utf-8 Content-Disposition: inline; filename="0001-gnu-Add-torbrowser-unbundle.patch" Content-Transfer-Encoding: quoted-printable =46rom f0e529147d7481c48395c741022e5ef8b3bc1c9b Mon Sep 17 00:00:00 2001 =46rom: =3D?UTF-8?q?Andr=3DC3=3DA9=3D20Batista?=3D Date: Thu, 24 Sep 2020 19:59:26 -0300 Subject: [PATCH] gnu: Add torbrowser-unbundle To: 42380@debbugs.gnu.org * gnu/packages/tor.scm (torbrowser-unbundle): New variable. * gnu/packages/patches/torbrowser-start-tor-browser.desktop.patch: New file. * gnu/packages/patches/torbrowser-start-tor-browser.patch: New file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. --- gnu/local.mk | 3 + ...torbrowser-start-tor-browser.desktop.patch | 22 + .../torbrowser-start-tor-browser.patch | 183 ++++ gnu/packages/tor.scm | 866 +++++++++++++++++- 4 files changed, 1073 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/torbrowser-start-tor-browser.deskt= op.patch create mode 100644 gnu/packages/patches/torbrowser-start-tor-browser.patch diff --git a/gnu/local.mk b/gnu/local.mk index f3b5b17e84..9331af8ce6 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -37,6 +37,7 @@ # Copyright =C2=A9 2020 Brice Waegeneire # Copyright =C2=A9 2020 Tanguy Le Carrour # Copyright =C2=A9 2020 Martin Becze +# Copyright =C2=A9 2020 Andr=C3=A9 Batista # # This file is part of GNU Guix. # @@ -1623,6 +1624,8 @@ dist_patch_DATA =3D \ %D%/packages/patches/tipp10-fix-compiling.patch \ %D%/packages/patches/tipp10-remove-license-code.patch \ %D%/packages/patches/tk-find-library.patch \ + %D%/packages/patches/torbrowser-start-tor-browser.desktop.patch \ + %D%/packages/patches/torbrowser-start-tor-browser.patch \ %D%/packages/patches/transcode-ffmpeg.patch \ %D%/packages/patches/ttf2eot-cstddef.patch \ %D%/packages/patches/tomb-fix-errors-on-open.patch \ diff --git a/gnu/packages/patches/torbrowser-start-tor-browser.desktop.patc= h b/gnu/packages/patches/torbrowser-start-tor-browser.desktop.patch new file mode 100644 index 0000000000..336115b33a --- /dev/null +++ b/gnu/packages/patches/torbrowser-start-tor-browser.desktop.patch @@ -0,0 +1,22 @@ +Change TorBrowser desktop file in order for it to be agnostic to the +path when invoked. + +--- torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser= =2Edesktop.orign 2020-07-05 18:47:40.689484877 -0300 ++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser= =2Edesktop 2020-07-25 02:54:44.603431160 -0300 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env ./Browser/execdesktop ++#!/usr/bin/env bash + # + # This file is a self-modifying .desktop file that can be run from the sh= ell. + # It preserves arguments and environment for the start-tor-browser script. +@@ -28,7 +28,7 @@ + GenericName=3DWeb Browser + Comment=3DTor Browser is +1 for privacy and =E2=88=921 for mass surveilla= nce + Categories=3DNetwork;WebBrowser;Security; +-Exec=3Dsh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ = ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/sta= rt-tor-browser --detach)' dummy %k +-X-TorBrowser-ExecShell=3D./Browser/start-tor-browser --detach +-Icon=3Dweb-browser ++Exec=3Dbash -c start-tor-browser ++X-TorBrowser-ExecShell=3Dstart-tor-browser --detach ++Icon=3Dtorbrowser + StartupWMClass=3DTor Browser diff --git a/gnu/packages/patches/torbrowser-start-tor-browser.patch b/gnu/= packages/patches/torbrowser-start-tor-browser.patch new file mode 100644 index 0000000000..a8403b09fa --- /dev/null +++ b/gnu/packages/patches/torbrowser-start-tor-browser.patch @@ -0,0 +1,183 @@ +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/RelativeLink/start-tor-browser= =2Eorig 2020-07-05 18:47:40.685485004 -0300 ++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser= 2020-08-01 20:22:08.901737325 -0300 +@@ -5,6 +5,15 @@ + # + # Copyright 2017 The Tor Project. See LICENSE for licensing information. +=20 ++TBB_HOME=3D"${HOME}/.local/share/torbrowser" ++TBB_LOGFILE=3D"${TBB_HOME}/torbrowser.log" ++TBB_DATA=3D"${TBB_HOME}/Data" ++TBB_PROFILE=3D"${TBB_DATA}/Browser/profile.default" ++TBB_STORE_PATH=3D$(dirname $(realpath "$0")) ++TBB_STORE_DATA=3D"${TBB_STORE_PATH}/TorBrowser/Data" ++TORRC=3D"${TBB_DATA}/Tor/torrc-defaults" ++##PT_PREFS=3D"${TBB_DATA}/Browser/bridge-prefs-js-appendix" ++ + complain_dialog_title=3D"Tor Browser" +=20 + # First, make sure DISPLAY is set. If it isn't, we're hosed; scream +@@ -134,8 +143,8 @@ + ;; + -l | --log) + if [ -z "$2" -o "${2:0:1}" =3D=3D "-" ]; then +- printf "Logging Tor Browser debug information to tor-browser= =2Elog\n" +- logfile=3D"../tor-browser.log" ++ printf "Logging Tor Browser debug information to torbrowser.= log\n" ++ logfile=3D"${TBB_LOGFILE}" + elif [ "${2:0:1}" =3D=3D "/" -o "${2:0:1}" =3D=3D "~" ]; then + printf "Logging Tor Browser debug information to %s\n" "$2" + logfile=3D"$2" +@@ -187,41 +196,23 @@ + export XAUTHORITY + fi +=20 +-# 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=3D"$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=3D"`realpath "$myname" 2>/dev/null`" +- if [ "$?" -eq 0 ]; then +- myname=3D"$possibly_my_real_name" +- else +- # realpath is not available; hopefully readlink -f works. +- myname=3D"`readlink -f "$myname" 2>/dev/null`" +- if [ "$?" -ne 0 ]; then +- # Ugh. +- complain "start-tor-browser cannot be run using a symlink on this oper= ating system." +- fi +- fi ++# Try to be agnostic to where we're being started from, check if files ar= e 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\", \"${TO= RRC}\");"\ ++ > "${TBB_PROFILE}/user.js" ++## grep -v 'default_bridge\.snowflake' "${PT_PREFS}" >> "${TBB_PROFILE}= /user.js" ++ echo "ClientTransportPlugin meek_lite,obfs2,obfs3,obfs4,scramblesuit e= xec ${TBB_STORE_PATH}/TorBrowser/Tor/PluggableTransports/obfs4proxy"\ ++ >> "${TORRC}" ++ cd "${TBB_HOME}" + fi +=20 +-# Try to be agnostic to where we're being started from, chdir to where +-# the script is. +-mydir=3D"`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 +227,9 @@ + ln -nsf ~/.config/ibus/bus .config/ibus + fi +=20 +-# 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=3D.*,Name=3DTor Browser,g" ../start-tor-browser.desktop +-sed -i -e "s,^Icon=3D.*,Icon=3D$PWD/browser/chrome/icons/default/default1= 28.png,g" ../start-tor-browser.desktop +-sed -i -e "s,^Exec=3D.*,Exec=3Dsh -c '\"$PWD/start-tor-browser\" --detach= || ([ ! -x \"$PWD/start-tor-browser\" ] \&\& \"\$(dirname \"\$*\")\"/Brow= ser/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/app= lications/" + update-desktop-database "$HOME/.local/share/applications/" + printf "Tor Browser has been registered as a desktop app for this user i= n ~/.local/share/applications/\n" + exit 0 +@@ -265,21 +249,6 @@ + HOME=3D"${PWD}" + export HOME +=20 +-SYSARCHITECTURE=3D$(getconf LONG_BIT) +-TORARCHITECTURE=3D$(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'l= l get +-# a crash during shutdown: https://bugs.torproject.org/10599#comment:59 +-ASAN_OPTIONS=3D"detect_leaks=3D0" +-export ASAN_OPTIONS +-[% END -%] +- + function setControlPortPasswd() { + local ctrlPasswd=3D$1 +=20 +@@ -342,13 +311,15 @@ + # your password in the following line where the word =E2=80=9Csecret=E2= =80=9D is: + setControlPortPasswd ${TOR_CONTROL_PASSWD:=3D'"secret"'} +=20 +-# Set up custom bundled fonts. See fonts-conf(5). +-export FONTCONFIG_PATH=3D"${HOME}/TorBrowser/Data/fontconfig" +-export FONTCONFIG_FILE=3D"fonts.conf" +- + # Avoid overwriting user's dconf values. Fixes #27903. + export GSETTINGS_BACKEND=3Dmemory +=20 ++# Set up custom bundled fonts. See fonts-conf(5). ++export FONTCONFIG_FILE=3D"${HOME}/Data/fontconfig/fonts.conf" ++ ++sed -i "${FONTCONFIG_FILE}"\ ++ -e "s,fonts,${TBB_STORE_PATH}/fonts," ++ + cd "${HOME}" +=20 + # We pass all additional command-line arguments we get to Firefox. +@@ -357,23 +328,23 @@ +=20 + if [ "$show_usage" -eq 1 ]; then + # Display Firefox help, then our help +- TOR_CONTROL_PASSWD=3D${TOR_CONTROL_PASSWD} ./firefox --class "Tor Bro= wser" \ +- -profile TorBrowser/Data/Browser/profile.default --help 2>/dev/nu= ll ++ TOR_CONTROL_PASSWD=3D${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox = --class "Tor Browser" \ ++ -profile Data/Browser/profile.default --help 2>/dev/null + tbb_usage + elif [ "$detach" -eq 1 ] ; then +- TOR_CONTROL_PASSWD=3D${TOR_CONTROL_PASSWD} ./firefox --class "Tor Bro= wser" \ +- -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfil= e" 2>&1 "$logfile" 2>&1 &1 &1 "$logfi= le" 2>&1 "$logfile" 2>&1 + ;; and related comments in the 'remove-bundled-libraries' phase. + ;; UNBUNDLE-ME! ("nspr" ,nspr) + ;; UNBUNDLE-ME! ("nss" ,nss) + ("obfs4" ,obfs4) + ("pango" ,pango) + ("pixman" ,pixman) + ("pulseaudio" ,pulseaudio) + ("shared-mime-info" ,shared-mime-info) + ;("sqlite" ,sqlite) + ("startup-notification" ,startup-notification) + ("tor" ,tor-client) + ("unzip" ,unzip) + ("zip" ,zip))) + (native-inputs + `(("autoconf" ,autoconf-2.13) + ("bash" ,bash) + ("cargo" ,rust-1.41 "cargo") + ("clang" ,clang) + ("https-everywhere" ,https-everywhere) + ("llvm" ,llvm) + ("patch" ,(canonical-package patch)) + ("torbrowser-start-tor-browser.patch" + ,(search-patch "torbrowser-start-tor-browser.patch")) + ("torbrowser-start-tor-browser.desktop.patch" + ,(search-patch "torbrowser-start-tor-browser.desktop.patch")) + ("perl" ,perl) + ("pkg-config" ,pkg-config) + ("python" ,python) + ("python2" ,python-2.7) + ("python2-pysqlite" ,python2-pysqlite) + ("nasm" ,nasm) ; XXX FIXME: only needed on x86_64 and i686 + ("node" ,node-10.22) + ("noscript" ,noscript) + ("rust" ,rust-1.41) + ("rust-cbindgen" ,rust-cbindgen-0.14) + ("tor-browser-build" ,tor-browser-build) + ("torbrowser-fonts" ,torbrowser-fonts) + ("tor-launcher" ,tor-launcher) + ("torbutton" ,torbutton) + ("which" ,which) + ("yasm" ,yasm))) + (arguments + `(#:tests? #f ; Some tests are autodone by mach on build fase. + + ;; XXX: There are RUNPATH issues such as + ;; $prefix/lib/icecat-31.6.0/plugin-container NEEDing libmozalloc.= so, + ;; which is not in its RUNPATH, but they appear to be harmless in + ;; practice somehow. See . + #:validate-runpath? #f + #:imported-modules ,%cargo-utils-modules ;for `generate-all-checks= ums' + #:modules ((ice-9 ftw) + (ice-9 rdelim) + (ice-9 regex) + (ice-9 match) + (srfi srfi-34) + (srfi srfi-35) + (rnrs bytevectors) + (rnrs io ports) + (guix elf) + (guix build gremlin) + (guix build utils) + (sxml simple) + ,@%gnu-build-system-modules) + + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'make-bundle + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (let ((torbutton (assoc-ref inputs "torbutton")) + (torbutton-dir "toolkit/torproject/torbutton") + (tor-launcher (assoc-ref inputs "tor-launcher")) + (tor-launcher-dir "browser/extensions/tor-launcher") + (tbb (assoc-ref inputs "tor-browser-build")) + (tbb-scripts-dir "tbb-scripts")) + (format #t "Copying torbutton source to default path ...~%= ") + (make-file-writable torbutton-dir) + (copy-recursively torbutton torbutton-dir + #:log (%make-void-port "w")) + (format #t "Copying tor-launcher ...~%") + (copy-recursively tor-launcher tor-launcher-dir + #:log (%make-void-port "w")) + (format #t "Copying tor-browser-build ...~%") + (mkdir tbb-scripts-dir) + (copy-recursively tbb tbb-scripts-dir + #:log (%make-void-port "w")) + (make-file-writable (string-append tbb-scripts-dir + "/RelativeLink/start-tor-browser")) + (make-file-writable (string-append tbb-scripts-dir + "/RelativeLink/start-tor-browser.desk= top"))) + #t)) + + (add-after 'make-bundle 'apply-guix-specific-patches + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (let ((patch (string-append (assoc-ref (or native-inputs inp= uts) + "patch") + "/bin/patch"))) + (for-each (match-lambda + ((label . file) + (when (and (string-prefix? "torbrowser-" label) + (string-suffix? ".patch" label)) + (format #t "applying '~a'...~%" file) + (invoke patch "--force" "--no-backup-if-mismatch" + "-p1" "--input" file)))) + (or native-inputs inputs))) + #t)) + + (add-after 'apply-guix-specific-patches 'merge-pt-prefs + (lambda* (#:key inputs native-inputs #:allow-other-keys) + (begin + (make-file-writable "browser/app/profile/000-tor-browser.j= s") + (let ((tbb-prefs (open-file "browser/app/profile/000-tor-b= rowser.js" + "a")) + (pt-prefs (open-input-file + "tbb-scripts/Bundle-Data/PTConfigs/bridge= _prefs.js"))) + (display (get-string-all pt-prefs) tbb-prefs) + (close-output-port tbb-prefs))) + #t)) + ;; On mach build system this is done on configure. + (delete 'bootstrap) + + (add-after 'patch-source-shebangs 'patch-cargo-checksums + (lambda _ + (use-modules (guix build cargo-utils)) + (let ((null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649= b934ca495991b7852b855")) + (for-each (lambda (file) + (format #t "patching checksums in ~a~%" file) + (substitute* (find-files "." "Cargo.lock$") + (("^checksum =3D \".*\"") + (string-append "checksum =3D \"" null-hash "= \"")))) + (find-files "." "Cargo.lock$")) + (for-each generate-all-checksums + '("services" + "js" + "third_party/rust" + "dom/media" + "dom/webauthn" + "toolkit" + "gfx" + "storage" + "modules" + "xpcom/rust" + "media" + "mozglue/static/rust" + "netwerk" + "remote" + "intl" + "servo" + "security/manager/ssl" + "build"))) + #t)) + + (add-after 'build 'neutralize-store-references + (lambda _ + ;; Mangle the store references to compilers & other build to= ols in + ;; about:buildconfig, reducing Tor Browser's closure signifi= cant. + ;; The resulting files are saved in lib/firefox/omni.ja + (substitute* "objdir/dist/bin/chrome/toolkit/content/global/= buildconfig.html" + (((format #f "(~a/)([0-9a-df-np-sv-z]{32})" + (regexp-quote (%store-directory))) _ store hash) + (string-append store + (string-take hash 8) + "" + (string-drop hash 8)))) + #t)) + + (replace 'configure + (lambda* (#:key inputs outputs configure-flags #:allow-other-k= eys) + (let* ((out (assoc-ref outputs "out")) + (bash (which "bash")) + (flags `(,(string-append "--prefix=3D" out) + ,@configure-flags))) + + (setenv "SHELL" bash) + (setenv "AUTOCONF" (string-append + (assoc-ref %build-inputs "autoconf") + "/bin/autoconf")) + (setenv "CONFIG_SHELL" bash) + (setenv "PYTHON" (string-append + (assoc-ref inputs "python2") + "/bin/python")) + (setenv "CC" "gcc") ; needed when Stylo is enabled + (setenv "MOZ_BUILD_DATE" ,%torbrowser-build-id) ; avoid ti= mestamp. + (setenv "LDFLAGS" (string-append + "-Wl,-rpath=3D" + (assoc-ref outputs "out") + "/lib/firefox")) + (substitute* ".mozconfig" + ;; Arch independent builddir. + (("(mk_add_options MOZ_OBJDIR=3D@TOPSRCDIR@/obj).*" _ m) + (string-append m "dir\n")) + (("ac_add_options --disable-tor-launcher") "") + ;; We won't be building incrementals. + (("ac_add_options --enable-signmar") "") + (("ac_add_options --enable-verify-mar") "") + (("ac_add_options --with-tor-browser-version=3Ddev-build= ") + (string-append "ac_add_options --with-tor-browser-versi= on=3Dorg.gnu\n" + "ac_add_options --with-unsigned-addon-sc= opes=3Dapp,system\n" + "ac_add_options --allow-addon-sideload\n" + "ac_add_options --enable-pulseaudio\n" + "ac_add_options --disable-debug-symbols\= n" + "ac_add_options --disable-updater\n" + ;; Unknown in 10.0 + ;;"ac_add_options --disable-gconf\n" + ;; Other syslibs that can be unbundled? = (nss, nspr) + "ac_add_options --enable-system-pixman\n" + "ac_add_options --enable-system-ffi\n" + ;; Unknown in 10.0 + ;;"ac_add_options --with-system-bz2\n" + ;"ac_add_options --with-system-icu\n" + "ac_add_options --with-system-jpeg\n" + ;"ac_add_options --with-system-libevent\= n" + ;"ac_add_options --with-system-zlib\n" + ;; Without these clang is not found. + "ac_add_options --with-clang-path=3D" + (assoc-ref %build-inputs "clang") "/bin= /clang\n" + "ac_add_options --with-libclang-path=3D" + (assoc-ref %build-inputs "clang") "/lib\= n"))) + + (substitute* "browser/app/profile/000-tor-browser.js" + ;; Tor Browser updates are disabled on mozconfig, but le= t's make sure. + (("(pref\\(\"extensions.torbutton.versioncheck_enabled\"= ).*" _ m) + (string-append m ",false);\n")) + ;; Snowflake is not built on gnu targets. + (("pref\\(\"extensions.torlauncher.default_bridge.snowfl= ake.1\".*") + "\n")) + + (substitute* + "browser/extensions/tor-launcher/src/defaults/preferences= /torlauncher-prefs.js" + ;; Not multilingual. See tor-browser/build:141. Currentl= y disabled on + ;; tor-launcher, but let's make sure while missing langp= acks. + (("(pref\\(\"extensions.torlauncher.prompt_for_locale\").= *" _ m) + (string-append m ", false);\n"))) + + ;; For user data outside the guix store. + (substitute* "xpcom/io/TorFileUtils.cpp" + (("ANDROID") "GNUGUIX")) + + (substitute* "old-configure.in" + (("(AC_SUBST\\(TOR_BROWSER_DISABLE_TOR_LAUNCHER\\))" _ m) + (string-append m "\n AC_DEFINE(GNUGUIX)\n"))) + + (format #t "Invoking mach configure ...~%") + (invoke "./mach" "configure")) + #t)) + + (replace 'build + (lambda _ + ;; Build fails without this. Does it make the build nondeter= ministic? + (make-file-writable "Cargo.lock") + (invoke "./mach" "build") + #t)) + + ;; Tor Browser just do a stage-package here and copy files to it= s places. + (replace 'install + (lambda* (#:key inputs native-inputs outputs + configure-flags #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (applications (string-append out "/share/applications= ")) + (build "objdir/dist/firefox") + (bin (string-append out "/bin")) + (lib (string-append out "/lib/firefox")) + (start-script + "tbb-scripts/RelativeLink/start-tor-browser") + (desktop-file + "tbb-scripts/RelativeLink/start-tor-browser.desktop"= )) + (invoke "./mach" "build" "stage-package") + ;; Tor Browser doesn't use those. + ;; See: tor-browser-build.git/projects/firefox/build:167 + (format #t "Deleting spurious files ...~%") + (with-directory-excursion build + (for-each (lambda (file) + (if (file-exists? file) + (delete-file file) + (display (string-append + "Warning: file " file + " not found! Skipping...\n")))) + '("firefox-bin" "libfreeblpriv3.chk" "libnssdb= m3.chk" + "libsoftokn3.chk" "fonts/TwemojiMozilla.ttf"= ))) + (rmdir (string-append build "/fonts")) + (format #t "Creating install dirs ...~%") + (mkdir-p applications) + (mkdir-p lib) + (mkdir bin) + (format #t "Copying files to install dirs ...~%") + (copy-recursively build (string-append lib "/") + #:log (%make-void-port "w")) + (copy-file start-script + (string-append lib "/start-tor-browser")) + (copy-file desktop-file + (string-append lib "/start-tor-browser.desktop"= )) + (chmod (string-append lib "/start-tor-browser") #o555) + (chmod (string-append lib "/start-tor-browser.desktop") #o= 555) + (format #t "Linking start-tor-browser script ...~%") + (symlink (string-append lib "/start-tor-browser") + (string-append bin "/start-tor-browser")) + (format #t "Installing desktop file ...~%") + (install-file desktop-file applications)) + #t)) + + (add-after 'install 'install-icons + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (icons-src (string-append + out "/lib/firefox/browser/chrome/icons/de= fault"))) + (with-directory-excursion + icons-src + (for-each + (lambda (file) + (let* ((size (string-filter char-numeric? file)) + (icons (string-append out "/share/icons/hicolo= r/" + size "x" size "/apps"))) + (mkdir-p icons) + (copy-file file (string-append icons "/torbrowser.p= ng")))) + '("default16.png" "default32.png" "default48.png" "defa= ult64.png" + "default128.png")))) + #t)) + + (add-after 'install-icons 'install-fonts + (lambda* (#:key inputs native-inputs outputs #:allow-other-key= s) + (let* ((out (assoc-ref outputs "out")) + (lib (string-append out "/lib/firefox/")) + (fonts (string-append (or (assoc-ref native-inputs + "torbrowser-fon= ts") + (assoc-ref inputs + "torbrowser-fon= ts")) + "/share"))) + (copy-recursively fonts lib + #:log (%make-void-port "w")) + (symlink (string-append lib "/fonts") + (string-append out "/share/fonts"))) + #t)) + + (add-after 'install-fonts 'install-extensions + (lambda* (#:key inputs native-inputs outputs #:allow-other-key= s) + (let* ((out (assoc-ref outputs "out")) + (lib (string-append out "/lib/firefox")) + (ext (string-append out "/lib/firefox/browser/extensi= ons")) + (torb-ext (string-append out + "/lib/firefox/chrome/torbutton/content/ex= tensions")) + (noscript-id "{73a6fe31-595d-460b-a920-fcc0f8843232}") + (httpse-id "https-everywhere") + (noscript (assoc-ref inputs "noscript")) + (httpse (assoc-ref inputs "https-everywhere"))) + (mkdir-p ext) + (mkdir-p torb-ext) + (copy-file noscript (string-append + ext "/" noscript-id ".xpi")) + (copy-recursively httpse + (string-append torb-ext "/" httpse-id) + #:log (%make-void-port "w")) + (chmod (string-append ext "/" noscript-id ".xpi") #o555) + ;; Make httpse available as a builtin extension. + (with-directory-excursion lib + (make-file-writable "omni.ja") + (for-each (lambda (file) + (invoke "zip" "-X" "omni.ja" file)) + (find-files "chrome" ".*")))) + #t)) + + (add-after 'install-extensions 'link-binaries + (lambda* (#:key inputs native-inputs outputs #:allow-other-key= s) + (let* ((out (assoc-ref outputs "out")) + (tordir (string-append out "/lib/firefox/TorBrowser/T= or")) + (ptdir (string-append tordir "/PluggableTransports")) + (obfs4 (string-append (assoc-ref inputs "obfs4") + "/bin/obfs4proxy")) + (tor (string-append (assoc-ref inputs "tor") + "/bin/tor"))) + (mkdir-p ptdir) + (symlink tor (string-append tordir "/tor")) + (symlink obfs4 (string-append ptdir "/obfs4proxy"))) + #t)) + + (add-after 'link-binaries 'copy-bundle-data + (lambda* (#:key inputs native-inputs outputs #:allow-other-key= s) + (let* ((out (assoc-ref outputs "out")) + (lib (string-append out "/lib/firefox")) + (tbb "tbb-scripts") + (ptconf (string-append tbb "/Bundle-Data/PTConfigs")) + (docs (string-append lib "/TorBrowser/Docs")) + (data (string-append lib "/TorBrowser/Data"))) + (mkdir-p data) + (mkdir docs) + (with-directory-excursion + (string-append tbb "/Bundle-Data/linux/Data") + (for-each (lambda (file) + (copy-recursively file + (string-append data "/" fil= e) + #:log (%make-void-port "w")= )) + '("Browser" "fontconfig" "Tor"))) + (copy-file (string-append ptconf "/linux/torrc-defaults-ap= pendix") + (string-append data "/Tor/torrc-defaults-append= ix")) + (copy-file (string-append ptconf "/bridge_prefs.js") + (string-append + data "/Browser/bridge-prefs-js-appendix")) + (copy-recursively (string-append tbb "/Bundle-Data/Docs") + (string-append docs "/") + #:log (%make-void-port "w"))) + #t)) + + ;; This fixes the file chooser crash that happens with GTK 3 + (add-after 'copy-bundle-data 'wrap-program + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (lib (string-append out "/lib/firefox")) + (gtk (assoc-ref inputs "gtk+")) + (gtk-share (string-append gtk "/share")) + (mesa (assoc-ref inputs "mesa")) + (mesa-lib (string-append mesa "/lib")) + (pulseaudio (assoc-ref inputs "pulseaudio")) + (pulseaudio-lib (string-append pulseaudio "/lib")) + (libxscrnsaver (assoc-ref inputs "libxscrnsaver")) + (libxscrnsaver-lib (string-append libxscrnsaver "/lib= "))) + (wrap-program (car (find-files lib "^firefox$")) + `("XDG_DATA_DIRS" prefix (,gtk-share)) + `("LD_LIBRARY_PATH" prefix (,pulseaudio-lib ,mesa-lib + ,libxscrnsaver-lib)))) + #t))))) + (home-page "https://www.torproject.org") + (synopsis "Anonymous browser derived from Mozilla Firefox") + (description + "Tor Browser is the Tor Project version of Firefox browser. It is t= he only +recommended way to anonymously browse the web that is supported by the pro= ject. +It modifies Firefox in order to avoid many know application level attacks = on +the privacy of Tor users. + +WARNING: This is not the official Tor Browser and is currently on testing.= Use +at your own risk and please report back on guix channels if you find any +issues.") + (license license:mpl2.0)))) ;and others, see toolkit/content/license.= html --=20 2.28.0 --/04w6evG8XlLl3ft-- --1UWUbFP1cBYEclgG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQI5BAABCgAjFiEEIBdLYNLH+F+MBdSrYrJ+WmBEwoIFAl9tKTQFgwPCZwAACgkQ YrJ+WmBEwoLTcBAAoXcLdICQ4EJtxUSV2UeEaajxtBzGwjBLe1mwVDqELkilsQUW akCa6Ix7+G2yWKioSHreJFaEjNGg9uyI1LjUTfH/3WXy6YUm5VyRe5JH+BTYKOPK 10B2ACQJceH4xfvLypWmgCijrNGwgH1yXxlAr15ivZ+wi4o3yza5i/13B8kLEIqP KT9OEE507e0S954LREf5X7wam5x5YbiIfR3tQKBmQ4jEMAOfo4hWZ2H1ioXQaGlc 9ol1dtfAz1BQ6nVGG3qxEINsB/u+os1tikwHioOrMecpmv26ecHX1f6T5oXHwpGV WEfYAT4fM2+kjRqlIogjmpmomDN/PRUZkNSbmL1P6o4rDGA+6yf5S68Nf+4D3uQ5 PXJGvHodtn4GNXU3OKzi12DOCGAJ6DLoVKphnpys4mMQ5XZI792Tuc9yG1pxRZHp y+TtKod57sZJAWX8zENod72HcNaj4tO6M+0xDNfTJ9EXxQmNy82EWiw2yy1Y2z3t ZpciG6XStVlVtJe9fy/Rfq0BTc6q5dwOAKM2dSB8bpuPNYXaDkShZwRQQsfoRXRs Q09ZjnAWoy9aFfrpBsT87JhfumYf84dxGSKNfV8mb3G0C/ITE08gjFcRMvWcJjeC tWpTYH8qvJiM0HN01/+0yeEF1/sDnKBHM6TVCk/f38++7a+rWo1VYX1k4f0= =9051 -----END PGP SIGNATURE----- --1UWUbFP1cBYEclgG--