unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#42380] [WIP] gnu: Add torbrowser-unbundle.
@ 2020-07-15 21:15 André Batista
  2020-07-25 14:49 ` [bug#42380] [PATCH] " André Batista
                   ` (3 more replies)
  0 siblings, 4 replies; 56+ messages in thread
From: André Batista @ 2020-07-15 21:15 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 1680 bytes --]

Hello Guix!

The patch bellow adds a torbrowser-unbundle variable, but it needs a
bit of working before merging into master. I've inserted many
comments on the code regarding issues which need attention and
questions that remained. I've decided to send this early notice so I
can ask some questions and get criticism before I go too deep on the
wrong direction.

As the name implies it does not bundle tor and to use it, you need
to have a properly configured system instance. You also need to
configure a ControlPort and a HashedControlPassword if you want to
be able to get new identities while browsing and if you don't want
to keep seeing a warning on startup page. It will create/change
permissions on ${HOME}/Data and use the native Downloads dir. It does
not have bundled fonts, so you will be fingerprintable on levels
bellow safest. It does not have support for obfs4 bridges yet.

There is no startup script for now, you are advised to invoke it with
'--class "Tor Browser"'.

Now for the questions:
- Should it keep unbundled? If so, should we try to unbundle the
  https-everywhere and noscript extensions?
- Is it acceptable to use to use the noscript .xpi, instead of
  building? Upstream just grabs it from addons.mozilla. There does
  not appear to be blobs and the GPL full text is inside it.
- Should we try change the app name at build time or is it enough to
  adapt the name of the startup script (which is not the for now, but
  is certainly needed)?
- Any other things that I've been blind to?

If you don't have time to review the code, but has processing
power available, build it with rounds=2 or try to cross compile
for i686 and comment back.

Thanks,

[-- Attachment #1.2: 0001-gnu-Add-torbrowser-unbundle.patch --]
[-- Type: text/plain, Size: 33930 bytes --]

From 2a9d31c9422de3d7486da6c2ef3e15c3496c7e69 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Wed, 15 Jul 2020 17:24:04 -0300
Subject: [PATCH] gnu: Add torbrowser-unbundle.
To: guix-patches@gnu.org

* gnu/packages/tor.scm (torbrowser-unbundle): New variable.
---
 gnu/packages/tor.scm | 634 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 633 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index c852c54a5b..528a528403 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -49,7 +49,49 @@
   #:use-module (gnu packages qt)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages w3m))
+  #:use-module (gnu packages w3m)
+  ;; New flags start here. Verify if they are all needed.
+  #:use-module ((srfi srfi-1) #:hide (zip))
+  #:use-module (ice-9 match)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
+  #:use-module (guix store)
+  #:use-module (guix monads)
+  #:use-module (guix build-system cargo)
+  #:use-module (guix build-system trivial)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages audio)
+  #:use-module (gnu packages autotools)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages databases)
+  #:use-module (gnu packages glib)
+  #:use-module (gnu packages gtk)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages libcanberra)
+  #:use-module (gnu packages cups)
+  #:use-module (gnu packages kerberos)
+  #:use-module (gnu packages perl)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages libreoffice)  ;for hunspell
+  #:use-module (gnu packages image)
+  #:use-module (gnu packages libffi)
+  #:use-module (gnu packages pulseaudio)
+  #:use-module (gnu packages node)
+  #:use-module (gnu packages xorg)
+  #:use-module (gnu packages gl)
+  #:use-module (gnu packages assembly)
+  #:use-module (gnu packages rust)
+  #:use-module (gnu packages rust-apps)
+  #:use-module (gnu packages llvm)
+  #:use-module (gnu packages nss)
+  #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages video)
+  #:use-module (gnu packages xiph)
+  #:use-module (gnu packages xdisorg)
+  #:use-module (gnu packages readline)
+  #:use-module (gnu packages vim) ; for xxd
+  #:use-module (gnu packages sqlite))
 
 (define-public tor
   (package
@@ -324,3 +366,593 @@ statistics and status reports on:
 
 Potential client and exit connections are scrubbed of sensitive information.")
     (license license:gpl3+)))
+
+;; Imported from gnuzilla.scm, make it public there?
+(define* (computed-origin-method gexp-promise hash-algo hash
+                                 #:optional (name "source")
+                                 #:key (system (%current-system))
+                                 (guile (default-guile)))
+  "Return a derivation that executes the G-expression that results
+from forcing GEXP-PROMISE."
+  (mlet %store-monad ((guile (package->derivation guile system)))
+    (gexp->derivation (or name "computed-origin")
+                      (force gexp-promise)
+                      #:graft? #f       ;nothing to graft
+                      #:system system
+                      #:guile-for-build guile)))
+
+(define %torbrowser-version "68.10.0esr-9.5-1")
+(define %torbrowser-build-id "20200709000000") ;must be of the form YYYYMMDDhhmmss
+
+;; (Un)fortunatly TorBrowser has it's own reproducible build system - RBM - which
+;; automates the build process for them and compiles TorBrowser from a range of
+;; repositories and produces a range of tarballs for different architectures and
+;; locales. So we need to nit-pick what is needed for guix and produce our own
+;; tarball. See https://gitweb.torproject.org/builders/tor-browser-build.git/projects/\
+;; {tor-browser,firefox}/{build,config} for the rationale applied here. When built from its
+;; unpatched repo, the 'mozconfig' is different and it errors out on missing
+;; torbutton source code. If we patch 'toolkit/moz.build', it compiles successfuly
+;; but the browser does not run and even if it ran, it would be missing most of
+;; its funcionality. See also the Hacking on TorBrowser document for a high level
+;; introduction (https://trac.torproject.org/projects/tor/wiki/doc/TorBrowser/Hacking).
+;;
+;; WARNING: For now it still lacks the bundled fonts, obfs4 bridge and locales.
+;; If used on level below safest, the browser accessible fonts are fingerprintable.
+;; On safest, it doesn't seem to be distinguishable from upstream bundle according
+;; to https://panopticlick.eff.org. To access some features, users need to
+;; configure the ControlPort and HashedControlPassword in system torrc and set
+;; TOR_CONTROL_PASSWD accordingly before launching the Browser (ControlPort defaults to
+;; 9051). Without this, the browser will work (try https://check.torproject.org) but
+;; user is presented with a startup page that tells something is wrong.
+(define torbrowser-source
+  (let* ((torbrowser-commit "75c2bb720d4ceb76231e8ecc3455754bf05ba19b")
+         (torbrowser-version %torbrowser-version)
+         (upstream-torbrowser-source
+          (origin
+            (method git-fetch)
+            (uri (git-reference
+                  (url "https://git.torproject.org/tor-browser.git")
+                  (commit torbrowser-commit)))
+            (file-name (git-file-name "tor-browser" torbrowser-version))
+            ;; Substitute for hash syntax.
+            (sha256
+             (base32
+              "19sk46k2bqa72il46pdl534nk2g3fi6l7m7kbglddccxv19ck0k4"))))
+
+         ;; Not used yet, mainly useful for references and for a patched start-tor-browser
+         ;; script in the near future.
+         (torbrowser-build-commit "e94ba3a7677f7051a14b2304427ec8393a450fdc")
+         (torbrowser-build-version "9.5")
+         (upstream-torbrowser-build-source
+          (origin
+            (method git-fetch)
+            (uri (git-reference
+                  (url "https://git.torproject.org/builders/tor-browser-build.git")
+                  (commit torbrowser-build-commit)))
+            (file-name (git-file-name "tor-browser-build" torbrowser-build-version))
+            ;; Substitute for hash syntax.
+            (sha256
+             (base32
+              "1jgkrsckcjgr1lgcwahzdrcasmpghs2ppz6w80fya89pa5d6r0gv"))))
+
+         (torbutton-commit "ebe2bedab44e38f18c7968bd327d99eef7660f34")
+         (torbutton-version "9.5")
+         (upstream-torbutton-source
+          (origin
+            (method git-fetch)
+            (uri (git-reference
+                  (url "https://git.torproject.org/torbutton.git")
+                  (commit torbutton-commit)))
+            (file-name (git-file-name "torbutton" torbutton-version))
+            ;; Substitute for hash syntax.
+            (sha256
+             (base32
+              "03xdyszab1a8j98xv6440v4lq58jkfqgmhxc2a62qz8q085d2x83"))))
+
+         (tor-launcher-commit "b4838d339a84c5ebebd91a0ba6b22d44ecda97b1")
+         (tor-launcher-version "0.2.21")
+         (upstream-tor-launcher-source
+          (origin
+            (method git-fetch)
+            (uri (git-reference
+                  (url "https://git.torproject.org/tor-launcher.git")
+                  (commit tor-launcher-commit)))
+            (file-name (git-file-name "tor-launcher" tor-launcher-version))
+            ;; Substitute for hash syntax.
+            (sha256
+             (base32
+              "0xxwyw1j6dkm2a24kg1564k701p5ikfzs1f9n0gflvlzz9427haf"))))
+
+         ;; TorBrowser uses its own git repo but it appears to be unpatched from upstream
+         ;; and it does no provide a tarball, so let's try upstream for now.
+         (https-everywhere-version "2020.5.20")
+         (upstream-https-everywhere-source
+          (origin
+            (method url-fetch)
+            (uri (string-append "https://github.com/EFForg/https-everywhere/archive/"
+                                https-everywhere-version ".tar.gz"))
+            ;; Substitute for hash syntax.
+            (sha256
+             (base32
+              "027lga3z0a4d7s95id861das7g0k29p7pqh9xd77jm87f7w4l763"))))
+
+         ;; TorBrowser 9.5.1 actualy uses v11.0.32, but let's get latest release.
+         ;; TorProject uses the .xpi instead of compiling the source code.
+         (noscript-xpi-version "11.0.34")
+         (upstream-noscript-xpi
+          (origin
+            (method url-fetch)
+            (uri (string-append "https://secure.informaction.com/download/releases/noscript-"
+                                noscript-xpi-version ".xpi"))
+            (sha256
+             (base32
+              "0y45925ms2bk9d42zbgwcdb2sif8kqlbaflkz15q08gi7vgki6km"))))
+
+         ;; Not used for now. It uses curl to update TLDs at build time which will make
+         ;; the build unreproducible. Also it uses LWM::Simple module which is not available
+         ;; on guix. Moreover, it complains about perl not having regexp capabilities. Patch
+         ;; build script, translate it to guile or just use the .xpi as upstream does?
+         (noscript-version "11.0.34")
+         (upstream-noscript-source
+          (origin
+            (method url-fetch)
+            (uri (string-append "https://github.com/hackademix/noscript/archive/"
+                                noscript-version ".tar.gz"))
+            ;; Substitute for hash syntax.
+            (sha256
+             (base32
+              "1amhdwc62cnp1i7vx4zyqd7iyj52rcr5ks9a39viczpqgfgk7hfy")))))
+
+    ;; Now we bundle the grabbed sources.
+    (origin
+      (method computed-origin-method)
+      (file-name (string-append "torbrowser-" %torbrowser-version ".tar.xz"))
+      (sha256 #f)
+      (uri
+       (delay
+         (with-imported-modules '((guix build utils))
+          #~(begin
+              (use-modules (guix build utils))
+              (let ((torbrowser-dir (string-append "torbrowser-" #$torbrowser-version))
+                    (torbutton-dir "toolkit/torproject/torbutton")
+                    (tor-launcher-dir "browser/extensions/tor-launcher")
+                           (tbb-scripts-dir "tbb-scripts")
+                    (https-everywhere "https-everywhere.tar.gz")
+                    (noscript "noscript.tar.gz")
+                    (noscript-xpi "noscript.xpi"))
+
+                (set-path-environment-variable
+                 "PATH" '("bin")
+                 (list #+(canonical-package bash)
+                       #+(canonical-package xz)
+                       #+(canonical-package tar)))
+
+                (format #t "Copying torbrowser source to writable path ...~%")
+                (force-output)
+                (copy-recursively #+upstream-torbrowser-source
+                                  torbrowser-dir
+                                  #:log (%make-void-port "w"))
+
+                (with-directory-excursion torbrowser-dir
+                  (format #t "Setting torbutton to writable...~%")
+                  (force-output)
+                  (make-file-writable torbutton-dir)
+
+                  (format #t "Copying torbutton source to torbrowser...~%")
+                  (force-output)
+                  (copy-recursively #+upstream-torbutton-source
+                                    torbutton-dir
+                                    #:log (%make-void-port "w"))
+
+                  (format #t "Copying tor-launcher source to torbrowser...~%")
+                  (force-output)
+                  (copy-recursively #+upstream-tor-launcher-source
+                                    tor-launcher-dir
+                                    #:log (%make-void-port "w"))
+
+                  (format #t "Copying tor-browser-build source to torbrowser...~%")
+                  (force-output)
+                  (mkdir tbb-scripts-dir)
+                  (copy-recursively #+upstream-torbrowser-build-source
+                                    tbb-scripts-dir
+                                    #:log (%make-void-port "w"))
+
+                  (format #t "Copying https-everywhere source to torbrowser...~%")
+                  (force-output)
+                  (copy-file #+upstream-https-everywhere-source
+                             https-everywhere)
+
+                  (format #t "Copying noscript source to torbrowser...~%")
+                  (force-output)
+                  (copy-file #+upstream-noscript-source
+                             noscript)
+
+                  (format #t "Copying noscript xpi to torbrowser...~%")
+                  (force-output)
+                  (copy-file #+upstream-noscript-xpi
+                             "noscript.xpi"))
+
+                (invoke "tar" "cvfa" #$output
+                        ;; Avoid non-determinism in the archive. For now just copy icecat timestamp.
+                        "--mtime=@315619200" ; 1980-01-02 UTC
+                        "--owner=root:0"
+                        "--group=root:0"
+                        "--sort=name"
+                        torbrowser-dir)
+                #t))))))))
+
+(define-public torbrowser-unbundle
+  (package
+    (name "torbrowser-unbundle")
+    (version %torbrowser-version)
+    (source torbrowser-source)
+    (build-system gnu-build-system)
+    (inputs
+     `(("alsa-lib" ,alsa-lib)
+       ("bzip2" ,bzip2)
+       ("cups" ,cups)
+       ("dbus-glib" ,dbus-glib)
+       ("gdk-pixbuf" ,gdk-pixbuf)
+       ("glib" ,glib)
+       ("gtk+" ,gtk+)
+       ("gtk+-2" ,gtk+-2)
+       ("graphite2" ,graphite2)
+       ("pango" ,pango)
+       ("freetype" ,freetype)
+       ("harfbuzz" ,harfbuzz)
+       ("libcanberra" ,libcanberra)
+       ("libgnome" ,libgnome)
+       ("libjpeg-turbo" ,libjpeg-turbo)
+       ("libogg" ,libogg)
+       ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
+       ("libvorbis" ,libvorbis)
+       ("libxft" ,libxft)
+       ("libevent" ,libevent)
+       ("libxinerama" ,libxinerama)
+       ("libxscrnsaver" ,libxscrnsaver)
+       ("libxcomposite" ,libxcomposite)
+       ("libxt" ,libxt)
+       ("libffi" ,libffi)
+       ("ffmpeg" ,ffmpeg)
+       ("libvpx" ,libvpx)
+       ("icu4c" ,icu4c)
+       ("pixman" ,pixman)
+       ("pulseaudio" ,pulseaudio)
+       ("mesa" ,mesa)
+       ("mit-krb5" ,mit-krb5)
+       ;; See <https://bugs.gnu.org/32833>
+       ;;   and related comments in the 'remove-bundled-libraries' phase.
+       ;; UNBUNDLE-ME! ("nspr" ,nspr)
+       ;; UNBUNDLE-ME! ("nss" ,nss)
+       ("shared-mime-info" ,shared-mime-info)
+       ("sqlite" ,sqlite)
+       ("startup-notification" ,startup-notification)
+       ("unzip" ,unzip)
+       ("zip" ,zip)
+       ("zlib" ,zlib)))
+    (native-inputs
+     `(("patch" ,(canonical-package patch))
+       ("rust" ,rust)
+       ("cargo" ,rust "cargo")
+       ("rust-cbindgen" ,rust-cbindgen)
+       ("llvm" ,llvm)
+       ("clang" ,clang)
+       ("perl" ,perl)
+       ("node" ,node)
+       ("openssl" ,openssl) ; Required for building https-everywhere
+       ("tar" ,tar) ; for untaring extensions
+       ("util-linux" ,util-linux) ; for getopt on https-everywhere build
+       ("xxd" ,xxd) ; for https-everywhere build
+       ("python" ,python)
+       ("python2" ,python-2.7)
+       ("python2-pysqlite" ,python2-pysqlite)
+       ("yasm" ,yasm)
+       ("nasm" ,nasm)  ; XXX FIXME: only needed on x86_64 and i686
+       ("pkg-config" ,pkg-config)
+       ("autoconf" ,autoconf-2.13)
+       ("which" ,which)))
+    (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 <http://hydra.gnu.org/build/378133>.
+       ;;
+       ;; Is this needed?
+       #:validate-runpath? #f
+
+       #:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
+
+       ;; Verify which modules are actually needed.
+       #: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 'unpack-extensions
+            (lambda* (#:key inputs native-inputs #:allow-other-keys)
+              (let ((https-everywhere-archive "https-everywhere.tar.gz")
+                    (https-everywhere-srcdir "https-everywhere-src")
+                    (noscript-archive "noscript.tar.gz")
+                    (noscript-srcdir "noscript-src")
+                    (bash (which "bash")))
+
+                (setenv "SHELL" bash)
+
+                (mkdir https-everywhere-srcdir)
+                (mkdir noscript-srcdir)
+                (invoke "tar" "xf" https-everywhere-archive "--strip-components=1"
+                        "-C" https-everywhere-srcdir)
+                (invoke "tar" "xf" noscript-archive "--strip-components=1"
+                        "-C" noscript-srcdir))))
+
+         ;; Not used yet. For start-tor-browser patch and possibly others.
+         (add-after 'unpack-extensions 'apply-guix-specific-patches
+           (lambda* (#:key inputs native-inputs #:allow-other-keys)
+             (let ((patch (string-append (assoc-ref (or native-inputs inputs)
+                                                    "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))
+
+         ;; 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 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
+               (substitute* '("Cargo.lock" "gfx/wr/Cargo.lock")
+                 (("(\"checksum .* = )\".*\"" all name)
+                  (string-append name "\"" null-hash "\"")))
+               (generate-all-checksums "third_party/rust"))
+             #t))
+
+         (add-after 'build 'neutralize-store-references
+           (lambda _
+             ;; Mangle the store references to compilers & other build tools in
+             ;; about:buildconfig, reducing TorBrowser's closure significant.
+             ;; 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)
+                                          "<!-- Guix: not a runtime dependency -->"
+                                          (string-drop hash 8))))
+             #t))
+
+         (replace 'configure
+           (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (bash (which "bash"))
+                    ;; Is this needed?
+                    (flags `(,(string-append "--prefix=" 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 "MOZ_BUILD_DATE" ,%torbrowser-build-id) ; avoid timestamp.
+               (setenv "LDFLAGS" (string-append
+                                  "-Wl,-rpath="
+                                  (assoc-ref outputs "out")
+                                  "/lib/firefox"))
+
+               ;; Maybe remove --disable-strip since tor-builder strips on another step
+               ;; See tor-browser-build.git/projects/firefox/build:231.
+               ;; Add flag for changing app name to torbrowser or use this name for the start script?
+               (substitute* ".mozconfig"
+                            ;; Arch independent builddir.
+                            (("(mk_add_options MOZ_OBJDIR=@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=dev-build")
+                             (string-append "ac_add_options --with-tor-browser-version=org.gnu\n"
+                                            "ac_add_options --with-unsigned-addon-scopes=app\n"
+                                            "ac_add_options --enable-pulseaudio\n"
+                                            "ac_add_options --disable-debug-symbols\n"
+                                            "ac_add_options --disable-updater\n"
+                                            "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"
+                                            "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="
+                                            (assoc-ref %build-inputs "clang") "/bin/clang\n"
+                                            "ac_add_options --with-libclang-path="
+                                            (assoc-ref %build-inputs "clang") "/lib\n")))
+
+               ;; See tor-browser-build.git/projects/tor-browser/RelativeLink/start-tor-browser:307 on running
+               ;; with system tor instance.
+               (substitute* "browser/app/profile/000-tor-browser.js"
+                            (("(pref\\(\"network.proxy.socks_port\").*" _ m)
+                             (string-append m ", 9050);\n"))
+                            (("(pref\\(\"extensions.torbutton.loglevel\").*" _ m)
+                             (string-append m ",2);\n"))
+                            (("(pref\\(\"extensions.torbutton.logmethod\").*" _ m)
+                             (string-append m ",0);\n"))
+                            (("(pref\\(\"extensions.torbutton.inserted_button\").*" _ m)
+                             (string-append m ",true);\n"))
+                            (("(pref\\(\"extensions.torbutton.launch_warning\").*" _ m)
+                             (string-append m ",false);\n"))
+                            ;; TorBrowser updates are disabled on mozconfig, but let's make sure.
+                            (("(pref\\(\"extensions.torbutton.versioncheck_enabled\").*" _ m)
+                                (string-append m ",false);\n")))
+
+               (substitute* "browser/extensions/tor-launcher/src/defaults/preferences/torlauncher-prefs.js"
+                            (("(pref\\(\"extensions.torlauncher.start_tor\").*" _ m)
+                             (string-append m ", false);\n"))
+                            (("(pref\\(\"extensions.torlauncher.prompt_at_startup\").*" _ m)
+                             (string-append m ", false);\n"))
+                            ;; Investigate this one: "extensions.torlauncher.only_configure_tor"
+                            ;; on 'tl-util.jsm', would it be a nice addition?
+                            (("(pref\\(\"extensions.torlauncher.should_remove_meek_helper_profiles\").*" _ m)
+                             (string-append m ", false);\n"))
+                            (("(pref\\(\"extensions.torlauncher.loglevel\").*" _ m)
+                             (string-append m ", 2);\n"))
+                            (("(pref\\(\"extensions.torlauncher.logmethod\").*" _ m)
+                             (string-append m ", 0);\n"))
+                            (("(pref\\(\"extensions.torlauncher.control_port\").*" _ m)
+                             (string-append m ", 9051);\n")))
+
+               ;; For user data outside the guix store. Dirty hack. Maybe worth a patch upstream to create a
+               ;; configure flag for guix. It will create/modify permissions on 'Data' dir on $HOME. It also
+               ;; means that TorBrowser will share the Downloads dir on home and not keep its own.
+               ;; Work on start-tor-browser script to set a TorBrowser own home.
+               (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")))
+
+               ;; TODO: change prefs to block autoupdate app and extensions.
+
+               (newline)
+               (format #t "Invoking mach configure ...~%")
+               (force-output)
+               (invoke "./mach" "configure"))))
+
+         ;; Building noscript from source is failing for now. So its sources remain unused.
+         (add-after 'configure 'build-extensions
+           (lambda* (#:key inputs native-inputs #:allow-other-keys)
+             (let* ((bash (which "bash")))
+
+               (setenv "SHELL" bash)
+
+               ;; Python3.6 is hardcoded on these scripts. Using v3.8 appears to be harmless.
+               (with-directory-excursion "https-everywhere-src"
+                                         (substitute* '("install-dev-dependencies.sh"
+                                                        "make.sh"
+                                                        "hooks/precommit"
+                                                        "test/firefox.sh"
+                                                        "test/manual.sh"
+                                                        "test/script.py"
+                                                        "test/validations.sh"
+                                                        "utils/create_zip.py"
+                                                        "utils/merge-rulesets.py"
+                                                        "utils/setversion.py"
+                                                        "utils/zipfile_deterministic.py")
+                                                      (("python3.6") "python3"))
+
+                                         ;; Failing to generate the xpi, but copy-dir appears to be enough.
+                                         ;; Failing on missing 'wasm'?
+                                         (invoke "./make.sh")))))
+
+         (replace 'build
+                  (lambda _ (invoke "./mach" "build")))
+
+         ;; TorBrowser just do a stage-package here and copy files to its places.
+         (replace 'install
+           (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (builddir "objdir/dist/firefox")
+                    (libdir (string-append out "/lib/firefox"))
+                    (bindir (string-append out "/bin"))
+                    (noscript-id "{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi")
+                    (extdir (string-append libdir "/browser/extensions")))
+
+               ;; (display "string\n") should be enough here, chage this.
+               (format #t "Staging package ...~%")
+               (force-output)
+               (invoke "./mach" "build" "stage-package")
+               (format #t "Deleting spurious files ...~%")
+               (force-output)
+               ;; TorBrowser doesn't use those. See: tor-browser-build.git/projects/firefox/build:167
+               (for-each delete-file `(,(string-append builddir "/firefox-bin")
+                                       ,(string-append builddir "/libfreeblpriv3.chk")
+                                       ,(string-append builddir "/libnssdbm3.chk")
+                                       ,(string-append builddir "/libsoftokn3.chk")))
+
+               (format #t "Creating install dirs ...~%")
+               (force-output)
+               (mkdir-p libdir)
+               (mkdir bindir)
+
+               (format #t "Copying files to install dirs ...~%")
+               (force-output)
+               (copy-recursively builddir (string-append libdir "/")
+                                 #:log (%make-void-port "w"))
+
+               (format #t "Linking binary ...~%")
+               (force-output)
+               (symlink (string-append libdir "/firefox")
+                        (string-append bindir "/firefox"))
+
+               (format #t "Copying extensions to default path ...~%")
+               (force-output)
+               (mkdir-p extdir)
+               (format #t "Copying noscript ...~%")
+               (force-output)
+               (copy-file "noscript.xpi" (string-append extdir "/" noscript-id))
+               (format #t "Copying https-everywhere ...~%")
+               (force-output)
+               (if (file-exists? "https-everywhere-src/pkg/https-everywhere-2020.5.20~pre-eff.xpi")
+                   (copy-file "https-everywhere-src/pkg/https-everywhere-2020.5.20~pre-eff.xpi"
+                              (string-append extdir "/https-everywhere-eff@eff.org.xpi"))
+                   (copy-recursively "https-everywhere-src/pkg/xpi-eff"
+                                     (string-append extdir "/https-everywhere-eff@eff.org")))
+                                     #:log (%make-void-port "w")))))))
+
+         ;; Thunderbird doesn't provide any .desktop file, but TorBrowser does, however it's staged not installed, let's see.
+         ;;
+         ;; Is this needed? Try to play webmedia!
+         ;;(add-after 'install 'wrap-program
+         ;; (lambda* (#:key inputs outputs #:allow-other-keys)
+         ;;    (let* ((out (assoc-ref outputs "out"))
+         ;;           (lib (string-append out "/lib"))
+         ;;           (gtk (assoc-ref inputs "gtk+"))
+         ;;           (gtk-share (string-append gtk "/share"))
+         ;;           (pulseaudio (assoc-ref inputs "pulseaudio"))
+         ;;           (pulseaudio-lib (string-append pulseaudio "/lib")))
+         ;;      (wrap-program (car (find-files lib "^firefox$"))
+         ;;        `("XDG_DATA_DIRS" prefix (,gtk-share))
+         ;;        `("LD_LIBRARY_PATH" prefix (,pulseaudio-lib)))
+         ;;      #t))))))
+    (home-page "https://www.torproject.org")
+    (synopsis "Anonymous browser derived from Mozilla Firefox")
+    (description
+     "TorBrowser is the Tor Project version of the Firefox browser.  It is
+the only recommended way to anonymously browse the web that is supported by
+the project.  It modifies firefox in order to avoid many know application level
+attacks on the privacy of Tor users.
+
+WARNING: This is not the official TorBrowser and is currently on testing.
+If you have issues using it, do not bother Tor Developers, as it is not the
+official bundle provided by the Tor Project.  Use at your own risk and please
+report back on guix channels.  This version does not bundle @code{tor}, you need
+to configure it as a system service and set ControlPort and HashedControlPassword
+to access some features.")
+    (license license:mpl2.0)))     ;and others, see toolkit/content/license.html
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser-unbundle.
  2020-07-15 21:15 [bug#42380] [WIP] gnu: Add torbrowser-unbundle André Batista
@ 2020-07-25 14:49 ` André Batista
  2020-08-03 12:55   ` André Batista
  2020-09-12 13:35 ` [bug#42380] Wow! Raghav Gururajan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2020-07-25 14:49 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 753 bytes --]

Hello Guix,

The patch bellow adds TorBrowser, Obfs4 and related libraries. No
more warnings, it should behave as expected. User files are
stored under '~/.local/share/torbrowser'.

Just two notes: 
- some of the libraries do not have a named font and just claim
  BDS-Style. I've written bsd-2 for those and left a note. I'm
  no sure if there is need for a more appropriate description.
- https-everywhere does not show rules on the browser, but the
  rules are there on the store path. There is no default address
  for autoupdating rules.

And one important question: tor and obfs4 are inputs to torbrowser
which are symlinked in the install phase. Do they need to be
propagated so as to not be garbage collected?

Happy Hacking!

[-- Attachment #1.2: 0001-gnu-Add-torbrowser-unbundle.patch --]
[-- Type: text/plain, Size: 58824 bytes --]

From d9b11fdfa62919fc5ebfd73c55a9dbbbc12596a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Sat, 25 Jul 2020 06:11:36 -0300
Subject: [PATCH] gnu: Add torbrowser-unbundle
To: guix-patches@gnu.org

* gnu/packages/tor.scm (obfs4, torbrowser-unbundle): New variables.
* gnu/packages/golang.scm (go-torproject-org-ptlib,
go-github-com-agl-ed25519, go-github-com-dchest-siphash,
go-github-com-dchest-uniuri, go-github-com-dsnet-compress,
go-schwanenlied-me-yawning-bsaes, go-gitlab-com-yawning-utls): New variables.
* 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 +
 gnu/packages/golang.scm                       | 188 +++++
 ...torbrowser-start-tor-browser.desktop.patch |  22 +
 .../torbrowser-start-tor-browser.patch        | 184 +++++
 gnu/packages/tor.scm                          | 752 +++++++++++++++++-
 5 files changed, 1145 insertions(+), 4 deletions(-)
 create mode 100644 gnu/packages/patches/torbrowser-start-tor-browser.desktop.patch
 create mode 100644 gnu/packages/patches/torbrowser-start-tor-browser.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index f2a7b6b984..7bff822c43 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -36,6 +36,7 @@
 # Copyright © 2020 Jan Wielkiewicz <tona_kosmicznego_smiecia@interia.pl>
 # Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
 # Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
+# Copyright © 2020 André Batista <nandre@riseup.net>
 #
 # This file is part of GNU Guix.
 #
@@ -1587,6 +1588,8 @@ dist_patch_DATA =						\
   %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.patch       \
+  %D%/packages/patches/torbrowser-start-tor-browser.desktop.patch \
   %D%/packages/patches/ttf2eot-cstddef.patch			\
   %D%/packages/patches/ttfautohint-source-date-epoch.patch	\
   %D%/packages/patches/tomb-fix-errors-on-open.patch		\
diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 2c31632db6..772b1e29f2 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2019, 2020 Arun Isaac <arunisaac@systemreboot.net>
 ;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
+;;; Copyright © 2020 André Batista <nandre@riseup.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -4263,3 +4264,190 @@ used by other processes.")
 Porter2 stemmer}.  It is written completely using finite state machines to do
 suffix comparison, rather than the string-based or tree-based approaches.")
       (license license:asl2.0))))
+
+(define-public go-torproject-org-ptlib
+  (package
+   (name "go-torproject-org-ptlib")
+   (version "1.1.0")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://git.torproject.org/pluggable-transports/goptlib.git")
+           (commit (string-append "v" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "1lh938194hvkf8pqgnxwf6hvjv9rv0j3kasi07r2ckrj8sxzk4jc"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:import-path "git.torproject.org/pluggable-transports/goptlib.git"))
+   (home-page "https://git.torproject.org/pluggable-transports/goptlib.git")
+   (synopsis "Go library for Tor pluggable transports")
+   (description "Library for writing Tor pluggable transports in Go.")
+   (license license:cc0)))
+
+
+(define-public go-github-com-agl-ed25519
+  (let ((commit "c4161f4c7483313562781c61b9a20aba73daf9de")
+        (revision "0"))
+    (package
+     (name "go-github-com-agl-ed25519")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/agl/ed25519")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "1wjlbzi0w63rmlzgk3amw274wsl0zhcn4yx2lraffbkhqappahxc"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/agl/ed25519"
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'reset-gzip-timestamps 'make-files-writable
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let ((out (assoc-ref outputs "out")))
+                   (for-each (lambda (file) (chmod file #o644))
+                     (find-files out "\\.gz"))
+             #t))))))
+     (home-page "https://github.com/agl/ed25519")
+     (synopsis "Go library for ed25519")
+     (description "This library is used in the implementation of obfs4.")
+     (license license:bsd-2))));; Repo does not contain license anymore.
+                               ;; Only refered on file as BSD-Style.
+
+(define-public go-github-com-dchest-siphash
+  (let ((commit "34f201214d993633bb24f418ba11736ab8b55aa7")
+        (revision "0"))
+    (package
+     (name "go-github-com-dchest-siphash")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dchest/siphash")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "08s076y7vmjqnq7jz0762hkm896r6r31v8b31a3gy0n8rfa01k8k"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dchest/siphash"))
+     (home-page "https://github.com/dchest/siphash")
+     (synopsis "Go library for siphash")
+     (description "Go implementation of SipHash-2-4, a fast short-input PRF
+created by Jean-Philippe Aumasson and Daniel J. Bernstein.")
+     (license license:cc0))))
+
+(define-public go-github-com-dchest-uniuri
+  (let ((commit "8902c56451e9b58ff940bbe5fec35d5f9c04584a")
+        (revision "0"))
+    (package
+     (name "go-github-com-dchest-uniuri")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dchest/uniuri")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "1x5bsbm1nlphsv96zd0rbclfaa1swpz5bp14x7s5dbxp0awk2gd4"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dchest/uniuri"))
+     (home-page "https://github.com/dchest/uniuri")
+     (synopsis "Go library for random URIs")
+     (description "Package uniuri generates random strings good for use in
+URIs to identify unique objects.")
+     (license license:cc0))))
+
+(define-public go-github-com-dsnet-compress
+  (let ((commit "cc9eb1d7ad760af14e8f918698f745e80377af4f")
+        (revision "0"))
+    (package
+     (name "go-github-com-dsnet-compress")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dsnet/compress")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "159liclywmyb6zx88ga5gn42hfl4cpk1660zss87fkx31hdq9fgx"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dsnet/compress"))
+     (home-page "https://github.com/dsnet/compress")
+     (synopsis "Go library for extended compression")
+     (description "This is a collection of compression related libraries.
+The goal of this project is to provide pure Go implementations for popular
+compression algorithms bey ond what the Go standard library provides.")
+     (license license:bsd-2))));; Unnamed. Go license?
+
+(define-public go-schwanenlied-me-yawning-bsaes
+  (let ((commit "26d1add596b6d800bdeeb3bc3b2c7b316c056b6d")
+        (revision "0"))
+    (package
+     (name "go-schwanenlied-me-yawning-bsaes")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.schwanenlied.me/yawning/bsaes.git")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "0h4dsyw54n9rcwprqy93wv2v1gcvlq1vfqdp1g7wxdkq457rhvys"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "git.schwanenlied.me/yawning/bsaes.git"))
+     (home-page "https://git.schwanenlied.me/yawning/bsaes.git")
+     (synopsis "Go AES library")
+     (description "Portable pure-Go constant time AES implementation based on
+the excellent code from [BearSSL](https://bearssl.org/).  On AMD64 systems
+with AES-NI and a sufficiently recent Go runtime, it will transparently call
+crypto/aes when NewCipher is invoked.")
+     (license license:bsd-2))));; Also unnamed.
+
+(define-public go-gitlab-com-yawning-utls
+  (package
+   (name "go-gitlab-com-yawning-utls")
+   (version "0.0.10-1")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://gitlab.com/yawning/utls.git")
+           (commit (string-append "v" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "15c46s56r45n22rmq9spnczydnkqrnxff28h5mpnk5yvcqif3lgb"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:tests? #f ;; Tries to connect and fails.
+      #:import-path "gitlab.com/yawning/utls.git"))
+   (propagated-inputs
+    `(("go-schwanenlied-me-yawning-bsaes" ,go-schwanenlied-me-yawning-bsaes)
+      ("go-github-com-dsnet-compress" ,go-github-com-dsnet-compress)
+      ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)))
+   (home-page "https://gitlab.com/yawning/utls.git")
+   (synopsis "Go library for UTLS")
+   (description "UTLS fork for the specific purpose of improving obfs4proxy's
+meek_lite transport.")
+   (license license:gpl3+)))
diff --git a/gnu/packages/patches/torbrowser-start-tor-browser.desktop.patch b/gnu/packages/patches/torbrowser-start-tor-browser.desktop.patch
new file mode 100644
index 0000000000..e65348b7f5
--- /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/projects/tor-browser/RelativeLink/start-tor-browser.desktop.orig    2020-07-05 18:47:40.689484877 -0300
++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/projects/tor-browser/RelativeLink/start-tor-browser.desktop 2020-07-24 14:36:37.720579884 -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 shell.
+ # It preserves arguments and environment for the start-tor-browser script.
+@@ -28,7 +28,7 @@
+ GenericName=Web Browser
+ Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
+ Categories=Network;WebBrowser;Security;
+-Exec=sh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/start-tor-browser --detach)' dummy %k
+-X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
+-Icon=web-browser
++Exec=bash -c start-tor-browser
++X-TorBrowser-ExecShell=start-tor-browser --detach
++Icon=torbrowser
+ StartupWMClass=Tor 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..e3e29e61ed
--- /dev/null
+++ b/gnu/packages/patches/torbrowser-start-tor-browser.patch
@@ -0,0 +1,184 @@
+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,<dir>fonts</dir>,<dir>${TBB_STORE_PATH}/fonts</dir>,"
++
+ cd "${HOME}"
+ 
+ # We pass all additional command-line arguments we get to Firefox.
+@@ -357,23 +329,23 @@
+ 
+ if [ "$show_usage" -eq 1 ]; then
+     # Display Firefox help, then our help
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default --help 2>/dev/null
++    TOR_CONTROL_PASSWD=${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=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-       -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++       -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
+     disown "$!"
+ elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
+         tee "$logfile"
+ elif [ "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" < /dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" < /dev/null
+ else
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
+ fi
+ 
+ exit $?
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index c852c54a5b..4fe3f69ef3 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -28,28 +28,69 @@
 
 (define-module (gnu packages tor)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
+  #:use-module (guix monads)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix store)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix build-system cargo)
+  #:use-module (guix build-system go)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages assembly)
+  #:use-module (gnu packages audio)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
-  #:use-module (gnu packages libevent)
-  #:use-module (gnu packages linux)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cups)
+  #:use-module (gnu packages databases)
+  #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages gl)
+  #:use-module (gnu packages glib)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages golang)
+  #:use-module (gnu packages gtk)
+  #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages image)
+  #:use-module (gnu packages kerberos)
+  #:use-module (gnu packages libcanberra)
+  #:use-module (gnu packages libevent)
+  #:use-module (gnu packages libffi)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu packages llvm)
+  #:use-module (gnu packages node)
+  #:use-module (gnu packages nss)
   #:use-module (gnu packages pcre)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-crypto)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages qt)
-  #:use-module (gnu packages autotools)
+  #:use-module (gnu packages readline)
+  #:use-module (gnu packages rsync) ; for httpse
+  #:use-module (gnu packages rust)
+  #:use-module (gnu packages rust-apps)
+  #:use-module (gnu packages sqlite)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages w3m))
+  #:use-module (gnu packages video)
+  #:use-module (gnu packages vim) ; for xxd
+  #:use-module (gnu packages w3m)
+  #:use-module (gnu packages xdisorg)
+  #:use-module (gnu packages xiph)
+  #:use-module (gnu packages xorg)
+  #:use-module (gnu packages xml) ; for httpse
+  #:use-module (ice-9 match)
+  #:use-module ((srfi srfi-1) #:hide (zip)))
 
 (define-public tor
   (package
@@ -324,3 +365,706 @@ statistics and status reports on:
 
 Potential client and exit connections are scrubbed of sensitive information.")
     (license license:gpl3+)))
+
+(define-public obfs4
+  (package
+   (name "obfs4")
+   (version "0.0.11")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://git.torproject.org/pluggable-transports/obfs4.git")
+           (commit (string-append "obfs4proxy-" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "1y2kjwrk64l1h8b87m4iqsanib5rn68gzkdri1vd132qrlypycjn"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:import-path "git.torproject.org/pluggable-transports/obfs4.git"
+      #:tests? #f ;; No test files
+      #:phases
+      (modify-phases %standard-phases
+        (replace 'build
+          (lambda* (#:key outputs configure-flags #:allow-other-keys)
+            (let ((out (assoc-ref outputs "out")))
+              (copy-recursively
+               "src/git.torproject.org/pluggable-transports/obfs4.git"
+               "src/gitlab.com/yawning/obfs4.git"
+               #:log (%make-void-port "w"))
+              (with-directory-excursion
+               "src/git.torproject.org/pluggable-transports/obfs4.git/obfs4proxy"
+               (invoke "go" "build" "-ldflags" "-s"))
+            #t)))
+        (replace 'install
+          (lambda* (#:key outputs #:allow-other-keys)
+            (let* ((out (assoc-ref outputs "out"))
+                   (srcdir
+                    "src/git.torproject.org/pluggable-transports/obfs4.git")
+                   (bindir (string-append out "/bin"))
+                   (sharedir (string-append out "/share/"))
+                   (docdir (string-append sharedir "/doc"))
+                   (mandir (string-append out "/man/man1")))
+              (mkdir-p mandir)
+              (mkdir-p bindir)
+              (mkdir-p docdir)
+              (with-directory-excursion
+               (string-append srcdir "/obfs4proxy")
+               (copy-file "obfs4proxy"
+                          (string-append bindir "/obfs4proxy")))
+              (with-directory-excursion
+               (string-append srcdir "/doc")
+               (copy-file "obfs4proxy.1"
+                          (string-append mandir "/obfs4proxy.1"))
+               (copy-file "obfs4-spec.txt"
+                          (string-append docdir "/obfs4-spec.txt")))
+            #t))))))
+   (propagated-inputs
+    `(("go-torproject-org-ptlib" ,go-torproject-org-ptlib)
+      ;; Currently uses this, but the readme on github is pointing
+      ;; users to start relying on x/crypto/ed25519 instead.
+      ("go-github-com-agl-ed25519" ,go-github-com-agl-ed25519)
+      ("go-github-com-dchest-siphash" ,go-github-com-dchest-siphash)
+      ("go-github-com-dchest-uniuri" ,go-github-com-dchest-uniuri)
+      ("go-github-com-dsnet-compress" ,go-github-com-dsnet-compress)
+      ("go-schwanenlied-me-yawning-bsaes" ,go-schwanenlied-me-yawning-bsaes)
+      ("go-gitlab-com-yawning-utls" ,go-gitlab-com-yawning-utls)
+      ("go-golang-org-x-net" ,go-golang-org-x-net)
+      ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)
+      ("go-golang-org-x-text" ,go-golang-org-x-text)))
+   (home-page "https://git.torproject.org/pluggable-transports/obfs4.git")
+   (synopsis "Obfs4 implements an obfuscation protocol")
+   (description "This is a look-like nothing obfuscation protocol that
+incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol.
+The obfs naming was chosen primarily because it was shorter, in terms of
+protocol ancestery obfs4 is much closer to ScrambleSuit than obfs2/obfs3.")
+   (license license:gpl3+)))
+
+(define* (computed-origin-method gexp-promise hash-algo hash
+                                 #:optional (name "source")
+                                 #:key (system (%current-system))
+                                 (guile (default-guile)))
+  "Return a derivation that executes the G-expression that results
+from forcing GEXP-PROMISE."
+  (mlet %store-monad ((guile (package->derivation guile system)))
+    (gexp->derivation (or name "computed-origin")
+                      (force gexp-promise)
+                      #:graft? #f       ;nothing to graft
+                      #:system system
+                      #:guile-for-build guile)))
+
+;; Fonts for TorBrowser. Avoid downloading 4Gb+ git repo on
+;; https://github.com/googlei18n/noto-fonts.git to use just a handful.
+;; Use the fonts on TorBrowser package.
+(define torbrowser-fonts
+  (package
+   (name "torbrowser-fonts")
+   (version "9.5.1")
+   (source (origin
+            (method url-fetch)
+            (uri (string-append "https://dist.torproject.org/torbrowser/"
+                                version "/tor-browser-linux64-"
+                                version "_en-US.tar.xz"))
+            (sha256
+             (base32
+              "18xv8pv2j55f78n4d7cz24zwhqlcxkpq8nbanl754k2k0s1w34dd"))))
+   (build-system trivial-build-system)
+   (native-inputs
+    `(("tar" ,tar)
+      ("xz" ,xz)))
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (let ((src (assoc-ref %build-inputs "source"))
+                        (src-dir "tor-browser_en-US/Browser/fonts")
+                        (install-dir (string-append %output "/fonts"))
+                        (tar (assoc-ref %build-inputs "tar"))
+                        (xz (assoc-ref %build-inputs "xz")))
+
+                    (mkdir-p install-dir)
+                    (format #t "Untaring torbrowser ball ...~%")
+                    (invoke (string-append tar "/bin/tar") "-xf" src
+                            "-C" install-dir "--strip-components=3"
+                            (string-append "--use-compress-program=" xz "/bin/xz")
+                            src-dir)
+                    #t))))
+   (home-page "https://github.com/googlei18n/noto-fonts")
+   (synopsis "TorBrowser bundled fonts")
+   (description "Free fonts bundled with TorBrowser.  Includes a subset of Noto,
+Arimo, Cousine, Tinos and STIX fonts.")
+   (license license:silofl1.1)))
+
+(define %torbrowser-version "68.10.0esr-9.5-1")
+(define %torbrowser-build-id "20200709000000") ;must be of the form YYYYMMDDhhmmss
+
+;; (Un)fortunatly TorBrowser has it's own reproducible build system - RBM - which
+;; automates the build process for them and compiles TorBrowser from a range of
+;; repositories and produces a range of tarballs for different architectures and
+;; locales. So we need to cherry-pick what is needed for guix and produce our own
+;; tarball. See https://gitweb.torproject.org/builders/tor-browser-build.git/projects/\
+;; {tor-browser,firefox}/{build,config} for the rationale applied here. See also
+;; the Hacking on TorBrowser document for a high level introduction at
+;; https://trac.torproject.org/projects/tor/wiki/doc/TorBrowser/Hacking).
+;;
+;; TODO: Import langpacks.
+(define torbrowser-source
+  (let* ((torbrowser-commit "75c2bb720d4ceb76231e8ecc3455754bf05ba19b")
+         (torbrowser-version %torbrowser-version)
+         (upstream-torbrowser-source
+          (origin
+            (method git-fetch)
+            (uri (git-reference
+                  (url "https://git.torproject.org/tor-browser.git")
+                  (commit torbrowser-commit)))
+            (file-name (git-file-name "tor-browser" torbrowser-version))
+            (sha256
+             (base32
+              "19sk46k2bqa72il46pdl534nk2g3fi6l7m7kbglddccxv19ck0k4"))))
+
+         (torbrowser-build-commit "e94ba3a7677f7051a14b2304427ec8393a450fdc")
+         (torbrowser-build-version "9.5")
+         (upstream-torbrowser-build-source
+          (origin
+            (method git-fetch)
+            (uri (git-reference
+                  (url "https://git.torproject.org/builders/tor-browser-build.git")
+                  (commit torbrowser-build-commit)))
+            (file-name (git-file-name "tor-browser-build"
+                                      torbrowser-build-version))
+            (sha256
+             (base32
+              "1jgkrsckcjgr1lgcwahzdrcasmpghs2ppz6w80fya89pa5d6r0gv"))))
+
+         (torbutton-commit "ebe2bedab44e38f18c7968bd327d99eef7660f34")
+         (torbutton-version "9.5")
+         (upstream-torbutton-source
+          (origin
+            (method git-fetch)
+            (uri (git-reference
+                  (url "https://git.torproject.org/torbutton.git")
+                  (commit torbutton-commit)))
+            (file-name (git-file-name "torbutton" torbutton-version))
+            (sha256
+             (base32
+              "03xdyszab1a8j98xv6440v4lq58jkfqgmhxc2a62qz8q085d2x83"))))
+
+         (tor-launcher-commit "b4838d339a84c5ebebd91a0ba6b22d44ecda97b1")
+         (tor-launcher-version "0.2.21")
+         (upstream-tor-launcher-source
+          (origin
+            (method git-fetch)
+            (uri (git-reference
+                  (url "https://git.torproject.org/tor-launcher.git")
+                  (commit tor-launcher-commit)))
+            (file-name (git-file-name "tor-launcher" tor-launcher-version))
+            (sha256
+             (base32
+              "0xxwyw1j6dkm2a24kg1564k701p5ikfzs1f9n0gflvlzz9427haf"))))
+
+         (https-everywhere-version "2020.5.20")
+         (upstream-https-everywhere-source
+          (origin
+            (method url-fetch)
+            (uri (string-append "https://github.com/EFForg/https-everywhere/archive/"
+                                https-everywhere-version ".tar.gz"))
+            (sha256
+             (base32
+              "027lga3z0a4d7s95id861das7g0k29p7pqh9xd77jm87f7w4l763"))))
+
+         (noscript-xpi-version "11.0.34")
+         (upstream-noscript-xpi
+          (origin
+            (method url-fetch)
+            (uri (string-append "https://secure.informaction.com/download/releases/noscript-"
+                                noscript-xpi-version ".xpi"))
+            (sha256
+             (base32
+              "0y45925ms2bk9d42zbgwcdb2sif8kqlbaflkz15q08gi7vgki6km")))))
+
+    ;; Now we bundle the grabbed sources.
+    (origin
+      (method computed-origin-method)
+      (file-name (string-append "torbrowser-" %torbrowser-version ".tar.xz"))
+      (sha256 #f)
+      (uri
+       (delay
+         (with-imported-modules '((guix build utils))
+          #~(begin
+              (use-modules (guix build utils))
+              (let ((torbrowser-dir (string-append "torbrowser-"
+                                                   #$torbrowser-version))
+                    (torbutton-dir "toolkit/torproject/torbutton")
+                    (tor-launcher-dir "browser/extensions/tor-launcher")
+                    (tbb-scripts-dir "tbb-scripts")
+                    (https-everywhere "https-everywhere.tar.gz")
+                    (noscript-xpi "noscript.xpi"))
+
+                (set-path-environment-variable
+                 "PATH" '("bin")
+                 (list #+(canonical-package bash)
+                       #+(canonical-package xz)
+                       #+(canonical-package tar)))
+
+                (format #t "Copying torbrowser source to writable path ...~%")
+                (force-output)
+                (copy-recursively #+upstream-torbrowser-source
+                                  torbrowser-dir
+                                  #:log (%make-void-port "w"))
+
+                (with-directory-excursion torbrowser-dir
+                  (format #t "Copying torbutton source to torbrowser...~%")
+                  (force-output)
+                  (make-file-writable torbutton-dir)
+                  (copy-recursively #+upstream-torbutton-source
+                                    torbutton-dir
+                                    #:log (%make-void-port "w"))
+
+                  (format #t "Copying tor-launcher source to torbrowser...~%")
+                  (force-output)
+                  (copy-recursively #+upstream-tor-launcher-source
+                                    tor-launcher-dir
+                                    #:log (%make-void-port "w"))
+
+                  (format #t "Copying tor-browser-build source to torbrowser...~%")
+                  (force-output)
+                  (mkdir tbb-scripts-dir)
+                  (copy-recursively #+upstream-torbrowser-build-source
+                                    tbb-scripts-dir
+                                    #:log (%make-void-port "w"))
+
+                  (format #t "Copying https-everywhere source to torbrowser...~%")
+                  (force-output)
+                  (copy-file #+upstream-https-everywhere-source
+                             https-everywhere)
+
+                  (format #t "Copying noscript xpi to torbrowser...~%")
+                  (force-output)
+                  (copy-file #+upstream-noscript-xpi
+                             "noscript.xpi"))
+
+                (invoke "tar" "cvfa" #$output
+                        ;; Avoid non-determinism in the archive.
+                        "--mtime=@315619200" ; 1980-01-02 UTC
+                        "--owner=root:0"
+                        "--group=root:0"
+                        "--sort=name"
+                        torbrowser-dir)
+              #t))))))))
+
+(define-public torbrowser-unbundle
+  (package
+    (name "torbrowser-unbundle")
+    (version %torbrowser-version)
+    (source torbrowser-source)
+    (build-system gnu-build-system)
+    (inputs
+     `(("alsa-lib" ,alsa-lib)
+       ("bzip2" ,bzip2)
+       ("cups" ,cups)
+       ("dbus-glib" ,dbus-glib)
+       ("ffmpeg" ,ffmpeg)
+       ("freetype" ,freetype)
+       ("gdk-pixbuf" ,gdk-pixbuf)
+       ("glib" ,glib)
+       ("gtk+" ,gtk+)
+       ("gtk+-2" ,gtk+-2)
+       ("graphite2" ,graphite2)
+       ("harfbuzz" ,harfbuzz)
+       ("icu4c" ,icu4c)
+       ("libcanberra" ,libcanberra)
+       ("libgnome" ,libgnome)
+       ("libjpeg-turbo" ,libjpeg-turbo)
+       ("libogg" ,libogg)
+       ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
+       ("libvorbis" ,libvorbis)
+       ("libxft" ,libxft)
+       ("libevent" ,libevent)
+       ("libxinerama" ,libxinerama)
+       ("libxscrnsaver" ,libxscrnsaver)
+       ("libxcomposite" ,libxcomposite)
+       ("libxt" ,libxt)
+       ("libffi" ,libffi)
+       ("libvpx" ,libvpx)
+       ("mesa" ,mesa)
+       ("mit-krb5" ,mit-krb5)
+       ;; See <https://bugs.gnu.org/32833>
+       ;;   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)
+       ("zlib" ,zlib)))
+    (native-inputs
+     `(("autoconf" ,autoconf-2.13)
+       ("cargo" ,rust "cargo")
+       ("clang" ,clang)
+       ("libxml2" ,libxml2) ; for https-e
+       ("libxslt" ,libxslt) ; for https-e
+       ("llvm" ,llvm)
+       ("openssl" ,openssl) ; For hash+sig on https-everywhere
+       ("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)
+       ("rsync" ,rsync) ; for https-e build
+       ("rust" ,rust)
+       ("rust-cbindgen" ,rust-cbindgen)
+       ("tar" ,tar) ; for untaring extensions
+       ("torbrowser-fonts" ,torbrowser-fonts)
+       ("util-linux" ,util-linux) ; for getopt on https-everywhere build
+       ("which" ,which)
+       ("xxd" ,xxd) ; for https-everywhere build
+       ("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 <http://hydra.gnu.org/build/378133>.
+       #:validate-runpath? #f
+
+       #:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
+
+       #: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 'unpack-extensions
+           (lambda* (#:key inputs native-inputs #:allow-other-keys)
+             (let ((https-everywhere-archive "https-everywhere.tar.gz")
+                   (https-everywhere-srcdir "https-everywhere-src")
+                   (bash (which "bash")))
+               (setenv "SHELL" bash)
+               (mkdir https-everywhere-srcdir)
+               (invoke "tar" "xf" https-everywhere-archive
+                       "--strip-components=1" "-C" https-everywhere-srcdir))
+             #t))
+
+         (add-after 'unpack-extensions 'apply-guix-specific-patches
+           (lambda* (#:key inputs native-inputs #:allow-other-keys)
+             (let ((patch (string-append (assoc-ref (or native-inputs inputs)
+                                                    "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))
+
+         ;; 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 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
+               (substitute* '("Cargo.lock" "gfx/wr/Cargo.lock")
+                 (("(\"checksum .* = )\".*\"" all name)
+                  (string-append name "\"" null-hash "\"")))
+               (generate-all-checksums "third_party/rust"))
+             #t))
+
+         (add-after 'build 'neutralize-store-references
+           (lambda _
+             ;; Mangle the store references to compilers & other build tools in
+             ;; about:buildconfig, reducing TorBrowser's closure significant.
+             ;; 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)
+                                          "<!-- Guix: not a runtime dependency -->"
+                                          (string-drop hash 8))))
+             #t))
+
+         (replace 'configure
+           (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (bash (which "bash"))
+                    (flags `(,(string-append "--prefix=" 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 "MOZ_BUILD_DATE" ,%torbrowser-build-id) ; avoid timestamp.
+               (setenv "LDFLAGS" (string-append
+                                  "-Wl,-rpath="
+                                  (assoc-ref outputs "out")
+                                  "/lib/firefox"))
+
+               (substitute* ".mozconfig"
+                 ;; Arch independent builddir.
+                 (("(mk_add_options MOZ_OBJDIR=@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=dev-build")
+                  (string-append "ac_add_options --with-tor-browser-version=org.gnu\n"
+                                 "ac_add_options --with-unsigned-addon-scopes=app\n"
+                                 "ac_add_options --enable-pulseaudio\n"
+                                 "ac_add_options --disable-debug-symbols\n"
+                                 "ac_add_options --disable-updater\n"
+                                 "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"
+                                 "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="
+                                  (assoc-ref %build-inputs "clang") "/bin/clang\n"
+                                 "ac_add_options --with-libclang-path="
+                                  (assoc-ref %build-inputs "clang") "/lib\n")))
+
+               (substitute* "browser/app/profile/000-tor-browser.js"
+                 ;; TorBrowser updates are disabled on mozconfig, but let's make sure.
+                 (("(pref\\(\"extensions.torbutton.versioncheck_enabled\").*" _ m)
+                  (string-append m ",false);\n")))
+
+               (substitute* "browser/extensions/tor-launcher/src/defaults/preferences/torlauncher-prefs.js"
+                 ;; Not multilingual. See tor-browser/build:141. Currently disabled on
+                 ;; tor-launcher, but let's make sure while missing langpacks.
+                 (("(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))
+
+         (add-after 'configure 'build-extensions
+           (lambda* (#:key inputs native-inputs #:allow-other-keys)
+             (let ((bash (which "bash")))
+               (setenv "SHELL" bash)
+               ;; Python3.6 is hardcoded on these scripts. Using v3.8 appears to
+               ;; be harmless.
+               (with-directory-excursion "https-everywhere-src"
+                 (substitute* '("install-dev-dependencies.sh"
+                                "make.sh"
+                                "hooks/precommit"
+                                "test/firefox.sh"
+                                "test/manual.sh"
+                                "test/script.py"
+                                "test/validations.sh"
+                                "utils/create_zip.py"
+                                "utils/merge-rulesets.py"
+                                "utils/setversion.py"
+                                "utils/zipfile_deterministic.py")
+                   (("python3.6") "python3"))
+
+                 ;; Failing to generate the xpi, but copy-dir appears to be enough.
+                 ;; Failing on missing 'wasm'? Not generating rulesets.
+                 (invoke "./make.sh")))
+             #t))
+
+         (replace 'build
+                  (lambda _ (invoke "./mach" "build")))
+
+         ;; TorBrowser just do a stage-package here and copy files to its places.
+         (replace 'install
+           (lambda* (#:key inputs native-inputs outputs
+                     #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (applications (string-append out "/share/applications"))
+                    (builddir "objdir/dist/firefox")
+                    (bindir (string-append out "/bin"))
+                    (libdir (string-append out "/lib/firefox"))
+                    (extdir (string-append libdir "/browser/extensions"))
+                    (tordir (string-append libdir "/TorBrowser/Tor"))
+                    (ptdir (string-append tordir "/PluggableTransports"))
+                    (tbbscripts-dir "tbb-scripts/projects/tor-browser")
+                    (ptconfigsdir (string-append
+                                   tbbscripts-dir
+                                   "/Bundle-Data/PTConfigs"))
+                    (torbrowser-fonts (or (assoc-ref native-inputs
+                                                     "torbrowser-fonts")
+                                          (assoc-ref inputs
+                                                     "torbrowser-fonts")))
+                    (obfs4bin (string-append
+                               (assoc-ref inputs "obfs4")
+                               "/bin/obfs4proxy"))
+                    (torbin (string-append
+                             (assoc-ref inputs "tor")
+                             "/bin/tor"))
+                    (tbb-start-script (string-append
+                                       tbbscripts-dir
+                                       "/RelativeLink/start-tor-browser"))
+                    (tbb-desktop (string-append
+                                  tbbscripts-dir
+                                  "/RelativeLink/start-tor-browser.desktop"))
+                    (tbbdocs-in (string-append tbbscripts-dir
+                                               "/Bundle-Data/Docs"))
+                    (tbbdocs-out (string-append libdir
+                                                "/TorBrowser/Docs"))
+                    (tordata-in (string-append
+                                 tbbscripts-dir
+                                 "/Bundle-Data/linux/Data"))
+                    (tordata-out (string-append libdir
+                                                "/TorBrowser/Data"))
+                    (noscript-id "{73a6fe31-595d-460b-a920-fcc0f8843232}")
+                    (httpse-id "https-everywhere-eff@eff.org"))
+               ;; Stage-package
+               (format #t "Staging package ...~%")
+               (invoke "./mach" "build" "stage-package")
+               ;; Now we start moving files to its default paths.
+               (format #t "Deleting spurious files ...~%")
+               ;; TorBrowser doesn't use those.
+               ;; See: tor-browser-build.git/projects/firefox/build:167
+               (with-directory-excursion
+                builddir
+                (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" "libnssdbm3.chk"
+                            "libsoftokn3.chk" "fonts/TwemojiMozilla.ttf")))
+               (rmdir (string-append builddir "/fonts"))
+
+               (format #t "Creating install dirs ...~%")
+               (mkdir-p libdir)
+               (mkdir bindir)
+               (mkdir-p applications)
+               (mkdir-p tordir)
+               (mkdir-p ptdir)
+               (mkdir-p tordata-out)
+               (mkdir-p tbbdocs-out)
+               (mkdir-p extdir)
+               (format #t "Copying files to install dirs ...~%")
+               (copy-recursively builddir (string-append libdir "/")
+                                 #:log (%make-void-port "w"))
+               (copy-file tbb-start-script
+                          (string-append libdir "/start-tor-browser"))
+               (chmod (string-append libdir "/start-tor-browser") #o555)
+               (copy-file tbb-desktop
+                          (string-append libdir
+                                         "/start-tor-browser.desktop"))
+               (chmod (string-append libdir
+                                     "/start-tor-browser.desktop") #o555)
+               (install-file tbb-desktop applications)
+               (with-directory-excursion
+                (string-append libdir "/browser/chrome/icons/default")
+                (for-each
+                 (lambda (file)
+                   (let* ((size (string-filter char-numeric? file))
+                          (icons (string-append out "/share/icons/hicolor/"
+                                                size "x" size "/apps")))
+                     (mkdir-p icons)
+                     (copy-file file (string-append icons "/torbrowser.png"))))
+                 '("default16.png" "default32.png" "default48.png" "default64.png"
+                   "default128.png")))
+
+               (format #t "Linking start-tor-browser script ...~%")
+               (symlink (string-append libdir "/start-tor-browser")
+                        (string-append bindir "/start-tor-browser"))
+               (format #t "Copying fonts to install dirs ...~%")
+               (copy-recursively torbrowser-fonts
+                                 (string-append libdir "/")
+                                 #:log (%make-void-port "w"))
+               (format #t "Linking store tor binary ...~%")
+               (symlink torbin (string-append tordir
+                                              "/tor"))
+               (format #t "Linking store obfs4 binary ...~%")
+               (symlink obfs4bin (string-append ptdir
+                                                "/obfs4proxy"))
+               (format #t "Copying Bundle-Data to default path ...~%")
+               (with-directory-excursion
+                tordata-in
+                (for-each (lambda (file)
+                            (copy-recursively file
+                                              (string-append
+                                               tordata-out "/" file)
+                                              #:log (%make-void-port "w")))
+                          '("Browser" "fontconfig" "Tor")))
+               (copy-file (string-append ptconfigsdir
+                                         "/linux/torrc-defaults-appendix")
+                          (string-append tordata-out
+                                         "/Tor/torrc-defaults-appendix"))
+               (copy-file (string-append ptconfigsdir
+                                         "/bridge_prefs.js")
+                          (string-append tordata-out
+                                         "/Browser/bridge-prefs-js-appendix"))
+
+               (format #t "Copying licenses and changelog to default path ...~%")
+               (copy-recursively tbbdocs-in
+                                 (string-append tbbdocs-out "/")
+                                 #:log (%make-void-port "w"))
+
+               (format #t "Copying noscript ...~%")
+               (copy-file "noscript.xpi" (string-append
+                                          extdir "/" noscript-id ".xpi"))
+               (format #t "Copying https-everywhere ...~%")
+               (if (file-exists?
+                    "https-everywhere-src/pkg/https-everywhere-2020.5.20~pre-eff.xpi")
+                   (copy-file
+                    "https-everywhere-src/pkg/https-everywhere-2020.5.20~pre-eff.xpi"
+                    (string-append extdir "/" httpse-id ".xpi"))
+                   (copy-recursively "https-everywhere-src/pkg/xpi-eff"
+                                     (string-append extdir "/" httpse-id)
+                                     #:log (%make-void-port "w"))))
+             #t)))))
+    (home-page "https://www.torproject.org")
+    (synopsis "Anonymous browser derived from Mozilla Firefox")
+    (description
+     "TorBrowser is the Tor Project version of Firefox browser.  It is the only
+recommended way to anonymously browse the web that is supported by the project.
+It modifies Firefox in order to avoid many know application level attacks on
+the privacy of Tor users.
+
+WARNING: This is not the official TorBrowser 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
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser-unbundle.
  2020-07-25 14:49 ` [bug#42380] [PATCH] " André Batista
@ 2020-08-03 12:55   ` André Batista
  2020-09-07 14:13     ` Ludovic Courtès
  0 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2020-08-03 12:55 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 431 bytes --]

Hello Guix,

This patch upgrades Tor Browser to version 9.5.3. I've also took this
opportunity to rework the code in order to improve readability, make
code review and maintainance easier and lower build time.

Main changes:
- No longer relies on computed-origin-method
- Private package definitions
- Chopped down install phase
- New phases
- More detailed go library package descriptions
- Reviewed license definitions

Cheers,


[-- Attachment #1.2: 0001-gnu-Add-torbrowser-unbundle.patch --]
[-- Type: text/plain, Size: 64918 bytes --]

From 2075c6a93a6b1918305323b369318425e05fc4f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Mon, 3 Aug 2020 09:29:55 -0300
Subject: [PATCH] gnu: Add torbrowser-unbundle
To: guix-patches@gnu.org

* gnu/packages/tor.scm (obfs4, torbrowser-unbundle): New variables.
* gnu/packages/golang.scm (go-torproject-org-ptlib,
go-github-com-agl-ed25519, go-github-com-dchest-siphash,
go-github-com-dchest-uniuri, go-github-com-dsnet-compress,
go-schwanenlied-me-yawning-bsaes, go-gitlab-com-yawning-utls): New variables.
* 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 +
 gnu/packages/golang.scm                       | 201 +++++
 ...torbrowser-start-tor-browser.desktop.patch |  22 +
 .../torbrowser-start-tor-browser.patch        | 226 +++++
 gnu/packages/tor.scm                          | 824 +++++++++++++++++-
 5 files changed, 1272 insertions(+), 4 deletions(-)
 create mode 100644 gnu/packages/patches/torbrowser-start-tor-browser.desktop.patch
 create mode 100644 gnu/packages/patches/torbrowser-start-tor-browser.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index f1a6c6a0d0..ccdcdc8e6a 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -36,6 +36,7 @@
 # Copyright © 2020 Jan Wielkiewicz <tona_kosmicznego_smiecia@interia.pl>
 # Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
 # Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
+# Copyright © 2020 André Batista <nandre@riseup.net>
 #
 # This file is part of GNU Guix.
 #
@@ -1587,6 +1588,8 @@ dist_patch_DATA =						\
   %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.patch       \
+  %D%/packages/patches/torbrowser-start-tor-browser.desktop.patch \
   %D%/packages/patches/ttf2eot-cstddef.patch			\
   %D%/packages/patches/ttfautohint-source-date-epoch.patch	\
   %D%/packages/patches/tomb-fix-errors-on-open.patch		\
diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 2c31632db6..63b090fbd8 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2019, 2020 Arun Isaac <arunisaac@systemreboot.net>
 ;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
+;;; Copyright © 2020 André Batista <nandre@riseup.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -4263,3 +4264,203 @@ used by other processes.")
 Porter2 stemmer}.  It is written completely using finite state machines to do
 suffix comparison, rather than the string-based or tree-based approaches.")
       (license license:asl2.0))))
+
+(define-public go-torproject-org-ptlib
+  (package
+   (name "go-torproject-org-ptlib")
+   (version "1.1.0")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://git.torproject.org/pluggable-transports/goptlib.git")
+           (commit (string-append "v" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "1lh938194hvkf8pqgnxwf6hvjv9rv0j3kasi07r2ckrj8sxzk4jc"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:import-path "git.torproject.org/pluggable-transports/goptlib.git"))
+   (home-page "https://git.torproject.org/pluggable-transports/goptlib.git")
+   (synopsis "Go library for Tor Pluggable Transports")
+   (description "Library for writing Tor Pluggable Transports in Go.  Pluggable
+Transports are a means of connecting to the Tor Network from places where it
+is censored.")
+   (license license:cc0)))
+
+(define-public go-github-com-agl-ed25519
+  (let ((commit "c4161f4c7483313562781c61b9a20aba73daf9de")
+        (revision "0"))
+    (package
+     (name "go-github-com-agl-ed25519")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/agl/ed25519")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "1wjlbzi0w63rmlzgk3amw274wsl0zhcn4yx2lraffbkhqappahxc"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/agl/ed25519"
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'reset-gzip-timestamps 'make-files-writable
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let ((out (assoc-ref outputs "out")))
+                   (for-each (lambda (file) (chmod file #o644))
+                     (find-files out "\\.gz"))
+             #t))))))
+     (home-page "https://github.com/agl/ed25519")
+     (synopsis "Go library for ed25519 public-key signatures")
+     (description "This library is a Go implementation of ed25519 public-key
+signature system which was designed to be faster than previous digital signature
+systems without sacrificing security.  It is currently used in the
+implementation of obfs4 and should be not be used on newer projects since it
+is unmaintained.  Newer software should use x-crypto instead.")
+     ;; License file is referred but it is missing. Probably because the
+     ;; author decided to discontinue the project.
+     (license (license:non-copyleft "file://ed25519.go")))))
+
+(define-public go-github-com-dchest-siphash
+  (let ((commit "34f201214d993633bb24f418ba11736ab8b55aa7")
+        (revision "0"))
+    (package
+     (name "go-github-com-dchest-siphash")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dchest/siphash")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "08s076y7vmjqnq7jz0762hkm896r6r31v8b31a3gy0n8rfa01k8k"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dchest/siphash"))
+     (home-page "https://github.com/dchest/siphash")
+     (synopsis "Go library for siphash")
+     (description "Go implementation of SipHash-2-4, a fast short-input
+Pseudo Random Function which is suitable for usage in message authentication
+codes and was based on the design created by Jean-Philippe Aumasson and Daniel
+J. Bernstein. ")
+     (license license:cc0))))
+
+(define-public go-github-com-dchest-uniuri
+  (let ((commit "8902c56451e9b58ff940bbe5fec35d5f9c04584a")
+        (revision "0"))
+    (package
+     (name "go-github-com-dchest-uniuri")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dchest/uniuri")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "1x5bsbm1nlphsv96zd0rbclfaa1swpz5bp14x7s5dbxp0awk2gd4"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dchest/uniuri"))
+     (home-page "https://github.com/dchest/uniuri")
+     (synopsis "Go library for random URIs")
+     (description "Package uniuri generates random strings good for use in
+Universal Resource Identifiers to uniquely identify objects.")
+     (license license:cc0))))
+
+(define-public go-github-com-dsnet-compress
+  (let ((commit "cc9eb1d7ad760af14e8f918698f745e80377af4f")
+        (revision "0"))
+    (package
+     (name "go-github-com-dsnet-compress")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dsnet/compress")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "159liclywmyb6zx88ga5gn42hfl4cpk1660zss87fkx31hdq9fgx"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dsnet/compress"))
+     (home-page "https://github.com/dsnet/compress")
+     (synopsis "Go library for extended compression")
+     (description "This is a collection of compression related libraries.
+The goal of this project is to provide pure Go implementations for popular
+compression algorithms bey ond what the Go standard library provides.")
+     (license (license:non-copyleft "file://LICENSE.md")))))
+
+(define-public go-schwanenlied-me-yawning-bsaes
+  (let ((commit "26d1add596b6d800bdeeb3bc3b2c7b316c056b6d")
+        (revision "0"))
+    (package
+     (name "go-schwanenlied-me-yawning-bsaes")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.schwanenlied.me/yawning/bsaes.git")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "0h4dsyw54n9rcwprqy93wv2v1gcvlq1vfqdp1g7wxdkq457rhvys"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "git.schwanenlied.me/yawning/bsaes.git"))
+     (home-page "https://git.schwanenlied.me/yawning/bsaes.git")
+     (synopsis "Go AES library")
+     (description "Portable pure-Go constant time Advanced Encryption
+Standard (AES) for eletronic data encryption.  This implementation if
+based on code from [BearSSL](https://bearssl.org/).  On AMD64 systems
+with hardware support for AES New Instructions (AES-NI) and a
+sufficiently recent Go runtime, it will transparently call crypto/aes
+when NewCipher is invoked.")
+     (license (license:non-copyleft "file://LICENSE.txt")))))
+
+(define-public go-gitlab-com-yawning-utls
+  (package
+   (name "go-gitlab-com-yawning-utls")
+   (version "0.0.10-1")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://gitlab.com/yawning/utls.git")
+           (commit (string-append "v" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "15c46s56r45n22rmq9spnczydnkqrnxff28h5mpnk5yvcqif3lgb"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:tests? #f ;; Tries to connect and fails.
+      #:import-path "gitlab.com/yawning/utls.git"))
+   (propagated-inputs
+    `(("go-schwanenlied-me-yawning-bsaes" ,go-schwanenlied-me-yawning-bsaes)
+      ("go-github-com-dsnet-compress" ,go-github-com-dsnet-compress)
+      ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)))
+   (home-page "https://gitlab.com/yawning/utls.git")
+   (synopsis "Go library for uTLS")
+   (description "This library is a fork of the main Transport Layer Security
+protocol in Go (crypto/tls) which provides ClientHello fingerprinting resistance,
+low level access to handshakes and fake session tickets among other features.
+This fork was made for the specific purpose of improving obfs4proxy's meek_lite
+transport protocol.")
+   (license license:gpl3+)))
diff --git a/gnu/packages/patches/torbrowser-start-tor-browser.desktop.patch 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.desktop.orign	2020-07-05 18:47:40.689484877 -0300
++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser.desktop	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 shell.
+ # It preserves arguments and environment for the start-tor-browser script.
+@@ -28,7 +28,7 @@
+ GenericName=Web Browser
+ Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
+ Categories=Network;WebBrowser;Security;
+-Exec=sh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/start-tor-browser --detach)' dummy %k
+-X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
+-Icon=web-browser
++Exec=bash -c start-tor-browser
++X-TorBrowser-ExecShell=start-tor-browser --detach
++Icon=torbrowser
+ StartupWMClass=Tor 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..c563f94003
--- /dev/null
+++ b/gnu/packages/patches/torbrowser-start-tor-browser.patch
@@ -0,0 +1,226 @@
+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.orig	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.
+ 
++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"
++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
+@@ -106,14 +115,11 @@
+     printf "  --verbose         Display Tor and Firefox output in the terminal\n"
+     printf "  --log [file]      Record Tor and Firefox output in file (default: tor-browser.log)\n"
+     printf "  --detach          Detach from terminal and run Tor Browser in the background.\n"
+-    printf "  --register-app    Register Tor Browser as a desktop app for this user\n"
+-    printf "  --unregister-app  Unregister Tor Browser as a desktop app for this user\n"
+ }
+ log_output=0
+ show_output=0
+ detach=0
+ show_usage=0
+-register_desktop_app=0
+ logfile=/dev/null
+ while :
+ do
+@@ -134,8 +140,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"
+@@ -148,16 +154,6 @@
+           log_output=1
+           shift
+           ;;
+-      --register-app)
+-          register_desktop_app=1
+-          show_output=1
+-          shift
+-          ;;
+-      --unregister-app)
+-          register_desktop_app=-1
+-          show_output=1
+-          shift
+-          ;;
+       *) # No more options
+           break
+           ;;
+@@ -187,41 +183,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,50 +214,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/"
+-	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
+-fi
+-
+-if [ "$register_desktop_app" -eq -1 ]; then
+-	if [ -e "$HOME/.local/share/applications/start-tor-browser.desktop" ]; then
+-		rm -f "$HOME/.local/share/applications/start-tor-browser.desktop"
+-		update-desktop-database "$HOME/.local/share/applications/"
+-		printf "Tor Browser has been removed as a user desktop app (from ~/.local/share/applications/)\n"
+-	else
+-		printf "Tor Browser does not appear to be a desktop app (not present in ~/.local/share/applications/)\n"
+-	fi
+-	exit 0
+-fi
+-
+ 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 +279,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,<dir>fonts</dir>,<dir>${TBB_STORE_PATH}/fonts</dir>,"
++
+ cd "${HOME}"
+ 
+ # We pass all additional command-line arguments we get to Firefox.
+@@ -357,23 +296,23 @@
+ 
+ if [ "$show_usage" -eq 1 ]; then
+     # Display Firefox help, then our help
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default --help 2>/dev/null
++    TOR_CONTROL_PASSWD=${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=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-       -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++       -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
+     disown "$!"
+ elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
+         tee "$logfile"
+ elif [ "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" < /dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" < /dev/null
+ else
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
+ fi
+ 
+ exit $?
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index c852c54a5b..d3a0933ae4 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -28,28 +28,69 @@
 
 (define-module (gnu packages tor)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
+  #:use-module (guix monads)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix store)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix build-system cargo)
+  #:use-module (guix build-system go)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages assembly)
+  #:use-module (gnu packages audio)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
-  #:use-module (gnu packages libevent)
-  #:use-module (gnu packages linux)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cups)
+  #:use-module (gnu packages databases)
+  #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages gl)
+  #:use-module (gnu packages glib)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages golang)
+  #:use-module (gnu packages gtk)
+  #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages image)
+  #:use-module (gnu packages kerberos)
+  #:use-module (gnu packages libcanberra)
+  #:use-module (gnu packages libevent)
+  #:use-module (gnu packages libffi)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu packages llvm)
+  #:use-module (gnu packages node)
+  #:use-module (gnu packages nss)
   #:use-module (gnu packages pcre)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-crypto)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages qt)
-  #:use-module (gnu packages autotools)
+  #:use-module (gnu packages readline)
+  #:use-module (gnu packages rsync) ; for httpse
+  #:use-module (gnu packages rust)
+  #:use-module (gnu packages rust-apps)
+  #:use-module (gnu packages sqlite)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages w3m))
+  #:use-module (gnu packages video)
+  #:use-module (gnu packages vim) ; for xxd
+  #:use-module (gnu packages w3m)
+  #:use-module (gnu packages xdisorg)
+  #:use-module (gnu packages xiph)
+  #:use-module (gnu packages xorg)
+  #:use-module (gnu packages xml) ; for httpse
+  #:use-module (ice-9 match)
+  #:use-module ((srfi srfi-1) #:hide (zip)))
 
 (define-public tor
   (package
@@ -324,3 +365,778 @@ statistics and status reports on:
 
 Potential client and exit connections are scrubbed of sensitive information.")
     (license license:gpl3+)))
+
+(define-public obfs4
+  (package
+   (name "obfs4")
+   (version "0.0.11")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://git.torproject.org/pluggable-transports/obfs4.git")
+           (commit (string-append "obfs4proxy-" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "1y2kjwrk64l1h8b87m4iqsanib5rn68gzkdri1vd132qrlypycjn"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:import-path "git.torproject.org/pluggable-transports/obfs4.git"
+      #:tests? #f ;; No test files
+      #:phases
+      (modify-phases %standard-phases
+        (replace 'build
+          (lambda* (#:key outputs configure-flags #:allow-other-keys)
+            (let ((out (assoc-ref outputs "out")))
+              (copy-recursively
+               "src/git.torproject.org/pluggable-transports/obfs4.git"
+               "src/gitlab.com/yawning/obfs4.git"
+               #:log (%make-void-port "w"))
+              (with-directory-excursion
+               "src/git.torproject.org/pluggable-transports/obfs4.git/obfs4proxy"
+               (invoke "go" "build" "-ldflags" "-s"))
+            #t)))
+        (replace 'install
+          (lambda* (#:key outputs #:allow-other-keys)
+            (let* ((out (assoc-ref outputs "out"))
+                   (src "src/git.torproject.org/pluggable-transports/obfs4.git")
+                   (bin (string-append out "/bin"))
+                   (share (string-append out "/share"))
+                   (doc (string-append share "/doc"))
+                   (man (string-append share "/man/man1")))
+              (mkdir-p man)
+              (mkdir bin)
+              (mkdir doc)
+              (with-directory-excursion
+               (string-append src "/obfs4proxy")
+               (copy-file "obfs4proxy"
+                          (string-append bin "/obfs4proxy")))
+              (with-directory-excursion
+               (string-append src "/doc")
+               (copy-file "obfs4proxy.1"
+                          (string-append man "/obfs4proxy.1"))
+               (copy-file "obfs4-spec.txt"
+                          (string-append doc "/obfs4-spec.txt")))
+            #t))))))
+   (propagated-inputs
+    `(("go-torproject-org-ptlib" ,go-torproject-org-ptlib)
+      ;; Currently uses this, but the readme on github is pointing
+      ;; users to start relying on x/crypto/ed25519 instead.
+      ("go-github-com-agl-ed25519" ,go-github-com-agl-ed25519)
+      ("go-github-com-dchest-siphash" ,go-github-com-dchest-siphash)
+      ("go-github-com-dchest-uniuri" ,go-github-com-dchest-uniuri)
+      ("go-github-com-dsnet-compress" ,go-github-com-dsnet-compress)
+      ("go-schwanenlied-me-yawning-bsaes" ,go-schwanenlied-me-yawning-bsaes)
+      ("go-gitlab-com-yawning-utls" ,go-gitlab-com-yawning-utls)
+      ("go-golang-org-x-net" ,go-golang-org-x-net)
+      ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)
+      ("go-golang-org-x-text" ,go-golang-org-x-text)))
+   (home-page "https://git.torproject.org/pluggable-transports/obfs4.git")
+   (synopsis "Obfs4 implements an obfuscation protocol")
+   (description "This is a look-like nothing obfuscation protocol that
+incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol.
+The obfs naming was chosen primarily because it was shorter, in terms of
+protocol ancestery obfs4 is much closer to ScrambleSuit than obfs2/obfs3.")
+   (license license:gpl3+)))
+
+;; Upstream does not seem to keep tor-browser and tor-browser-build versions
+;; in sync
+(define %torbrowser-version "68.11.0esr-9.5-1")
+(define %torbrowser-build-version "9.5.3")
+(define %torbrowser-build "build1")
+(define %torbrowser-build-id "20200729000000");must be of the form YYYYMMDDhhmmss
+
+;; Fonts for Tor Browser. Avoid downloading 4Gb+ git repo on
+;; https://github.com/googlei18n/noto-fonts.git to use just a handful.
+;; Use the fonts on Tor Browser release tarball.
+(define torbrowser-fonts
+  (package
+   (name "torbrowser-fonts")
+   (version %torbrowser-build-version)
+   (source
+    (origin
+     (method url-fetch)
+     (uri (string-append "https://dist.torproject.org/torbrowser/"
+                         version "/tor-browser-linux64-"
+                         version "_en-US.tar.xz"))
+     (sha256
+      (base32
+       "1kqvr0sag94xdkq85k426qq1hz2b52m315yz51w6hvc87d8332b4"))))
+   (build-system trivial-build-system)
+   (native-inputs
+    `(("tar" ,tar)
+      ("xz" ,xz)))
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (let ((src (assoc-ref %build-inputs "source"))
+                        (src-dir "tor-browser_en-US/Browser/fonts")
+                        (fonts (string-append %output "/share/fonts"))
+                        (tar (assoc-ref %build-inputs "tar"))
+                        (xz (assoc-ref %build-inputs "xz")))
+                    (mkdir-p fonts)
+                    (format #t "Untaring torbrowser ball ...~%")
+                    (invoke (string-append tar "/bin/tar") "-xf" src
+                            "-C" fonts "--strip-components=3"
+                            (string-append "--use-compress-program=" xz "/bin/xz")
+                            src-dir)
+                    #t))))
+   (home-page "https://github.com/googlei18n/noto-fonts")
+   (synopsis "Tor Browser bundled fonts")
+   (description "Free fonts bundled with Tor Browser.  Includes a subset of Noto,
+Arimo, Cousine, Tinos and STIX fonts.")
+   (license license:silofl1.1)))
+
+(define tor-browser-build
+  (let ((commit (string-append "tbb-" %torbrowser-build-version
+                               "-" %torbrowser-build)))
+    (package
+     (name "tor-browser-build")
+     (version %torbrowser-build-version)
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.torproject.org/builders/tor-browser-build.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "1p291zqkvgsz9kk21s2p9v1bha3aam7z646v73dr06qmhdfhvgag"))))
+     (build-system trivial-build-system)
+     (arguments
+      `(#:modules ((guix build utils))
+        #:builder (begin
+                    (use-modules (guix build utils))
+                    (format #t "Copying build scripts ...~%")
+                    (copy-recursively (string-append
+                                       (assoc-ref %build-inputs "source")
+                                       "/projects/tor-browser")
+                                      %output
+                                      #:log (%make-void-port "w")))))
+     (home-page "https://www.torproject.org")
+     (synopsis "Tor Browser build scripts")
+     (description "Tor Browser runtime scripts.")
+     (license (license:non-copyleft "file://LICENSE")))))
+
+(define torbutton
+  (let ((commit "ebe2bedab44e38f18c7968bd327d99eef7660f34"))
+    (package
+     (name "torbutton")
+     (version %torbrowser-build-version)
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.torproject.org/torbutton.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "03xdyszab1a8j98xv6440v4lq58jkfqgmhxc2a62qz8q085d2x83"))))
+     (build-system trivial-build-system)
+     (arguments
+      `(#:modules ((guix build utils))
+        #:builder (begin
+                    (use-modules (guix build utils))
+                    (format #t "Copying source ...~%")
+                    (copy-recursively (assoc-ref %build-inputs "source")
+                                      %output
+                                      #:log (%make-void-port "w")))))
+     (home-page "https://www.torproject.org")
+     (synopsis "Tor Browser built-in extension")
+     (description "Browser extension needed to build and run Tor Browser.")
+     (license (license:non-copyleft "file://LICENSE")))))
+
+(define tor-launcher
+  (package
+   (name "tor-launcher")
+   (version "0.2.21.8")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://git.torproject.org/tor-launcher.git")
+           (commit version)))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "1mm1z7gv9dv6ymbr3vsg0lsnhnn84zrb6qsa164hmaxcfrwfhz5d"))))
+   (build-system trivial-build-system)
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (format #t "Copying source ...~%")
+                  (copy-recursively (assoc-ref %build-inputs "source")
+                                    %output
+                                    #:log (%make-void-port "w")))))
+   (home-page "https://www.torproject.org")
+   (synopsis "Tor Browser built-in controler extension")
+   (description "Browser extension that starts the tor process (which
+connects the browser and other applications to the Tor Network), and
+which helps people configure and use @code{tor}. The first window that
+you see when you start Tor Browser is displayed by this extension.")
+   (license (license:non-copyleft "file://src/LICENSE"))))
+
+(define https-everywhere
+  (package
+   (name "https-everywhere")
+   (version "2020.5.20")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (string-append "https://github.com/EFForg/https-everywhere/archive/"
+                         version ".tar.gz"))
+     (sha256
+      (base32
+       "027lga3z0a4d7s95id861das7g0k29p7pqh9xd77jm87f7w4l763"))))
+   (build-system trivial-build-system)
+   (native-inputs
+    `(("bash" ,bash)
+      ("coreutils" ,coreutils)
+      ("gzip" ,gzip)
+      ("libxml2" ,libxml2)
+      ("libxslt" ,libxslt)
+      ("openssl" ,openssl)
+      ("python" ,python)
+      ("rsync" ,rsync)
+      ("tar" ,tar)
+      ("util-linux" ,util-linux) ; for getopt
+      ("xxd" ,xxd)
+      ("zip" ,zip)))
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (let ((src (assoc-ref %build-inputs "source"))
+                        (bash (assoc-ref %build-inputs "bash"))
+                        (coreutils (assoc-ref %build-inputs "coreutils"))
+                        (python (assoc-ref %build-inputs "python"))
+                        (openssl (assoc-ref %build-inputs "openssl"))
+                        (rsync (assoc-ref %build-inputs "rsync"))
+                        (libxml2 (assoc-ref %build-inputs "libxml2"))
+                        (libxslt (assoc-ref %build-inputs "libxslt"))
+                        (util-linux (assoc-ref %build-inputs "util-linux"))
+                        (xxd (assoc-ref %build-inputs "xxd"))
+                        (zip (assoc-ref %build-inputs "zip"))
+                        (tar (assoc-ref %build-inputs "tar"))
+                        (gzip (assoc-ref %build-inputs "gzip")))
+                    (setenv "SHELL" (string-append bash "/bin/bash"))
+                    (set-path-environment-variable
+                     "PATH" '("bin")
+                     (list bash python tar openssl rsync libxml2 libxslt
+                           util-linux xxd gzip zip coreutils))
+                    (set-path-environment-variable
+                     "LIBRARY_PATH" '("lib")
+                     (list bash python tar openssl rsync libxml2 libxslt
+                           util-linux xxd gzip zip coreutils))
+                    (format #t "Untaring source tarball ...~%")
+                    (invoke "tar" "-xf" src "--strip-components=1")
+                    ;; Python3.6 is hardcoded on these scripts. Using v3.8 appears to
+                    ;; be harmless.
+                    (substitute* '("install-dev-dependencies.sh"
+                                   "make.sh"
+                                   "hooks/precommit"
+                                   "test/firefox.sh"
+                                   "test/manual.sh"
+                                   "test/rules/src/https_everywhere_checker/check_rules.py"
+                                   "test/script.py"
+                                   "test/validations.sh"
+                                   "test/validations/filename/run.py"
+                                   "test/validations/relaxng/run.py"
+                                   "test/validations/securecookie/run.py"
+                                   "test/validations/special/run.py"
+                                   "utils/create_zip.py"
+                                   "utils/chromium-translations.py"
+                                   "utils/create-platform-certs/split_combined_cert_file.py"
+                                   "utils/mk-client-whitelist/dbconnect.py"
+                                   "utils/mk-client-whitelist/run.py"
+                                   "utils/merge-rulesets.py"
+                                   "utils/setversion.py"
+                                   "utils/zipfile_deterministic.py")
+                      (("python3.6") "python3"))
+                    (for-each patch-shebang
+                              (find-files "."
+                                          (lambda (file stat)
+                                            ;; Filter out symlinks.
+                                            (eq? 'regular (stat:type stat)))
+                                          #:stat lstat))
+                    ;; Failing to generate the xpi, but copy-dir appears to be enough.
+                    ;; Failing on missing 'wasm'? Not generating rulesets.
+                    (invoke "./make.sh")
+                    (copy-recursively "pkg/xpi-eff" %output
+                                      #:log (%make-void-port "w"))
+                    #t))))
+   (home-page "https://www.eff.org/https-everywhere")
+   (synopsis "Browser extension for automatic HTTPS usage")
+   (description "Browser extension that automatically makes the browser to use
+HTTPS instead of plain HTTP when the remote destination makes it available to users.")
+   (license license:gpl2+)))
+
+(define noscript
+  (package
+   (name "noscript")
+   (version "11.0.34")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (string-append "https://secure.informaction.com/download/releases/noscript-"
+                         version ".xpi"))
+     (sha256
+      (base32
+       "0y45925ms2bk9d42zbgwcdb2sif8kqlbaflkz15q08gi7vgki6km"))))
+   (build-system trivial-build-system)
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (format #t "Copying source ...~%")
+                  (copy-file (assoc-ref %build-inputs "source")
+                                    %output))))
+   (home-page "https://noscript.net")
+   (synopsis "Browser extension for protection against known attacks")
+   (description "Browser extension that protects users from a range of
+known attacks on web browsing activity such as Cross-site scripting, clickjack and
+makes possible for the users to block or choose on a per site basis which remote
+javascript to run while browsing the web.")
+   (license license:gpl2+)))
+
+;; (Un)fortunatly Tor Browser has it's own reproducible build system - RBM - which
+;; automates the build process for them and compiles Tor Browser from a range of
+;; repositories and produces a range of tarballs for different architectures and
+;; locales. So we need to cherry-pick what is needed for guix and produce our own
+;; tarball. See https://gitweb.torproject.org/builders/tor-browser-build.git/projects/\
+;; {tor-browser,firefox}/{build,config} for the rationale applied here. See also
+;; the Hacking on Tor Browser document for a high level introduction at
+;; https://trac.torproject.org/projects/tor/wiki/doc/Tor Browser/Hacking).
+;;
+;; TODO: Import langpacks.
+(define-public torbrowser-unbundle
+  (let ((commit (string-append "tor-browser-" %torbrowser-version
+                               "-" %torbrowser-build)))
+    (package
+     (name "torbrowser-unbundle")
+     (version %torbrowser-build-version)
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.torproject.org/tor-browser.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "12qq0mpqf0q2v3grz4kydngvddc4k0k12hqg8fg6h2fwyqivamrr"))))
+     (build-system gnu-build-system)
+     (inputs
+      `(("alsa-lib" ,alsa-lib)
+        ("bzip2" ,bzip2)
+        ("cups" ,cups)
+        ("dbus-glib" ,dbus-glib)
+        ("ffmpeg" ,ffmpeg)
+        ("freetype" ,freetype)
+        ("gdk-pixbuf" ,gdk-pixbuf)
+        ("glib" ,glib)
+        ("gtk+" ,gtk+)
+        ("gtk+-2" ,gtk+-2)
+        ("graphite2" ,graphite2)
+        ("harfbuzz" ,harfbuzz)
+        ("icu4c" ,icu4c)
+        ("libcanberra" ,libcanberra)
+        ("libgnome" ,libgnome)
+        ("libjpeg-turbo" ,libjpeg-turbo)
+        ("libogg" ,libogg)
+        ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
+        ("libvorbis" ,libvorbis)
+        ("libxft" ,libxft)
+        ("libevent" ,libevent)
+        ("libxinerama" ,libxinerama)
+        ("libxscrnsaver" ,libxscrnsaver)
+        ("libxcomposite" ,libxcomposite)
+        ("libxt" ,libxt)
+        ("libffi" ,libffi)
+        ("libvpx" ,libvpx)
+        ("mesa" ,mesa)
+        ("mit-krb5" ,mit-krb5)
+        ;; See <https://bugs.gnu.org/32833>
+        ;;   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)
+        ("zlib" ,zlib)))
+     (native-inputs
+      `(("autoconf" ,autoconf-2.13)
+        ("bash" ,bash)
+        ("cargo" ,rust "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)
+        ("noscript" ,noscript)
+        ("rust" ,rust)
+        ("rust-cbindgen" ,rust-cbindgen)
+        ("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 <http://hydra.gnu.org/build/378133>.
+        #:validate-runpath? #f
+
+        #:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
+
+        #: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.desktop")))
+              #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 inputs)
+                                                     "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))
+
+          ;; 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 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
+                (substitute* '("Cargo.lock" "gfx/wr/Cargo.lock")
+                  (("(\"checksum .* = )\".*\"" all name)
+                   (string-append name "\"" null-hash "\"")))
+                (generate-all-checksums "third_party/rust"))
+              #t))
+
+          (add-after 'build 'neutralize-store-references
+            (lambda _
+              ;; Mangle the store references to compilers & other build tools in
+              ;; about:buildconfig, reducing Tor Browser's closure significant.
+              ;; 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)
+                                "<!-- Guix: not a runtime dependency -->"
+                                (string-drop hash 8))))
+              #t))
+
+          (replace 'configure
+            (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bash (which "bash"))
+                     (flags `(,(string-append "--prefix=" 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 "MOZ_BUILD_DATE" ,%torbrowser-build-id) ; avoid timestamp.
+                (setenv "LDFLAGS" (string-append
+                                   "-Wl,-rpath="
+                                   (assoc-ref outputs "out")
+                                   "/lib/firefox"))
+                (substitute* ".mozconfig"
+                  ;; Arch independent builddir.
+                  (("(mk_add_options MOZ_OBJDIR=@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=dev-build")
+                   (string-append "ac_add_options --with-tor-browser-version=org.gnu\n"
+                                  "ac_add_options --with-unsigned-addon-scopes=app\n"
+                                  "ac_add_options --enable-pulseaudio\n"
+                                  "ac_add_options --disable-debug-symbols\n"
+                                  "ac_add_options --disable-updater\n"
+                                  "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"
+                                  "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="
+                                   (assoc-ref %build-inputs "clang") "/bin/clang\n"
+                                  "ac_add_options --with-libclang-path="
+                                   (assoc-ref %build-inputs "clang") "/lib\n")))
+
+                (substitute* "browser/app/profile/000-tor-browser.js"
+                  ;; Tor Browser updates are disabled on mozconfig, but let's make sure.
+                  (("(pref\\(\"extensions.torbutton.versioncheck_enabled\").*" _ m)
+                   (string-append m ",false);\n")))
+
+                (substitute*
+                 "browser/extensions/tor-launcher/src/defaults/preferences/torlauncher-prefs.js"
+                  ;; Not multilingual. See tor-browser/build:141. Currently disabled on
+                  ;; tor-launcher, but let's make sure while missing langpacks.
+                 (("(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 _ (invoke "./mach" "build")
+              #t))
+
+          ;; Tor Browser just do a stage-package here and copy files to its places.
+          (replace 'install
+            (lambda* (#:key inputs native-inputs outputs #: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" "libnssdbm3.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") #o555)
+                (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/default")))
+                (with-directory-excursion
+                 icons-src
+                 (for-each
+                   (lambda (file)
+                     (let* ((size (string-filter char-numeric? file))
+                            (icons (string-append out "/share/icons/hicolor/"
+                                                  size "x" size "/apps")))
+                       (mkdir-p icons)
+                       (copy-file file (string-append icons "/torbrowser.png"))))
+                   '("default16.png" "default32.png" "default48.png" "default64.png"
+                     "default128.png"))))
+              #t))
+
+          (add-after 'install-icons 'install-fonts
+            (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (lib (string-append out "/lib/firefox/"))
+                     (fonts  (string-append (or (assoc-ref native-inputs
+                                                           "torbrowser-fonts")
+                                                (assoc-ref inputs
+                                                           "torbrowser-fonts"))
+                                            "/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-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (ext (string-append out "/lib/firefox/browser/extensions"))
+                     (noscript-id "{73a6fe31-595d-460b-a920-fcc0f8843232}")
+                     (httpse-id "https-everywhere-eff@eff.org")
+                     (noscript (assoc-ref inputs "noscript"))
+                     (httpse (assoc-ref inputs "https-everywhere")))
+                (mkdir-p ext)
+                (copy-file noscript (string-append
+                                     ext "/" noscript-id ".xpi"))
+                (copy-recursively httpse
+                                  (string-append ext "/" httpse-id)
+                                  #:log (%make-void-port "w"))
+                (chmod (string-append ext "/" noscript-id ".xpi") #o555))
+              #t))
+
+          (add-after 'install-extensions 'link-binaries
+            (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (tordir (string-append out "/lib/firefox/TorBrowser/Tor"))
+                     (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-keys)
+              (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 "/" file)
+                                               #:log (%make-void-port "w")))
+                           '("Browser" "fontconfig" "Tor")))
+                (copy-file (string-append ptconf "/linux/torrc-defaults-appendix")
+                           (string-append data "/Tor/torrc-defaults-appendix"))
+                (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 the only
+recommended way to anonymously browse the web that is supported by the project.
+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
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser-unbundle.
  2020-08-03 12:55   ` André Batista
@ 2020-09-07 14:13     ` Ludovic Courtès
  2020-09-09  2:24       ` André Batista
  0 siblings, 1 reply; 56+ messages in thread
From: Ludovic Courtès @ 2020-09-07 14:13 UTC (permalink / raw)
  To: André Batista; +Cc: 42380

Hello,

André Batista <nandre@riseup.net> skribis:

> This patch upgrades Tor Browser to version 9.5.3. I've also took this
> opportunity to rework the code in order to improve readability, make
> code review and maintainance easier and lower build time.
>
> Main changes:
> - No longer relies on computed-origin-method
> - Private package definitions
> - Chopped down install phase
> - New phases
> - More detailed go library package descriptions
> - Reviewed license definitions

Woow, thanks for working on this!  The end result is functional, right?
Any important missing items?

> From 2075c6a93a6b1918305323b369318425e05fc4f5 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
> Date: Mon, 3 Aug 2020 09:29:55 -0300
> Subject: [PATCH] gnu: Add torbrowser-unbundle
> To: guix-patches@gnu.org
>
> * gnu/packages/tor.scm (obfs4, torbrowser-unbundle): New variables.
> * gnu/packages/golang.scm (go-torproject-org-ptlib,
> go-github-com-agl-ed25519, go-github-com-dchest-siphash,
> go-github-com-dchest-uniuri, go-github-com-dsnet-compress,
> go-schwanenlied-me-yawning-bsaes, go-gitlab-com-yawning-utls): New variables.
> * 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.

For the final submission, we’d need one patch per new package, as is
customary.  That will have the advantage of allowing review to proceed
one bit at a time.  :-)

Regarding Tor Browser itself, can you think of ways to factorize code
with IceCat?

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser-unbundle.
  2020-09-07 14:13     ` Ludovic Courtès
@ 2020-09-09  2:24       ` André Batista
  2020-09-09  7:20         ` Ludovic Courtès
  0 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2020-09-09  2:24 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 42380

Hello,

seg 07 set 2020 às 16:13:17 (1599505997), ludo@gnu.org enviou:
> Hello,
> 
> Woow, thanks for working on this!  The end result is functional, right?
> Any important missing items?

Just a small token of my appreciation for your years of work on
guix. I'm glad to be able to give something back to this community.

I've been using this package for the last month or so and did not
hit any bugs so, though I'm not a heavy web user, I think it's fair
to say the result is functional.

On the down side, the https-everywhere extension is broken as is
since it's missing lib-wasm. I've built but did not send here a
version which just copies lib-wasm to its proper place before
building the extension and this version works without further
issues.

The reason I did not send it to this list is that lib-wasm source
provides a precompiled prepackaged file[1] which is then used on
https-everywhere build script and it's source code is not actualy
compiled[2]. As I understand it, the Tor Project just relies on
this precompiled binary on its build procedure and the same seems
to be true for IceCat[3][4].

In order to have everything compiled from source, I've had to
define a lot of rust libs which were required for building
wasm-pack and then to have a rustc with wasm32-unknown-unknown
target enabled and compatible with wasm-pack (apparently newer
versions changed compiler strings and wasm-pack errors out when
trying to parse). For over two weeks I've been trying without
success and always thinking that the next build would succeed.

Long story short, maybe there's just one more issue pending when
compiling lib-wasm. When wasm-pack is invoked, everything
compiles but I'm getting the following error:

note: lld: error: /gnu/store/kwdsf42z7ib6fr5vggqi9nc4jpi1znxy-rust-1.38.0/lib/rustlib/wasm32-unknown-unknown/lib/libstd-373ca16e620a2f9a.rlib: archive has no index; run ranlib to add one

for a few rust libs. Without lld, it complains about a missing
rust-lld binary. Also, this appears to be the rust standard
nowadays[5].

If I'm not terribly wrong, this issue[6] seems to suggest an
approach for emscripten which could solve this issue without
removing the 'strip' phase which was the work around suggested
by some on the same thread.

Another issue that is pending is that libwasm depends on rust
multi-default-trait-impl crate. This crate defines lgpl2.1+ on
its Cargo.toml file, but the sources does not contain neither a
copy of the license. So I'm unsure if this is enough to make it
free software. So I'm planning on sending some mails to both the
maintainer and FSF to see if this needs improvement.

> For the final submission, we’d need one patch per new package, as is
> customary.  That will have the advantage of allowing review to proceed
> one bit at a time.  :-)

For sure. I'll give it a few more tries and cleanup the mess
here before sending this patch series. If I don't succeed, I'm
planning on sending it anyway so at least the libs can be
added and maybe someone can spot what I'm missing. But maybe
it's wise to hold Tor Browser itself since there has been an
announcement of some large percentage of exit relays messing
with Tor traffic[7].

> Regarding Tor Browser itself, can you think of ways to factorize code
> with IceCat?

Other than sharing the https-everywhere definition, I was
thinking maybe we could take a diff of Tor Browser and Firefox
and avoid downloading firefox source twice when building both
browsers. But I need to take a more careful look. I'll give
this question some thought.

Cheers,

1. https://docs.rs/crate/https-everywhere-lib-wasm/0.1.2/source/pkg/https_everywhere_lib_wasm_bg.wasm
2. https://github.com/EFForg/https-everywhere/blob/master/make.sh#L113
3. https://git.savannah.gnu.org/cgit/gnuzilla.git/tree/makeicecat?h=68#n565
4. https://git.savannah.gnu.org/cgit/gnuzilla.git/tree/data/extensions/https-everywhere@eff.org/wasm/https_everywhere_lib_wasm_bg.wasm?h=68
5. https://github.com/rust-lang/rust/pull/48125
6. https://github.com/emscripten-core/emscripten/issues/9705
7. https://blog.torproject.org/bad-exit-relays-may-june-2020




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser-unbundle.
  2020-09-09  2:24       ` André Batista
@ 2020-09-09  7:20         ` Ludovic Courtès
  2020-09-09 10:59           ` Efraim Flashner
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
  0 siblings, 2 replies; 56+ messages in thread
From: Ludovic Courtès @ 2020-09-09  7:20 UTC (permalink / raw)
  To: André Batista; +Cc: Efraim Flashner, 42380

Hi André,

André Batista <nandre@riseup.net> skribis:

> Just a small token of my appreciation for your years of work on
> guix. I'm glad to be able to give something back to this community.

Thank you.

> I've been using this package for the last month or so and did not
> hit any bugs so, though I'm not a heavy web user, I think it's fair
> to say the result is functional.
>
> On the down side, the https-everywhere extension is broken as is
> since it's missing lib-wasm. I've built but did not send here a
> version which just copies lib-wasm to its proper place before
> building the extension and this version works without further
> issues.
>
> The reason I did not send it to this list is that lib-wasm source
> provides a precompiled prepackaged file[1] which is then used on
> https-everywhere build script and it's source code is not actualy
> compiled[2]. As I understand it, the Tor Project just relies on
> this precompiled binary on its build procedure and the same seems
> to be true for IceCat[3][4].

Oh, glad that you were able to identify that issue, which presumably had
been overlooked so far.

> In order to have everything compiled from source, I've had to
> define a lot of rust libs which were required for building
> wasm-pack and then to have a rustc with wasm32-unknown-unknown
> target enabled and compatible with wasm-pack (apparently newer
> versions changed compiler strings and wasm-pack errors out when
> trying to parse). For over two weeks I've been trying without
> success and always thinking that the next build would succeed.
>
> Long story short, maybe there's just one more issue pending when
> compiling lib-wasm. When wasm-pack is invoked, everything
> compiles but I'm getting the following error:
>
> note: lld: error: /gnu/store/kwdsf42z7ib6fr5vggqi9nc4jpi1znxy-rust-1.38.0/lib/rustlib/wasm32-unknown-unknown/lib/libstd-373ca16e620a2f9a.rlib: archive has no index; run ranlib to add one
>
> for a few rust libs. Without lld, it complains about a missing
> rust-lld binary. Also, this appears to be the rust standard
> nowadays[5].

Ah.  I’m Cc’ing Efraim, who’s been very much into Rust packaging for
some time; does that ring a bell, Efraim?

> If I'm not terribly wrong, this issue[6] seems to suggest an
> approach for emscripten which could solve this issue without
> removing the 'strip' phase which was the work around suggested
> by some on the same thread.
>
> Another issue that is pending is that libwasm depends on rust
> multi-default-trait-impl crate. This crate defines lgpl2.1+ on
> its Cargo.toml file, but the sources does not contain neither a
> copy of the license. So I'm unsure if this is enough to make it
> free software. So I'm planning on sending some mails to both the
> maintainer and FSF to see if this needs improvement.

Great.

>> For the final submission, we’d need one patch per new package, as is
>> customary.  That will have the advantage of allowing review to proceed
>> one bit at a time.  :-)
>
> For sure. I'll give it a few more tries and cleanup the mess
> here before sending this patch series. If I don't succeed, I'm
> planning on sending it anyway so at least the libs can be
> added and maybe someone can spot what I'm missing. But maybe
> it's wise to hold Tor Browser itself since there has been an
> announcement of some large percentage of exit relays messing
> with Tor traffic[7].

I don’t think Guix users will radically increase traffic over Tor, so I
think we can keep going.  :-)

>> Regarding Tor Browser itself, can you think of ways to factorize code
>> with IceCat?
>
> Other than sharing the https-everywhere definition, I was
> thinking maybe we could take a diff of Tor Browser and Firefox
> and avoid downloading firefox source twice when building both
> browsers. But I need to take a more careful look. I'll give
> this question some thought.

OK.  I was expecting at least things like some of the build phases and
most/all of the inputs to be the same, but I haven’t checked.

Thanks again for all the work!

Ludo’.




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser-unbundle.
  2020-09-09  7:20         ` Ludovic Courtès
@ 2020-09-09 10:59           ` Efraim Flashner
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
  1 sibling, 0 replies; 56+ messages in thread
From: Efraim Flashner @ 2020-09-09 10:59 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: André Batista, 42380

[-- Attachment #1: Type: text/plain, Size: 4829 bytes --]

On Wed, Sep 09, 2020 at 09:20:08AM +0200, Ludovic Courtès wrote:
> Hi André,
> 
> André Batista <nandre@riseup.net> skribis:
> 
> > Just a small token of my appreciation for your years of work on
> > guix. I'm glad to be able to give something back to this community.
> 
> Thank you.
> 
> > I've been using this package for the last month or so and did not
> > hit any bugs so, though I'm not a heavy web user, I think it's fair
> > to say the result is functional.
> >
> > On the down side, the https-everywhere extension is broken as is
> > since it's missing lib-wasm. I've built but did not send here a
> > version which just copies lib-wasm to its proper place before
> > building the extension and this version works without further
> > issues.
> >
> > The reason I did not send it to this list is that lib-wasm source
> > provides a precompiled prepackaged file[1] which is then used on
> > https-everywhere build script and it's source code is not actualy
> > compiled[2]. As I understand it, the Tor Project just relies on
> > this precompiled binary on its build procedure and the same seems
> > to be true for IceCat[3][4].
> 
> Oh, glad that you were able to identify that issue, which presumably had
> been overlooked so far.
> 
> > In order to have everything compiled from source, I've had to
> > define a lot of rust libs which were required for building
> > wasm-pack and then to have a rustc with wasm32-unknown-unknown
> > target enabled and compatible with wasm-pack (apparently newer
> > versions changed compiler strings and wasm-pack errors out when
> > trying to parse). For over two weeks I've been trying without
> > success and always thinking that the next build would succeed.
> >
> > Long story short, maybe there's just one more issue pending when
> > compiling lib-wasm. When wasm-pack is invoked, everything
> > compiles but I'm getting the following error:
> >
> > note: lld: error: /gnu/store/kwdsf42z7ib6fr5vggqi9nc4jpi1znxy-rust-1.38.0/lib/rustlib/wasm32-unknown-unknown/lib/libstd-373ca16e620a2f9a.rlib: archive has no index; run ranlib to add one
> >
> > for a few rust libs. Without lld, it complains about a missing
> > rust-lld binary. Also, this appears to be the rust standard
> > nowadays[5].
> 
> Ah.  I’m Cc’ing Efraim, who’s been very much into Rust packaging for
> some time; does that ring a bell, Efraim?
> 

It's not something that I've come across before. My first guess would be
to check the linking flags against the ones icecat/firefox uses and see
if anything changed. Or if it needs a different version of rust.

> > If I'm not terribly wrong, this issue[6] seems to suggest an
> > approach for emscripten which could solve this issue without
> > removing the 'strip' phase which was the work around suggested
> > by some on the same thread.
> >
> > Another issue that is pending is that libwasm depends on rust
> > multi-default-trait-impl crate. This crate defines lgpl2.1+ on
> > its Cargo.toml file, but the sources does not contain neither a
> > copy of the license. So I'm unsure if this is enough to make it
> > free software. So I'm planning on sending some mails to both the
> > maintainer and FSF to see if this needs improvement.
> 
> Great.
> 
> >> For the final submission, we’d need one patch per new package, as is
> >> customary.  That will have the advantage of allowing review to proceed
> >> one bit at a time.  :-)
> >
> > For sure. I'll give it a few more tries and cleanup the mess
> > here before sending this patch series. If I don't succeed, I'm
> > planning on sending it anyway so at least the libs can be
> > added and maybe someone can spot what I'm missing. But maybe
> > it's wise to hold Tor Browser itself since there has been an
> > announcement of some large percentage of exit relays messing
> > with Tor traffic[7].
> 
> I don’t think Guix users will radically increase traffic over Tor, so I
> think we can keep going.  :-)
> 
> >> Regarding Tor Browser itself, can you think of ways to factorize code
> >> with IceCat?
> >
> > Other than sharing the https-everywhere definition, I was
> > thinking maybe we could take a diff of Tor Browser and Firefox
> > and avoid downloading firefox source twice when building both
> > browsers. But I need to take a more careful look. I'll give
> > this question some thought.
> 
> OK.  I was expecting at least things like some of the build phases and
> most/all of the inputs to be the same, but I haven’t checked.
> 
> Thanks again for all the work!
> 
> Ludo’.

-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] Wow!
  2020-07-15 21:15 [bug#42380] [WIP] gnu: Add torbrowser-unbundle André Batista
  2020-07-25 14:49 ` [bug#42380] [PATCH] " André Batista
@ 2020-09-12 13:35 ` Raghav Gururajan
  2020-09-15 15:23   ` André Batista
  2023-12-12 11:21 ` [bug#42380] [PATCH] gnu: Add torbrowser Clément Lassieur
  2023-12-27 21:22 ` [bug#42380] [WIP] gnu: Add torbrowser-unbundle Anonymousemail via Guix-patches via
  3 siblings, 1 reply; 56+ messages in thread
From: Raghav Gururajan @ 2020-09-12 13:35 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 184 bytes --]

Hello Guix!

Thank you all for the hard work. This is a high-time package.

Any idea on when it can be merged to master?, at-least a minimally
viable package?

Regards,
RG.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 0/9] gnu: Add torbrowser-unbundle.
  2020-09-09  7:20         ` Ludovic Courtès
  2020-09-09 10:59           ` Efraim Flashner
@ 2020-09-15 14:21           ` André Batista
  2020-09-15 15:01             ` [bug#42380] [PATCH 1/9] gnu: Add go-torproject-org-ptlib André Batista
                               ` (8 more replies)
  1 sibling, 9 replies; 56+ messages in thread
From: André Batista @ 2020-09-15 14:21 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Efraim Flashner, 42380

[-- Attachment #1: Type: text/plain, Size: 2250 bytes --]

Hi Ludo,

qua 09 set 2020 às 09:20:08 (1599654008), ludo@gnu.org enviou:
> Hi André,
> 
> André Batista <nandre@riseup.net> skribis:
> 
> > For sure. I'll give it a few more tries and cleanup the mess
> > here before sending this patch series. If I don't succeed, I'm
> > planning on sending it anyway so at least the libs can be
> > added and maybe someone can spot what I'm missing. But maybe
> > it's wise to hold Tor Browser itself since there has been an
> > announcement of some large percentage of exit relays messing
> > with Tor traffic[7].
> 
> I don’t think Guix users will radically increase traffic over Tor, so I
> think we can keep going.  :-)

Just to be sure: it's not so much about Guix users increasing the load
on Tor Network as of Guix users not having the benefits of this
extension and being prey to sslstriping.

Since you're giving a green light and I've encountered further
deterrence down the trail, I'll be sending this patch series which
also updates Tor Browser to the latest version. I've left comments
on code where I see room for improvement, in case someones wants to
help. For now, I'm trying to solve this issue and I think I'll
start a new thread for tracking it in order to avoid clutter here
as https-everywhere requires a good many new rust libs.

> >> Regarding Tor Browser itself, can you think of ways to factorize code
> >> with IceCat?
> >
> > Other than sharing the https-everywhere definition, I was
> > thinking maybe we could take a diff of Tor Browser and Firefox
> > and avoid downloading firefox source twice when building both
> > browsers. But I need to take a more careful look. I'll give
> > this question some thought.
> 
> OK.  I was expecting at least things like some of the build phases and
> most/all of the inputs to be the same, but I haven’t checked.

Indeed they both share many inputs and phases. I've actually started
this definition from the IceCat one. I'll think on how to merge
them back. Probably some inheritance is in need.

> Thanks again for all the work!

:)

---

This patch series adds Tor Browser version 9.5.4 to Guix.
Unsurprisignly, building it with '--rounds=2' seems to imply that
it is deterministic.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 1/9] gnu: Add go-torproject-org-ptlib
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
@ 2020-09-15 15:01             ` André Batista
  2020-09-15 15:04             ` [bug#42380] [PATCH 2/9] gnu: Add go-github-com-agl-ed25519 André Batista
                               ` (7 subsequent siblings)
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2020-09-15 15:01 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #1.2: 0001-gnu-Add-go-torproject-org-ptlib.patch --]
[-- Type: text/plain, Size: 1731 bytes --]

From f92795d45035e0423c69a5f6264e35f466840778 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Mon, 14 Sep 2020 18:03:28 -0300
Subject: [PATCH] gnu: Add go-torproject-org-ptlib.
To: 42380@debbugs.gnu.org

* gnu/packages/golang.scm (go-torproject-org-ptlib): New variable.
---
 gnu/packages/golang.scm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 8723592b51..0bcb01fd2f 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -5656,3 +5656,27 @@ Included are the following:
 except that it adds convenience functions that use the fmt package to format
 error messages.")
     (license license:bsd-3)))
+
+(define-public go-torproject-org-ptlib
+  (package
+   (name "go-torproject-org-ptlib")
+   (version "1.1.0")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://git.torproject.org/pluggable-transports/goptlib.git")
+           (commit (string-append "v" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "1lh938194hvkf8pqgnxwf6hvjv9rv0j3kasi07r2ckrj8sxzk4jc"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:import-path "git.torproject.org/pluggable-transports/goptlib.git"))
+   (home-page "https://git.torproject.org/pluggable-transports/goptlib.git")
+   (synopsis "Go library for Tor Pluggable Transports")
+   (description "Library for writing Tor Pluggable Transports in Go.  Pluggable
+Transports are a means of connecting to the Tor Network from places where it
+is censored.")
+   (license license:cc0)))
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 2/9] gnu: Add go-github-com-agl-ed25519
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
  2020-09-15 15:01             ` [bug#42380] [PATCH 1/9] gnu: Add go-torproject-org-ptlib André Batista
@ 2020-09-15 15:04             ` André Batista
  2020-09-15 22:50               ` [bug#42380] [PATCH 2v2/9] " André Batista
  2020-09-15 15:06             ` [bug#42380] [PATCH 0/9] gnu: Add go-github-com-dchest-siphash André Batista
                               ` (6 subsequent siblings)
  8 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2020-09-15 15:04 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #1.2: 0001-gnu-Add-go-github-com-agl-ed25519.patch --]
[-- Type: text/plain, Size: 2543 bytes --]

From a9a38cf97812f18e1f39b9009d040f16af501efe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Mon, 14 Sep 2020 18:15:31 -0300
Subject: [PATCH] gnu: Add go-github-com-agl-ed25519.
To: 42380@debbugs.gnu.org

* gnu/packages/golang.scm (go-github-com-agl-ed25519): New variable.
---
 gnu/packages/golang.scm | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 0bcb01fd2f..8eab872814 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -5680,3 +5680,41 @@ error messages.")
 Transports are a means of connecting to the Tor Network from places where it
 is censored.")
    (license license:cc0)))
+
+(define-public go-github-com-agl-ed25519
+  (let ((commit "c4161f4c7483313562781c61b9a20aba73daf9de")
+        (revision "0"))
+    (package
+     (name "go-github-com-agl-ed25519")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/agl/ed25519")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "1wjlbzi0w63rmlzgk3amw274wsl0zhcn4yx2lraffbkhqappahxc"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/agl/ed25519"
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'reset-gzip-timestamps 'make-files-writable
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let ((out (assoc-ref outputs "out")))
+                   (for-each (lambda (file) (chmod file #o644))
+                     (find-files out "\\.gz"))
+             #t))))))
+     (home-page "https://github.com/agl/ed25519")
+     (synopsis "Go library for ed25519 public-key signatures")
+     (description "This library is a Go implementation of ed25519 public-key
+signature system which was designed to be faster than previous digital signature
+systems without sacrificing security.  It is currently used in the
+implementation of obfs4 and should be not be used on newer projects since it
+is unmaintained.  Newer software should use x-crypto instead.")
+     ;; License file is referred but it is missing. Probably because the
+     ;; author decided to discontinue the project.
+     (license (license:non-copyleft "file://ed25519.go")))))
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 0/9] gnu: Add go-github-com-dchest-siphash.
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
  2020-09-15 15:01             ` [bug#42380] [PATCH 1/9] gnu: Add go-torproject-org-ptlib André Batista
  2020-09-15 15:04             ` [bug#42380] [PATCH 2/9] gnu: Add go-github-com-agl-ed25519 André Batista
@ 2020-09-15 15:06             ` André Batista
  2020-09-15 22:53               ` [bug#42380] [PATCH 3/9] " André Batista
  2020-09-15 15:08             ` [bug#42380] [PATCH 4/9] gnu: Add go-github-com-dchest-uniuri André Batista
                               ` (5 subsequent siblings)
  8 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2020-09-15 15:06 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #1.2: 0001-gnu-Add-go-github-com-dchest-siphash.patch --]
[-- Type: text/plain, Size: 1982 bytes --]

From b1d59160bf4c444784f68b5b35d20c48cb1eb601 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Mon, 14 Sep 2020 18:18:41 -0300
Subject: [PATCH] gnu: Add go-github-com-dchest-siphash.
To: 42380@debbugs.gnu.org

* gnu/packages/golang.scm (go-github-com-dchest-siphash): New variable.
---
 gnu/packages/golang.scm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 8eab872814..471ed31965 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -5718,3 +5718,30 @@ is unmaintained.  Newer software should use x-crypto instead.")
      ;; License file is referred but it is missing. Probably because the
      ;; author decided to discontinue the project.
      (license (license:non-copyleft "file://ed25519.go")))))
+
+(define-public go-github-com-dchest-siphash
+  (let ((commit "34f201214d993633bb24f418ba11736ab8b55aa7")
+        (revision "0"))
+    (package
+     (name "go-github-com-dchest-siphash")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dchest/siphash")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "08s076y7vmjqnq7jz0762hkm896r6r31v8b31a3gy0n8rfa01k8k"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dchest/siphash"))
+     (home-page "https://github.com/dchest/siphash")
+     (synopsis "Go library for siphash")
+     (description "Go implementation of SipHash-2-4, a fast short-input
+Pseudo Random Function which is suitable for usage in message authentication
+codes and was based on the design created by Jean-Philippe Aumasson and Daniel
+J. Bernstein. ")
+     (license license:cc0))))
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 4/9] gnu: Add go-github-com-dchest-uniuri
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
                               ` (2 preceding siblings ...)
  2020-09-15 15:06             ` [bug#42380] [PATCH 0/9] gnu: Add go-github-com-dchest-siphash André Batista
@ 2020-09-15 15:08             ` André Batista
  2020-09-15 15:10             ` [bug#42380] [PATCH 5/9] gnu: Add go-github-com-dsnet-compress André Batista
                               ` (4 subsequent siblings)
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2020-09-15 15:08 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #1.2: 0001-gnu-Add-go-github-com-dchest-uniuri.patch --]
[-- Type: text/plain, Size: 1820 bytes --]

From 46b0c175ce9c440c469c4456960adab9503c2bfa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Mon, 14 Sep 2020 18:27:56 -0300
Subject: [PATCH] gnu: Add go-github-com-dchest-uniuri.
To: 42380@debbugs.gnu.org

* gnu/packages/golang.scm (go-github-com-dchest-uniuri): New variable.
---
 gnu/packages/golang.scm | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 471ed31965..da9a531665 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -5745,3 +5745,28 @@ Pseudo Random Function which is suitable for usage in message authentication
 codes and was based on the design created by Jean-Philippe Aumasson and Daniel
 J. Bernstein. ")
      (license license:cc0))))
+
+(define-public go-github-com-dchest-uniuri
+  (let ((commit "8902c56451e9b58ff940bbe5fec35d5f9c04584a")
+        (revision "0"))
+    (package
+     (name "go-github-com-dchest-uniuri")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dchest/uniuri")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "1x5bsbm1nlphsv96zd0rbclfaa1swpz5bp14x7s5dbxp0awk2gd4"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dchest/uniuri"))
+     (home-page "https://github.com/dchest/uniuri")
+     (synopsis "Go library for random URIs")
+     (description "Package uniuri generates random strings good for use in
+Universal Resource Identifiers to uniquely identify objects.")
+     (license license:cc0))))
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 5/9] gnu: Add go-github-com-dsnet-compress
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
                               ` (3 preceding siblings ...)
  2020-09-15 15:08             ` [bug#42380] [PATCH 4/9] gnu: Add go-github-com-dchest-uniuri André Batista
@ 2020-09-15 15:10             ` André Batista
  2020-09-15 15:12             ` [bug#42380] [PATCH 6/9] gnu: Add go-schwanenlied-me-yawning-bsaes André Batista
                               ` (3 subsequent siblings)
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2020-09-15 15:10 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #1.2: 0001-gnu-Add-go-github-com-dsnet-compress.patch --]
[-- Type: text/plain, Size: 1935 bytes --]

From e539f026c99a4983713a60928b2be10d70dd3a91 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Mon, 14 Sep 2020 18:31:36 -0300
Subject: [PATCH] gnu: Add go-github-com-dsnet-compress.
To: 42380@debbugs.gnu.org

* gnu/packages/golang.scm (go-github-com-dsnet-compress): New variable.
---
 gnu/packages/golang.scm | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index da9a531665..06c9faa286 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -5770,3 +5770,29 @@ J. Bernstein. ")
      (description "Package uniuri generates random strings good for use in
 Universal Resource Identifiers to uniquely identify objects.")
      (license license:cc0))))
+
+(define-public go-github-com-dsnet-compress
+  (let ((commit "cc9eb1d7ad760af14e8f918698f745e80377af4f")
+        (revision "0"))
+    (package
+     (name "go-github-com-dsnet-compress")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dsnet/compress")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "159liclywmyb6zx88ga5gn42hfl4cpk1660zss87fkx31hdq9fgx"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dsnet/compress"))
+     (home-page "https://github.com/dsnet/compress")
+     (synopsis "Go library for extended compression")
+     (description "This is a collection of compression related libraries.
+The goal of this project is to provide pure Go implementations for popular
+compression algorithms bey ond what the Go standard library provides.")
+     (license (license:non-copyleft "file://LICENSE.md")))))
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 6/9] gnu: Add go-schwanenlied-me-yawning-bsaes
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
                               ` (4 preceding siblings ...)
  2020-09-15 15:10             ` [bug#42380] [PATCH 5/9] gnu: Add go-github-com-dsnet-compress André Batista
@ 2020-09-15 15:12             ` André Batista
  2020-09-15 15:14             ` [bug#42380] [PATCH 7/9] gnu: Add go-gitlab-com-yawning-utls André Batista
                               ` (2 subsequent siblings)
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2020-09-15 15:12 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #1.2: 0001-gnu-Add-go-schwanenlied-me-yawning-bsaes.patch --]
[-- Type: text/plain, Size: 2212 bytes --]

From e88f0e94b84bd51ddf742577d60a5bcb19eff72b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Mon, 14 Sep 2020 18:33:55 -0300
Subject: [PATCH] gnu: Add go-schwanenlied-me-yawning-bsaes.
To: 42380@debbugs.gnu.org

* gnu/packages/golang.scm (go-schwanenlied-me-yawning-bsaes): New variable.
---
 gnu/packages/golang.scm | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 06c9faa286..7c68f36c2a 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -5796,3 +5796,32 @@ Universal Resource Identifiers to uniquely identify objects.")
 The goal of this project is to provide pure Go implementations for popular
 compression algorithms bey ond what the Go standard library provides.")
      (license (license:non-copyleft "file://LICENSE.md")))))
+
+(define-public go-schwanenlied-me-yawning-bsaes
+  (let ((commit "26d1add596b6d800bdeeb3bc3b2c7b316c056b6d")
+        (revision "0"))
+    (package
+     (name "go-schwanenlied-me-yawning-bsaes")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.schwanenlied.me/yawning/bsaes.git")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "0h4dsyw54n9rcwprqy93wv2v1gcvlq1vfqdp1g7wxdkq457rhvys"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "git.schwanenlied.me/yawning/bsaes.git"))
+     (home-page "https://git.schwanenlied.me/yawning/bsaes.git")
+     (synopsis "Go AES library")
+     (description "Portable pure-Go constant time Advanced Encryption
+Standard (AES) for eletronic data encryption.  This implementation if
+based on code from [BearSSL](https://bearssl.org/).  On AMD64 systems
+with hardware support for AES New Instructions (AES-NI) and a
+sufficiently recent Go runtime, it will transparently call crypto/aes
+when NewCipher is invoked.")
+     (license (license:non-copyleft "file://LICENSE.txt")))))
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 7/9] gnu: Add go-gitlab-com-yawning-utls
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
                               ` (5 preceding siblings ...)
  2020-09-15 15:12             ` [bug#42380] [PATCH 6/9] gnu: Add go-schwanenlied-me-yawning-bsaes André Batista
@ 2020-09-15 15:14             ` André Batista
  2020-09-15 15:15             ` [bug#42380] [PATCH 8/9] gnu: obfs4 André Batista
  2020-09-15 15:16             ` [bug#42380] [PATCH 9/9] gnu: Add torbrowser-unbundle André Batista
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2020-09-15 15:14 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #1.2: 0001-gnu-Add-go-gitlab-com-yawning-utls.patch --]
[-- Type: text/plain, Size: 2504 bytes --]

From 4f31263215dffb94e47a4c9e7256e095fb68c1e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Mon, 14 Sep 2020 18:47:38 -0300
Subject: [PATCH] gnu: Add go-gitlab-com-yawning-utls.
To: 42380@debbugs.gnu.org

* gnu/packages/golang.scm (go-gitlab-com-yawning-utls): New variable.
---
 gnu/packages/golang.scm | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 7c68f36c2a..55975d3e30 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.com>
+;;; Copyright © 2020 André Batista <nandre@riseup.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -5825,3 +5826,34 @@ with hardware support for AES New Instructions (AES-NI) and a
 sufficiently recent Go runtime, it will transparently call crypto/aes
 when NewCipher is invoked.")
      (license (license:non-copyleft "file://LICENSE.txt")))))
+
+(define-public go-gitlab-com-yawning-utls
+  (package
+   (name "go-gitlab-com-yawning-utls")
+   (version "0.0.10-1")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://gitlab.com/yawning/utls.git")
+           (commit (string-append "v" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "15c46s56r45n22rmq9spnczydnkqrnxff28h5mpnk5yvcqif3lgb"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:tests? #f ;; Tries to connect and fails.
+      #:import-path "gitlab.com/yawning/utls.git"))
+   (propagated-inputs
+    `(("go-schwanenlied-me-yawning-bsaes" ,go-schwanenlied-me-yawning-bsaes)
+      ("go-github-com-dsnet-compress" ,go-github-com-dsnet-compress)
+      ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)))
+   (home-page "https://gitlab.com/yawning/utls.git")
+   (synopsis "Go library for uTLS")
+   (description "This library is a fork of the main Transport Layer Security
+protocol in Go (crypto/tls) which provides ClientHello fingerprinting resistance,
+low level access to handshakes and fake session tickets among other features.
+This fork was made for the specific purpose of improving obfs4proxy's meek_lite
+transport protocol.")
+   (license license:gpl3+)))
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 8/9] gnu: obfs4
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
                               ` (6 preceding siblings ...)
  2020-09-15 15:14             ` [bug#42380] [PATCH 7/9] gnu: Add go-gitlab-com-yawning-utls André Batista
@ 2020-09-15 15:15             ` André Batista
  2020-09-15 15:16             ` [bug#42380] [PATCH 9/9] gnu: Add torbrowser-unbundle André Batista
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2020-09-15 15:15 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #1.2: 0001-gnu-Add-obfs4.patch --]
[-- Type: text/plain, Size: 5214 bytes --]

From 6e228ba965d65963456f3232cb8bd7fcc25bf822 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Mon, 14 Sep 2020 19:05:45 -0300
Subject: [PATCH] gnu: Add obfs4.
To: 42380@debbugs.gnu.org

* gnu/packages/tor.scm (obfs4): New variable.
* Alphabetically order module imports.
---
 gnu/packages/tor.scm | 80 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 77 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index c852c54a5b..dd362d3af8 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -33,13 +33,16 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system go)
   #:use-module (guix build-system python)
   #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
-  #:use-module (gnu packages libevent)
-  #:use-module (gnu packages linux)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages golang)
+  #:use-module (gnu packages libevent)
+  #:use-module (gnu packages linux)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -47,7 +50,6 @@
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages qt)
-  #:use-module (gnu packages autotools)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages w3m))
 
@@ -324,3 +326,75 @@ statistics and status reports on:
 
 Potential client and exit connections are scrubbed of sensitive information.")
     (license license:gpl3+)))
+
+(define-public obfs4
+  (package
+   (name "obfs4")
+   (version "0.0.11")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://git.torproject.org/pluggable-transports/obfs4.git")
+           (commit (string-append "obfs4proxy-" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "1y2kjwrk64l1h8b87m4iqsanib5rn68gzkdri1vd132qrlypycjn"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:import-path "git.torproject.org/pluggable-transports/obfs4.git"
+      #:tests? #f ;; No test files
+      #:phases
+      (modify-phases %standard-phases
+        (replace 'build
+          (lambda* (#:key outputs configure-flags #:allow-other-keys)
+            (let ((out (assoc-ref outputs "out")))
+              (copy-recursively
+               "src/git.torproject.org/pluggable-transports/obfs4.git"
+               "src/gitlab.com/yawning/obfs4.git"
+               #:log (%make-void-port "w"))
+              (with-directory-excursion
+               "src/git.torproject.org/pluggable-transports/obfs4.git/obfs4proxy"
+               (invoke "go" "build" "-ldflags" "-s"))
+            #t)))
+        (replace 'install
+          (lambda* (#:key outputs #:allow-other-keys)
+            (let* ((out (assoc-ref outputs "out"))
+                   (src "src/git.torproject.org/pluggable-transports/obfs4.git")
+                   (bin (string-append out "/bin"))
+                   (share (string-append out "/share"))
+                   (doc (string-append share "/doc"))
+                   (man (string-append share "/man/man1")))
+              (mkdir-p man)
+              (mkdir bin)
+              (mkdir doc)
+              (with-directory-excursion
+               (string-append src "/obfs4proxy")
+               (copy-file "obfs4proxy"
+                          (string-append bin "/obfs4proxy")))
+              (with-directory-excursion
+               (string-append src "/doc")
+               (copy-file "obfs4proxy.1"
+                          (string-append man "/obfs4proxy.1"))
+               (copy-file "obfs4-spec.txt"
+                          (string-append doc "/obfs4-spec.txt")))
+            #t))))))
+   (propagated-inputs
+    `(("go-torproject-org-ptlib" ,go-torproject-org-ptlib)
+      ("go-github-com-agl-ed25519" ,go-github-com-agl-ed25519)
+      ("go-github-com-dchest-siphash" ,go-github-com-dchest-siphash)
+      ("go-github-com-dchest-uniuri" ,go-github-com-dchest-uniuri)
+      ("go-github-com-dsnet-compress" ,go-github-com-dsnet-compress)
+      ("go-schwanenlied-me-yawning-bsaes" ,go-schwanenlied-me-yawning-bsaes)
+      ("go-gitlab-com-yawning-utls" ,go-gitlab-com-yawning-utls)
+      ("go-golang-org-x-net" ,go-golang-org-x-net)
+      ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)
+      ("go-golang-org-x-text" ,go-golang-org-x-text)))
+   (home-page "https://git.torproject.org/pluggable-transports/obfs4.git")
+   (synopsis "Obfs4 implements an obfuscation protocol")
+   (description "This is a look-like nothing obfuscation protocol that
+incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol.
+The obfs naming was chosen primarily because it was shorter, in terms of
+protocol ancestery obfs4 is much closer to ScrambleSuit than obfs2/obfs3.")
+   (license license:gpl3+)))
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 9/9] gnu: Add torbrowser-unbundle
  2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
                               ` (7 preceding siblings ...)
  2020-09-15 15:15             ` [bug#42380] [PATCH 8/9] gnu: obfs4 André Batista
@ 2020-09-15 15:16             ` André Batista
  2020-09-24 23:18               ` [bug#42380] [PATCHv2 " André Batista
  8 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2020-09-15 15:16 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Efraim Flashner, 42380


[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #1.2: 0001-gnu-Add-torbrowser-unbundle.patch --]
[-- Type: text/plain, Size: 55554 bytes --]

From 84070de582d33d47f2684bdee69b1e0b478c2352 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Mon, 14 Sep 2020 22:39:59 -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        | 226 +++++
 gnu/packages/tor.scm                          | 830 +++++++++++++++++-
 4 files changed, 1080 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/torbrowser-start-tor-browser.desktop.patch
 create mode 100644 gnu/packages/patches/torbrowser-start-tor-browser.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 1baa8405c5..1715068b6c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -37,6 +37,7 @@
 # Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
 # Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
 # Copyright © 2020 Martin Becze <mjbecze@riseup.net>
+# Copyright © 2020 André Batista <nandre@riseup.net>
 #
 # This file is part of GNU Guix.
 #
@@ -1615,6 +1616,8 @@ dist_patch_DATA =						\
   %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.patch 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.desktop.orign	2020-07-05 18:47:40.689484877 -0300
++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser.desktop	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 shell.
+ # It preserves arguments and environment for the start-tor-browser script.
+@@ -28,7 +28,7 @@
+ GenericName=Web Browser
+ Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
+ Categories=Network;WebBrowser;Security;
+-Exec=sh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/start-tor-browser --detach)' dummy %k
+-X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
+-Icon=web-browser
++Exec=bash -c start-tor-browser
++X-TorBrowser-ExecShell=start-tor-browser --detach
++Icon=torbrowser
+ StartupWMClass=Tor 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..c563f94003
--- /dev/null
+++ b/gnu/packages/patches/torbrowser-start-tor-browser.patch
@@ -0,0 +1,226 @@
+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.orig	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.
+ 
++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"
++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
+@@ -106,14 +115,11 @@
+     printf "  --verbose         Display Tor and Firefox output in the terminal\n"
+     printf "  --log [file]      Record Tor and Firefox output in file (default: tor-browser.log)\n"
+     printf "  --detach          Detach from terminal and run Tor Browser in the background.\n"
+-    printf "  --register-app    Register Tor Browser as a desktop app for this user\n"
+-    printf "  --unregister-app  Unregister Tor Browser as a desktop app for this user\n"
+ }
+ log_output=0
+ show_output=0
+ detach=0
+ show_usage=0
+-register_desktop_app=0
+ logfile=/dev/null
+ while :
+ do
+@@ -134,8 +140,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"
+@@ -148,16 +154,6 @@
+           log_output=1
+           shift
+           ;;
+-      --register-app)
+-          register_desktop_app=1
+-          show_output=1
+-          shift
+-          ;;
+-      --unregister-app)
+-          register_desktop_app=-1
+-          show_output=1
+-          shift
+-          ;;
+       *) # No more options
+           break
+           ;;
+@@ -187,41 +183,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,50 +214,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/"
+-	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
+-fi
+-
+-if [ "$register_desktop_app" -eq -1 ]; then
+-	if [ -e "$HOME/.local/share/applications/start-tor-browser.desktop" ]; then
+-		rm -f "$HOME/.local/share/applications/start-tor-browser.desktop"
+-		update-desktop-database "$HOME/.local/share/applications/"
+-		printf "Tor Browser has been removed as a user desktop app (from ~/.local/share/applications/)\n"
+-	else
+-		printf "Tor Browser does not appear to be a desktop app (not present in ~/.local/share/applications/)\n"
+-	fi
+-	exit 0
+-fi
+-
+ 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 +279,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,<dir>fonts</dir>,<dir>${TBB_STORE_PATH}/fonts</dir>,"
++
+ cd "${HOME}"
+ 
+ # We pass all additional command-line arguments we get to Firefox.
+@@ -357,23 +296,23 @@
+ 
+ if [ "$show_usage" -eq 1 ]; then
+     # Display Firefox help, then our help
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default --help 2>/dev/null
++    TOR_CONTROL_PASSWD=${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=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-       -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++       -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
+     disown "$!"
+ elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
+         tee "$logfile"
+ elif [ "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" < /dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" < /dev/null
+ else
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
+ fi
+ 
+ exit $?
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index dd362d3af8..bc7a3486f8 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -32,26 +32,63 @@
   #:use-module (guix utils)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix build-system cargo)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages assembly)
+  #:use-module (gnu packages audio)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cups)
+  #:use-module (gnu packages databases)
+  #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages gl)
+  #:use-module (gnu packages glib)
+  #:use-module (gnu packages gnome)
   #:use-module (gnu packages golang)
+  #:use-module (gnu packages gtk)
+  #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages image)
+  #:use-module (gnu packages kerberos)
+  #:use-module (gnu packages libcanberra)
   #:use-module (gnu packages libevent)
+  #:use-module (gnu packages libffi)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages llvm)
+  #:use-module (gnu packages node)
+  #:use-module (gnu packages nss)
   #:use-module (gnu packages pcre)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-crypto)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages qt)
+  #:use-module (gnu packages readline)
+  #:use-module (gnu packages rsync) ; for httpse
+  #:use-module (gnu packages rust)
+  #:use-module (gnu packages rust-apps)
+  #:use-module (gnu packages sqlite)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages w3m))
+  #:use-module (gnu packages version-control)
+  #:use-module (gnu packages video)
+  #:use-module (gnu packages vim) ; for xxd
+  #:use-module (gnu packages w3m)
+  #:use-module (gnu packages xdisorg)
+  #:use-module (gnu packages xiph)
+  #:use-module (gnu packages xorg)
+  #:use-module (gnu packages xml) ; for httpse
+  #:use-module (ice-9 match)
+  #:use-module ((srfi srfi-1) #:hide (zip)))
 
 (define-public tor
   (package
@@ -398,3 +435,794 @@ incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol.
 The obfs naming was chosen primarily because it was shorter, in terms of
 protocol ancestery obfs4 is much closer to ScrambleSuit than obfs2/obfs3.")
    (license license:gpl3+)))
+
+;; Upstream does not seem to keep tor-browser and tor-browser-build versions
+;; in sync
+(define %torbrowser-version "68.12.0esr-9.5-1")
+(define %torbrowser-build-version "9.5.4")
+(define %torbrowser-build "build1")
+(define %torbrowser-build-id "20200729000000");must be of the form YYYYMMDDhhmmss
+
+;; Fonts for Tor Browser. Avoid downloading 4Gb+ git repo on
+;; https://github.com/googlei18n/noto-fonts.git to use just a handful.
+;; Use the fonts on Tor Browser release tarball.
+(define torbrowser-fonts
+  (package
+   (name "torbrowser-fonts")
+   ; Tor Browser fonts did not change since last release and were not available
+   ; when this version was built, the previous version were kept.
+   ;(version %torbrowser-build-version)
+   (version "9.5.3")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (string-append "https://dist.torproject.org/torbrowser/"
+                         version "/tor-browser-linux64-"
+                         version "_en-US.tar.xz"))
+     (sha256
+      (base32
+       "1kqvr0sag94xdkq85k426qq1hz2b52m315yz51w6hvc87d8332b4"))))
+   (build-system trivial-build-system)
+   (native-inputs
+    `(("tar" ,tar)
+      ("xz" ,xz)))
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (let ((src (assoc-ref %build-inputs "source"))
+                        (src-dir "tor-browser_en-US/Browser/fonts")
+                        (fonts (string-append %output "/share/fonts"))
+                        (tar (assoc-ref %build-inputs "tar"))
+                        (xz (assoc-ref %build-inputs "xz")))
+                    (mkdir-p fonts)
+                    (format #t "Untaring torbrowser ball ...~%")
+                    (invoke (string-append tar "/bin/tar") "-xf" src
+                            "-C" fonts "--strip-components=3"
+                            (string-append "--use-compress-program=" xz "/bin/xz")
+                            src-dir)
+                    #t))))
+   (home-page "https://github.com/googlei18n/noto-fonts")
+   (synopsis "Tor Browser bundled fonts")
+   (description "Free fonts bundled with Tor Browser.  Includes a subset of Noto,
+Arimo, Cousine, Tinos and STIX fonts.")
+   (license license:silofl1.1)))
+
+(define tor-browser-build
+  (let ((commit (string-append "tbb-" %torbrowser-build-version
+                               "-" %torbrowser-build)))
+    (package
+     (name "tor-browser-build")
+     (version %torbrowser-build-version)
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.torproject.org/builders/tor-browser-build.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0mq9ml8p0l2nnwjgr6dqn00pzk7h5zpi3hhr093hq99bapxs3wcs"))))
+     (build-system trivial-build-system)
+     (arguments
+      `(#:modules ((guix build utils))
+        #:builder (begin
+                    (use-modules (guix build utils))
+                    (format #t "Copying build scripts ...~%")
+                    (copy-recursively (string-append
+                                       (assoc-ref %build-inputs "source")
+                                       "/projects/tor-browser")
+                                      %output
+                                      #:log (%make-void-port "w")))))
+     (home-page "https://www.torproject.org")
+     (synopsis "Tor Browser Builder scripts")
+     (description "Tor Browser build and runtime scripts.")
+     (license (license:non-copyleft "file://LICENSE")))))
+
+(define torbutton
+  (let ((commit "ebe2bedab44e38f18c7968bd327d99eef7660f34"))
+    (package
+     (name "torbutton")
+     (version %torbrowser-build-version)
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.torproject.org/torbutton.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "03xdyszab1a8j98xv6440v4lq58jkfqgmhxc2a62qz8q085d2x83"))))
+     (build-system trivial-build-system)
+     (arguments
+      `(#:modules ((guix build utils))
+        #:builder (begin
+                    (use-modules (guix build utils))
+                    (format #t "Copying source ...~%")
+                    (copy-recursively (assoc-ref %build-inputs "source")
+                                      %output
+                                      #:log (%make-void-port "w")))))
+     (home-page "https://www.torproject.org")
+     (synopsis "Tor Browser built-in extension")
+     (description "Browser extension needed to build and run Tor Browser.")
+     (license (license:non-copyleft "file://LICENSE")))))
+
+(define tor-launcher
+  (package
+   (name "tor-launcher")
+   (version "0.2.21.8")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://git.torproject.org/tor-launcher.git")
+           (commit version)))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "1mm1z7gv9dv6ymbr3vsg0lsnhnn84zrb6qsa164hmaxcfrwfhz5d"))))
+   (build-system trivial-build-system)
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (format #t "Copying source ...~%")
+                  (copy-recursively (assoc-ref %build-inputs "source")
+                                    %output
+                                    #:log (%make-void-port "w")))))
+   (home-page "https://www.torproject.org")
+   (synopsis "Tor Browser built-in controler extension")
+   (description "Browser extension that starts the tor process (which
+connects the browser and other applications to the Tor Network), and
+which helps people configure and use @code{tor}. The first window that
+you see when you start Tor Browser is displayed by this extension.")
+   (license (license:non-copyleft "file://src/LICENSE"))))
+
+;; This package is actually a cargo crate, so it should be moved to
+;; crates-io.scm and made public once the cross building to wasm32 is
+;; successful.
+(define https-everywhere-lib-wasm
+  (let ((commit "af199004083ce200f285735f68a5a57c47eed0e6"))
+  (package
+   (name "https-everywhere-lib-wasm")
+   (version "2020.08.13")
+   (source
+    (origin
+     (method git-fetch)
+      (uri (git-reference
+            (url "https://github.com/EFForg/https-everywhere-lib-wasm")
+            (commit commit)))
+      (file-name (git-file-name name version))
+      (sha256
+       (base32
+        "14xv637hf9kzdyr2w0cvx0g5if9nrzflf29p1spdl228yqlv9d5r"))))
+   (build-system trivial-build-system)
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (format #t "Copying source ...~%")
+                  (copy-recursively (assoc-ref %build-inputs "source")
+                                    %output
+                                    #:log (%make-void-port "w")))))
+   (home-page "https://github.com/EFForg/https-everywhere-lib-wasm")
+   (synopsis "Rust library for https-everywhere browser extension")
+   (description "Rust library for https-everywhere browser
+extension.")
+   (license license:gpl2+))))
+
+;; This should probably go elsewhere on the file system and made
+;; public in order to be shared between Tor Browser and IceCat once
+;; lib-wasm gets fixed.
+(define https-everywhere
+  (package
+   (name "https-everywhere")
+   (version "2020.8.13")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (string-append "https://github.com/EFForg/" name
+                         "/archive/" version ".tar.gz"))
+     (sha256
+      (base32
+       "0xb8q7izlyq80zzvj2j7wqp3srxxmi0wgwrb47lc5w38r7yzqjjd"))))
+   (build-system trivial-build-system)
+   (native-inputs
+    `(("bash" ,bash)
+      ("coreutils" ,coreutils)
+      ("findutils" ,findutils)
+      ("git" ,git)
+      ("grep" ,grep)
+      ("gzip" ,gzip)
+      ("https-everywhere-lib-wasm"
+       ,https-everywhere-lib-wasm)
+      ("libxml2" ,libxml2)
+      ("libxslt" ,libxslt)
+      ("openssl" ,openssl)
+      ("python" ,python)
+      ("rsync" ,rsync)
+      ("sed" ,sed)
+      ("tar" ,tar)
+      ("util-linux" ,util-linux) ; for getopt
+      ("which" ,which)
+      ("xxd" ,xxd)
+      ("zip" ,zip)))
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (let ((src (assoc-ref %build-inputs "source"))
+                        (httpse-libwasm (assoc-ref %build-inputs
+                                                   "https-everywhere-lib-wasm"))
+                        (bash (assoc-ref %build-inputs "bash"))
+                        (coreutils (assoc-ref %build-inputs "coreutils"))
+                        (findutils (assoc-ref %build-inputs "findutils"))
+                        ;; Might be worth patching make.sh and remove this.
+                        (git (assoc-ref %build-inputs "git"))
+                        (grep (assoc-ref %build-inputs "grep"))
+                        (gzip (assoc-ref %build-inputs "gzip"))
+                        (libxml2 (assoc-ref %build-inputs "libxml2"))
+                        (libxslt (assoc-ref %build-inputs "libxslt"))
+                        (openssl (assoc-ref %build-inputs "openssl"))
+                        (python (assoc-ref %build-inputs "python"))
+                        ;; Possibly not needed and used to update rules at
+                        ;; build time.
+                        (rsync (assoc-ref %build-inputs "rsync"))
+                        (sed (assoc-ref %build-inputs "sed"))
+                        (tar (assoc-ref %build-inputs "tar"))
+                        (util-linux (assoc-ref %build-inputs "util-linux"))
+                        (which (assoc-ref %build-inputs "which"))
+                        (xxd (assoc-ref %build-inputs "xxd"))
+                        (zip (assoc-ref %build-inputs "zip")))
+                    (setenv "SHELL" (string-append bash "/bin/bash"))
+                    (set-path-environment-variable
+                     "PATH" '("bin")
+                     (list bash sed findutils which git python tar openssl rsync
+                           libxml2 libxslt util-linux grep xxd gzip zip coreutils))
+                    (set-path-environment-variable
+                     "LIBRARY_PATH" '("lib")
+                     (list bash sed findutils which git python tar openssl rsync
+                           libxml2 libxslt util-linux grep xxd gzip zip coreutils))
+                    (format #t "Untaring source tarball ...~%")
+                    (invoke "tar" "-xf" src "--strip-components=1")
+                    ;; Python3.6 is hardcoded on these scripts. Using v3.8 appears
+                    ;; to be harmless.
+                    (substitute*
+                     '("install-dev-dependencies.sh"
+                       "make.sh"
+                       "hooks/precommit"
+                       "test/firefox.sh"
+                       "test/manual.sh"
+                       "test/rules/src/https_everywhere_checker/check_rules.py"
+                       "test/script.py"
+                       "test/validations.sh"
+                       "test/validations/filename/run.py"
+                       "test/validations/relaxng/run.py"
+                       "test/validations/securecookie/run.py"
+                       "test/validations/special/run.py"
+                       "utils/create_zip.py"
+                       "utils/chromium-translations.py"
+                       "utils/create-platform-certs/split_combined_cert_file.py"
+                       "utils/mk-client-whitelist/dbconnect.py"
+                       "utils/mk-client-whitelist/run.py"
+                       "utils/merge-rulesets.py"
+                       "utils/setversion.py"
+                       "utils/zipfile_deterministic.py")
+                     (("python3.6") "python3"))
+                    (make-file-writable "lib-wasm")
+                    (copy-recursively httpse-libwasm
+                                      "lib-wasm"
+                                      #:log (%make-void-port "w"))
+                    ;; Remove precompiled binaries from source. This breaks
+                    ;; http-everywhere at runtime, but building is successful.
+                    ;; Once lib-wasm is successfuly cross-compiled to wasm,
+                    ;; remove this.
+                    (with-directory-excursion "lib-wasm/pkg"
+                      (for-each (lambda (file)
+                        (if (file-exists? file)
+                            (delete-file file)
+                            (display (string-append
+                             "Warning: file " file
+                             " not found! Skipping...\n"))))
+                        '("https_everywhere_lib_wasm.js"
+                          "https_everywhere_lib_wasm_bg.wasm")))
+                    (for-each patch-shebang
+                              (find-files "."
+                                          (lambda (file stat)
+                                            ;; Filter out symlinks.
+                                            (eq? 'regular (stat:type stat)))
+                                          #:stat lstat))
+                    ;; Failing to generate the xpi, but copy-dir appears to be
+                    ;; enough.
+                    (invoke "./make.sh")
+                    (copy-recursively "pkg/xpi-eff" %output
+                                      #:log (%make-void-port "w"))
+                    #t))))
+   (home-page "https://www.eff.org/https-everywhere")
+   (synopsis "Browser extension for automatic HTTPS usage")
+   (description "Browser extension that automatically makes the browser to
+use HTTPS instead of plain HTTP when the remote destination makes it
+available to users.")
+   (license license:gpl2+)))
+
+;; Currently there seems to be no binaries on this package, but in
+;; order to avoid the possibility of one getting silently added,
+;; this needs reworking to make it build from source.
+(define noscript
+  (package
+   (name "noscript")
+   (version "11.0.38")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (string-append "https://secure.informaction.com/download/releases/"
+                         name "-" version ".xpi"))
+     (sha256
+      (base32
+       "0f77dh1qj02ayrxiz98px0kl0dlza65fpjzq56nsmhrxmmyrby4c"))))
+   (build-system trivial-build-system)
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (format #t "Copying source ...~%")
+                  (copy-file (assoc-ref %build-inputs "source")
+                             %output))))
+   (home-page "https://noscript.net")
+   (synopsis "Browser extension for protection against known attacks")
+   (description "Browser extension that protects users from a range of
+known attacks on web browsing activity such as Cross-site scripting, clickjack
+and makes possible for the users to block or choose on a per site basis which
+remote javascript to run while browsing the web.")
+   (license license:gpl2+)))
+
+;; (Un)fortunatly Tor Browser has it's own reproducible build system - RBM -
+;; which automates the build process for them and compiles Tor Browser from a
+;; range of repositories and produces a range of tarballs for different
+;; architectures and locales. So we need to cherry-pick what is needed for
+;; guix and produce our own tarball. See
+;; https://gitweb.torproject.org/builders/tor-browser-build.git/projects/\
+;; {tor-browser,firefox}/{build,config} for the rationale applied here. See
+;; also the Hacking on Tor Browser document for a high level introduction at
+;; https://trac.torproject.org/projects/tor/wiki/doc/Tor Browser/Hacking.
+;;
+;; TODO: Import langpacks.
+(define-public torbrowser-unbundle
+  (let ((commit (string-append "tor-browser-" %torbrowser-version
+                               "-" %torbrowser-build)))
+    (package
+     (name "torbrowser-unbundle")
+     (version %torbrowser-build-version)
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.torproject.org/tor-browser.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "02pxbhv64l575p2s2i365v53qyqynn272f64b6gqfrcvhn920g09"))))
+     (build-system gnu-build-system)
+     (inputs
+      `(("alsa-lib" ,alsa-lib)
+        ("bzip2" ,bzip2)
+        ("cups" ,cups)
+        ("dbus-glib" ,dbus-glib)
+        ("ffmpeg" ,ffmpeg)
+        ("freetype" ,freetype)
+        ("gdk-pixbuf" ,gdk-pixbuf)
+        ("glib" ,glib)
+        ("gtk+" ,gtk+)
+        ("gtk+-2" ,gtk+-2)
+        ("graphite2" ,graphite2)
+        ("harfbuzz" ,harfbuzz)
+        ("icu4c" ,icu4c)
+        ("libcanberra" ,libcanberra)
+        ("libgnome" ,libgnome)
+        ("libjpeg-turbo" ,libjpeg-turbo)
+        ("libogg" ,libogg)
+        ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
+        ("libvorbis" ,libvorbis)
+        ("libxft" ,libxft)
+        ("libevent" ,libevent)
+        ("libxinerama" ,libxinerama)
+        ("libxscrnsaver" ,libxscrnsaver)
+        ("libxcomposite" ,libxcomposite)
+        ("libxt" ,libxt)
+        ("libffi" ,libffi)
+        ("libvpx" ,libvpx)
+        ("mesa" ,mesa)
+        ("mit-krb5" ,mit-krb5)
+        ;; See <https://bugs.gnu.org/32833>
+        ;;   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)
+        ("zlib" ,zlib)))
+     (native-inputs
+      `(("autoconf" ,autoconf-2.13)
+        ("bash" ,bash)
+        ("cargo" ,rust "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)
+        ("noscript" ,noscript)
+        ("rust" ,rust)
+        ("rust-cbindgen" ,rust-cbindgen)
+        ("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 <http://hydra.gnu.org/build/378133>.
+        #:validate-runpath? #f
+        #:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
+        ;; This modules where copied from IceCat package definition and some
+        ;; of them are probably not needed anymore. TODO: verify if/which
+        ;; are still needed.
+        #: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.desktop")))
+              #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 inputs)
+                                                     "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))
+
+          ;; 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
+                     "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
+                (substitute* '("Cargo.lock" "gfx/wr/Cargo.lock")
+                  (("(\"checksum .* = )\".*\"" all name)
+                   (string-append name "\"" null-hash "\"")))
+                (generate-all-checksums "third_party/rust"))
+              #t))
+
+          (add-after 'build 'neutralize-store-references
+            (lambda _
+              ;; Mangle the store references to compilers & other build tools in
+              ;; about:buildconfig, reducing Tor Browser's closure significant.
+              ;; 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)
+                               "<!-- Guix: not a runtime dependency -->"
+                               (string-drop hash 8))))
+              #t))
+
+          (replace 'configure
+            (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bash (which "bash"))
+                     (flags `(,(string-append "--prefix=" 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 "MOZ_BUILD_DATE"
+                        ,%torbrowser-build-id) ; avoid timestamp.
+                (setenv "LDFLAGS" (string-append
+                                   "-Wl,-rpath="
+                                   (assoc-ref outputs "out")
+                                   "/lib/firefox"))
+                ;; This needs reworking to use the mozconfig available on
+                ;; tor-browser-builder repo which is the one Tor Project
+                ;; actually uses and which warranted some of the changes
+                ;; below.
+                (substitute* ".mozconfig"
+                  ;; Arch independent builddir.
+                  (("(mk_add_options MOZ_OBJDIR=@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=dev-build")
+                   (string-append
+                    "ac_add_options --with-tor-browser-version=org.gnu\n"
+                    "ac_add_options --with-unsigned-addon-scopes=app\n"
+                    "ac_add_options --enable-pulseaudio\n"
+                    "ac_add_options --disable-debug-symbols\n"
+                    "ac_add_options --disable-updater\n"
+                    "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"
+                    "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="
+                    (assoc-ref %build-inputs "clang") "/bin/clang\n"
+                    "ac_add_options --with-libclang-path="
+                    (assoc-ref %build-inputs "clang") "/lib\n")))
+
+                (substitute* "browser/app/profile/000-tor-browser.js"
+                  ;; Tor Browser updates are disabled on mozconfig, but let's be sure.
+                  (("(pref\\(\"extensions.torbutton.versioncheck_enabled\").*" _ m)
+                   (string-append m ",false);\n")))
+
+                (substitute*
+                 "browser/extensions/tor-launcher/src/defaults/preferences/torlauncher-prefs.js"
+                  ;; Not multilingual. See tor-browser/build:141. Currently disabled on
+                  ;; tor-launcher, but let's make sure while missing langpacks.
+                 (("(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 _ (invoke "./mach" "build")
+              #t))
+
+          ;; Tor Browser just do a stage-package here and copy files to its 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" "libnssdbm3.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") #o555)
+                (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/default")))
+                (with-directory-excursion
+                 icons-src
+                 (for-each
+                   (lambda (file)
+                     (let* ((size (string-filter char-numeric? file))
+                            (icons (string-append out "/share/icons/hicolor/"
+                                                  size "x" size "/apps")))
+                       (mkdir-p icons)
+                       (copy-file file (string-append icons "/torbrowser.png"))))
+                   '("default16.png" "default32.png" "default48.png" "default64.png"
+                     "default128.png"))))
+              #t))
+
+          (add-after 'install-icons 'install-fonts
+            (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (lib (string-append out "/lib/firefox/"))
+                     (fonts  (string-append (or (assoc-ref native-inputs
+                                                           "torbrowser-fonts")
+                                                (assoc-ref inputs
+                                                           "torbrowser-fonts"))
+                                            "/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-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (ext (string-append out "/lib/firefox/browser/extensions"))
+                     (noscript-id "{73a6fe31-595d-460b-a920-fcc0f8843232}")
+                     (httpse-id "https-everywhere-eff@eff.org")
+                     (noscript (assoc-ref inputs "noscript"))
+                     (httpse (assoc-ref inputs "https-everywhere")))
+                (mkdir-p ext)
+                (copy-file noscript (string-append
+                                     ext "/" noscript-id ".xpi"))
+                (copy-recursively httpse
+                                  (string-append ext "/" httpse-id)
+                                  #:log (%make-void-port "w"))
+                (chmod (string-append ext "/" noscript-id ".xpi") #o555))
+              #t))
+
+          (add-after 'install-extensions 'link-binaries
+            (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (tordir (string-append out "/lib/firefox/TorBrowser/Tor"))
+                     (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-keys)
+              (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 "/" file)
+                                               #:log (%make-void-port "w")))
+                           '("Browser" "fontconfig" "Tor")))
+                (copy-file (string-append ptconf "/linux/torrc-defaults-appendix")
+                           (string-append data "/Tor/torrc-defaults-appendix"))
+                (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
+the only recommended way to anonymously browse the web that is supported by
+the project.  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.
+Https-everywhere browser extension is currently not working so use it 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
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] Wow!
  2020-09-12 13:35 ` [bug#42380] Wow! Raghav Gururajan
@ 2020-09-15 15:23   ` André Batista
  2021-05-25 15:05     ` Xinglu Chen
  0 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2020-09-15 15:23 UTC (permalink / raw)
  To: Raghav Gururajan; +Cc: 42380

[-- Attachment #1: Type: text/plain, Size: 620 bytes --]

Hello Raghav,

sáb 12 set 2020 às 09:35:17 (1599914117), raghavgururajan@disroot.org enviou:
> 
> Thank you all for the hard work. This is a high-time package.

Thank you as well. :)

> Any idea on when it can be merged to master?, at-least a minimally
> viable package?

As of now, I think it's a viable package, but there's still room
for improvement on its definition. If you also care that this
package is available on Guix, I guess the easiest and most
important thing to do right now is to apply the patch series
that I've sent, try it out and report back on your experience.

Happy hacking!



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 2v2/9] gnu: Add go-github-com-agl-ed25519
  2020-09-15 15:04             ` [bug#42380] [PATCH 2/9] gnu: Add go-github-com-agl-ed25519 André Batista
@ 2020-09-15 22:50               ` André Batista
  0 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2020-09-15 22:50 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 65 bytes --]

There was an indentation error which is fixed on this version.



[-- Attachment #1.2: 0001-gnu-Add-go-github-com-agl-ed25519.patch --]
[-- Type: text/plain, Size: 2538 bytes --]

From eee248ad09b5c90522be5cb3cb3f40d8ad73ec20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Tue, 15 Sep 2020 19:35:56 -0300
Subject: [PATCH] gnu: Add go-github-com-agl-ed25519.
To: 42380@debbugs.gnu.org

* gnu/packages/golang.scm (go-github-com-agl-ed25519): New variable.
---
 gnu/packages/golang.scm | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 0bcb01fd2f..877295de72 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -5680,3 +5680,41 @@ error messages.")
 Transports are a means of connecting to the Tor Network from places where it
 is censored.")
    (license license:cc0)))
+
+(define-public go-github-com-agl-ed25519
+  (let ((commit "c4161f4c7483313562781c61b9a20aba73daf9de")
+        (revision "0"))
+    (package
+     (name "go-github-com-agl-ed25519")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/agl/ed25519")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "1wjlbzi0w63rmlzgk3amw274wsl0zhcn4yx2lraffbkhqappahxc"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/agl/ed25519"
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'reset-gzip-timestamps 'make-files-writable
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let ((out (assoc-ref outputs "out")))
+                (for-each (lambda (file) (chmod file #o644))
+                  (find-files out "\\.gz"))
+              #t))))))
+     (home-page "https://github.com/agl/ed25519")
+     (synopsis "Go library for ed25519 public-key signatures")
+     (description "This library is a Go implementation of ed25519 public-key
+signature system which was designed to be faster than previous digital signature
+systems without sacrificing security.  It is currently used in the
+implementation of obfs4 and should be not be used on newer projects since it
+is unmaintained.  Newer software should use x-crypto instead.")
+     ;; License file is referred but it is missing. Probably because the
+     ;; author decided to discontinue the project.
+     (license (license:non-copyleft "file://ed25519.go")))))
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH 3/9] gnu: Add go-github-com-dchest-siphash
  2020-09-15 15:06             ` [bug#42380] [PATCH 0/9] gnu: Add go-github-com-dchest-siphash André Batista
@ 2020-09-15 22:53               ` André Batista
  0 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2020-09-15 22:53 UTC (permalink / raw)
  To: 42380

[-- Attachment #1: Type: text/plain, Size: 84 bytes --]

Just in case, the 'zero' on the subject was a mistake.

My apologies for the noise.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCHv2 9/9] gnu: Add torbrowser-unbundle
  2020-09-15 15:16             ` [bug#42380] [PATCH 9/9] gnu: Add torbrowser-unbundle André Batista
@ 2020-09-24 23:18               ` André Batista
  2020-10-07 15:51                 ` [bug#42380] [PATCHv3 " André Batista
  0 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2020-09-24 23:18 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 743 bytes --]

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.

[-- Attachment #1.2: 0001-gnu-Add-torbrowser-unbundle.patch --]
[-- Type: text/plain, Size: 56690 bytes --]

From f0e529147d7481c48395c741022e5ef8b3bc1c9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
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.desktop.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 © 2020 Brice Waegeneire <brice@waegenei.re>
 # Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
 # Copyright © 2020 Martin Becze <mjbecze@riseup.net>
+# Copyright © 2020 André Batista <nandre@riseup.net>
 #
 # This file is part of GNU Guix.
 #
@@ -1623,6 +1624,8 @@ dist_patch_DATA =						\
   %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.patch 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.desktop.orign	2020-07-05 18:47:40.689484877 -0300
++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser.desktop	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 shell.
+ # It preserves arguments and environment for the start-tor-browser script.
+@@ -28,7 +28,7 @@
+ GenericName=Web Browser
+ Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
+ Categories=Network;WebBrowser;Security;
+-Exec=sh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/start-tor-browser --detach)' dummy %k
+-X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
+-Icon=web-browser
++Exec=bash -c start-tor-browser
++X-TorBrowser-ExecShell=start-tor-browser --detach
++Icon=torbrowser
+ StartupWMClass=Tor 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.orig 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.
+ 
++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"
++##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 +143,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 +196,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 +227,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 +249,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 +311,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,<dir>fonts</dir>,<dir>${TBB_STORE_PATH}/fonts</dir>,"
++
+ cd "${HOME}"
+ 
+ # We pass all additional command-line arguments we get to Firefox.
+@@ -357,23 +328,23 @@
+ 
+ if [ "$show_usage" -eq 1 ]; then
+     # Display Firefox help, then our help
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default --help 2>/dev/null
++    TOR_CONTROL_PASSWD=${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=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-       -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++       -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
+     disown "$!"
+ elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
+         tee "$logfile"
+ elif [ "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" < /dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" < /dev/null
+ else
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
+ fi
+ 
+ exit $?
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index b1e417f29c..13ee611385 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -32,26 +32,63 @@
   #:use-module (guix utils)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix build-system cargo)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages assembly)
+  #:use-module (gnu packages audio)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cups)
+  #:use-module (gnu packages databases)
+  #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages gl)
+  #:use-module (gnu packages glib)
+  #:use-module (gnu packages gnome)
   #:use-module (gnu packages golang)
+  #:use-module (gnu packages gtk)
+  #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages image)
+  #:use-module (gnu packages kerberos)
+  #:use-module (gnu packages libcanberra)
   #:use-module (gnu packages libevent)
+  #:use-module (gnu packages libffi)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages llvm)
+  #:use-module (gnu packages node)
+  #:use-module (gnu packages nss)
   #:use-module (gnu packages pcre)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-crypto)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages qt)
+  #:use-module (gnu packages readline)
+  #:use-module (gnu packages rsync) ; for httpse
+  #:use-module (gnu packages rust)
+  #:use-module (gnu packages rust-apps)
+  #:use-module (gnu packages sqlite)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages w3m))
+  #:use-module (gnu packages version-control)
+  #:use-module (gnu packages video)
+  #:use-module (gnu packages vim) ; for xxd
+  #:use-module (gnu packages w3m)
+  #:use-module (gnu packages xdisorg)
+  #:use-module (gnu packages xiph)
+  #:use-module (gnu packages xorg)
+  #:use-module (gnu packages xml) ; for httpse
+  #:use-module (ice-9 match)
+  #:use-module ((srfi srfi-1) #:hide (zip)))
 
 (define-public tor
   (package
@@ -398,3 +435,830 @@ incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol.
 The obfs naming was chosen primarily because it was shorter, in terms of
 protocol ancestery obfs4 is much closer to ScrambleSuit than obfs2/obfs3.")
    (license license:gpl3+)))
+
+;; Upstream does not seem to keep tor-browser and tor-browser-build versions
+;; in sync
+(define %torbrowser-version "78.3.0esr-10.0-2")
+(define %torbrowser-build-version "10.0")
+(define %torbrowser-build "build2")
+(define %tbb-build "build3")
+(define %torbrowser-build-id "20200820000000");must be of the form YYYYMMDDhhmmss
+
+;; Fonts for Tor Browser. Avoid downloading 4Gb+ git repo on
+;; https://github.com/googlei18n/noto-fonts.git to use just a handful.
+;; Use the fonts on Tor Browser release tarball.
+(define torbrowser-fonts
+  (package
+   (name "torbrowser-fonts")
+   ; Tor Browser fonts did not change since last release and were not available
+   ; when this version was built, the previous version were kept.
+   ; (version %torbrowser-build-version)
+   (version "9.5.3")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (string-append "https://dist.torproject.org/torbrowser/"
+                         version "/tor-browser-linux64-"
+                         version "_en-US.tar.xz"))
+     (sha256
+      (base32
+       "1kqvr0sag94xdkq85k426qq1hz2b52m315yz51w6hvc87d8332b4"))))
+   (build-system trivial-build-system)
+   (native-inputs
+    `(("tar" ,tar)
+      ("xz" ,xz)))
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (let ((src (assoc-ref %build-inputs "source"))
+                        (src-dir "tor-browser_en-US/Browser/fonts")
+                        (fonts (string-append %output "/share/fonts"))
+                        (tar (assoc-ref %build-inputs "tar"))
+                        (xz (assoc-ref %build-inputs "xz")))
+                    (mkdir-p fonts)
+                    (format #t "Untaring torbrowser ball ...~%")
+                    (invoke (string-append tar "/bin/tar") "-xf" src
+                            "-C" fonts "--strip-components=3"
+                            (string-append "--use-compress-program=" xz "/bin/xz")
+                            src-dir)
+                    #t))))
+   (home-page "https://github.com/googlei18n/noto-fonts")
+   (synopsis "Tor Browser bundled fonts")
+   (description "Free fonts bundled with Tor Browser.  Includes a subset of Noto,
+Arimo, Cousine, Tinos and STIX fonts.")
+   (license license:silofl1.1)))
+
+(define tor-browser-build
+  (let ((commit (string-append "tbb-" %torbrowser-build-version
+                               "-" %tbb-build)))
+    (package
+     (name "tor-browser-build")
+     (version %torbrowser-build-version)
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.torproject.org/builders/tor-browser-build.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "14wawaf555dvr3dznphyz4sd3r8q53klhrcb8igiadmdx8wqc33m"))))
+     (build-system trivial-build-system)
+     (arguments
+      `(#:modules ((guix build utils))
+        #:builder (begin
+                    (use-modules (guix build utils))
+                    (format #t "Copying build scripts ...~%")
+                    (copy-recursively (string-append
+                                       (assoc-ref %build-inputs "source")
+                                       "/projects/tor-browser")
+                                      %output
+                                      #:log (%make-void-port "w")))))
+     (home-page "https://www.torproject.org")
+     (synopsis "Tor Browser build scripts")
+     (description "Tor Browser runtime scripts.")
+     (license (license:non-copyleft "file://LICENSE")))))
+
+(define torbutton
+  (let ((commit "4e67ee2ef26e28da0f02a0e43e22a61ee33c6d4d"))
+    (package
+     (name "torbutton")
+     (version %torbrowser-build-version)
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.torproject.org/torbutton.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0md7lsspmji8wj1gx1mfy1wiqa28hjy3w1vdn5df1mv7g846jbbb"))))
+     (build-system trivial-build-system)
+     (arguments
+      `(#:modules ((guix build utils))
+        #:builder (begin
+                    (use-modules (guix build utils))
+                    (format #t "Copying source ...~%")
+                    (copy-recursively (assoc-ref %build-inputs "source")
+                                      %output
+                                      #:log (%make-void-port "w")))))
+     (home-page "https://www.torproject.org")
+     (synopsis "Tor Browser built-in extension")
+     (description "Browser extension needed to build and run Tor Browser.")
+     (license (license:non-copyleft "file://LICENSE")))))
+
+(define tor-launcher
+  (package
+   (name "tor-launcher")
+   (version "0.2.25")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://git.torproject.org/tor-launcher.git")
+           (commit version)))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "02vqwqhmwp9kr58qqjll5m4i8fqjqis7hr7zcbgb1ndgmfk2b8gr"))))
+   (build-system trivial-build-system)
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (format #t "Copying source ...~%")
+                  (copy-recursively (assoc-ref %build-inputs "source")
+                                    %output
+                                    #:log (%make-void-port "w")))))
+   (home-page "https://www.torproject.org")
+   (synopsis "Tor Browser built-in controler extension")
+   (description "Browser extension that starts the tor process (which
+connects the browser and other applications to the Tor Network), and
+which helps people configure and use @code{tor}. The first window that
+you see when you start Tor Browser is displayed by this extension.")
+   (license (license:non-copyleft "file://src/LICENSE"))))
+
+;; This package is actually a cargo crate, so it should be moved to
+;; crates-io.scm and made public once the cross building to wasm32 is
+;; successful.
+(define https-everywhere-lib-wasm
+  (let ((commit "af199004083ce200f285735f68a5a57c47eed0e6"))
+  (package
+   (name "https-everywhere-lib-wasm")
+   (version "2020.08.13")
+   (source
+    (origin
+     (method git-fetch)
+      (uri (git-reference
+            (url "https://github.com/EFForg/https-everywhere-lib-wasm")
+            (commit commit)))
+      (file-name (git-file-name name version))
+      (sha256
+       (base32
+        "14xv637hf9kzdyr2w0cvx0g5if9nrzflf29p1spdl228yqlv9d5r"))))
+   (build-system trivial-build-system)
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (format #t "Copying source ...~%")
+                  (copy-recursively (assoc-ref %build-inputs "source")
+                                    %output
+                                    #:log (%make-void-port "w")))))
+   (home-page "https://github.com/EFForg/https-everywhere-lib-wasm")
+   (synopsis "Browser extension for protection against known attacks")
+   (description "Browser extension that protects users from a range of
+known attacks on web browsing activity such as Cross-site scripting, clickjack and
+makes possible for the users to block or choose on a per site basis which remote
+javascript to run while browsing the web.")
+   (license license:gpl2+))))
+
+;; This should probably go elsewhere on the file system and made
+;; public in order to be shared between Tor Browser and IceCat once
+;; lib-wasm gets fixed.
+(define-public https-everywhere
+  (package
+   (name "https-everywhere")
+   (version "2020.8.13")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (string-append "https://github.com/EFForg/" name "/archive/"
+                         version ".tar.gz"))
+     (sha256
+      (base32
+       "0xb8q7izlyq80zzvj2j7wqp3srxxmi0wgwrb47lc5w38r7yzqjjd"))))
+   (build-system trivial-build-system)
+   (native-inputs
+    `(("bash" ,bash)
+      ("coreutils" ,coreutils)
+      ("findutils" ,findutils)
+      ("git" ,git)
+      ("grep" ,grep)
+      ("gzip" ,gzip)
+      ("https-everywhere-lib-wasm"
+       ,https-everywhere-lib-wasm)
+      ("libxml2" ,libxml2)
+      ("libxslt" ,libxslt)
+      ("openssl" ,openssl)
+      ("python" ,python)
+      ("rsync" ,rsync)
+      ("sed" ,sed)
+      ("tar" ,tar)
+      ("util-linux" ,util-linux) ; for getopt
+      ("xxd" ,xxd)
+      ("which" ,which)
+      ("zip" ,zip)))
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (use-modules (guix build utils))
+                  (let ((src (assoc-ref %build-inputs "source"))
+                        (httpse-libwasm (assoc-ref %build-inputs "https-everywhere-lib-wasm"))
+                        (bash (assoc-ref %build-inputs "bash"))
+                        (coreutils (assoc-ref %build-inputs "coreutils"))
+                        (python (assoc-ref %build-inputs "python"))
+                        (openssl (assoc-ref %build-inputs "openssl"))
+                        (git (assoc-ref %build-inputs "git"))
+                        (grep (assoc-ref %build-inputs "grep"))
+                        (findutils (assoc-ref %build-inputs "findutils"))
+                        (sed (assoc-ref %build-inputs "sed"))
+                        (which (assoc-ref %build-inputs "which"))
+                        (rsync (assoc-ref %build-inputs "rsync"))
+                        (libxml2 (assoc-ref %build-inputs "libxml2"))
+                        (libxslt (assoc-ref %build-inputs "libxslt"))
+                        (util-linux (assoc-ref %build-inputs "util-linux"))
+                        (xxd (assoc-ref %build-inputs "xxd"))
+                        (zip (assoc-ref %build-inputs "zip"))
+                        (tar (assoc-ref %build-inputs "tar"))
+                        (gzip (assoc-ref %build-inputs "gzip")))
+                    (setenv "SHELL" (string-append bash "/bin/bash"))
+                    (set-path-environment-variable
+                     "PATH" '("bin")
+                     (list bash sed findutils which git python tar openssl rsync libxml2 libxslt
+                           util-linux grep xxd gzip zip coreutils))
+                    (set-path-environment-variable
+                     "LIBRARY_PATH" '("lib")
+                     (list bash sed findutils which git python tar openssl rsync libxml2 libxslt
+                           util-linux grep xxd gzip zip coreutils))
+                    (format #t "Untaring source tarball ...~%")
+                    (invoke "tar" "-xf" src "--strip-components=1")
+                    ;; Python3.6 is hardcoded on these scripts. Using v3.8 appears to
+                    ;; be harmless.
+                    (substitute* '("install-dev-dependencies.sh"
+                                   "make.sh"
+                                   "hooks/precommit"
+                                   "test/firefox.sh"
+                                   "test/manual.sh"
+                                   "test/rules/src/https_everywhere_checker/check_rules.py"
+                                   "test/script.py"
+                                   "test/validations.sh"
+                                   "test/validations/filename/run.py"
+                                   "test/validations/relaxng/run.py"
+                                   "test/validations/securecookie/run.py"
+                                   "test/validations/special/run.py"
+                                   "utils/create_zip.py"
+                                   "utils/chromium-translations.py"
+                                   "utils/create-platform-certs/split_combined_cert_file.py"
+                                   "utils/mk-client-whitelist/dbconnect.py"
+                                   "utils/mk-client-whitelist/run.py"
+                                   "utils/merge-rulesets.py"
+                                   "utils/setversion.py"
+                                   "utils/zipfile_deterministic.py")
+                                 (("python3.6") "python3"))
+                    (make-file-writable "lib-wasm")
+                    (copy-recursively httpse-libwasm
+                                      "lib-wasm"
+                                      #:log (%make-void-port "w"))
+                    ;; Remove precompiled binaries from source. This breaks
+                    ;; http-everywhere at runtime, but building is successful.
+                    ;; Once lib-wasm is successfuly cross-compiled to wasm,
+                    ;; remove this.
+                    (with-directory-excursion "lib-wasm/pkg"
+                      (for-each (lambda (file)
+                        (if (file-exists? file)
+                            (delete-file file)
+                            (display (string-append
+                             "Warning: file " file
+                             " not found! Skipping...\n"))))
+                        '("https_everywhere_lib_wasm.js"
+                          "https_everywhere_lib_wasm_bg.wasm")))
+                    (for-each patch-shebang
+                              (find-files "."
+                                          (lambda (file stat)
+                                            ;; Filter out symlinks.
+                                            (eq? 'regular (stat:type stat)))
+                                          #:stat lstat))
+                    ;; Failing to generate the xpi, but copy-dir appears to be enough.
+                    ;; Failing on missing 'wasm'? Not generating rulesets.
+                    (invoke "./make.sh")
+                    (copy-recursively "pkg/xpi-eff" %output
+                                      #:log (%make-void-port "w"))
+                    #t))))
+   (home-page "https://www.eff.org/https-everywhere")
+   (synopsis "Browser extension for automatic HTTPS usage")
+   (description "Browser extension that automatically makes the browser to use
+HTTPS instead of plain HTTP when the remote destination makes it available to users.")
+   (license license:gpl2+)))
+
+;; Currently there seems to be no binaries on this package, but in
+;; order to avoid the possibility of one getting silently added,
+;; this needs reworking to make it build from source.
+(define noscript
+  (package
+   (name "noscript")
+   (version "11.0.46")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (string-append "https://secure.informaction.com/download/releases/"
+                         name "-" version ".xpi"))
+     (sha256
+      (base32
+       "1gbhzc4jldsc11fxpjkvlvixdlpmqz774vhni08lmszyqbjzim0s"))))
+   (build-system trivial-build-system)
+   (arguments
+    `(#:modules ((guix build utils))
+      #:builder (begin
+                  (format #t "Copying source ...~%")
+                  (copy-file (assoc-ref %build-inputs "source")
+                             %output))))
+   (home-page "https://noscript.net")
+   (synopsis "Browser extension for protection against known attacks")
+   (description "Browser extension that protects users from a range of
+known attacks on web browsing activity such as Cross-site scripting, clickjack and
+makes possible for the users to block or choose on a per site basis which remote
+javascript to run while browsing the web.")
+   (license license:gpl2+)))
+
+;; (Un)fortunatly Tor Browser has it's own reproducible build system - RBM - which
+;; automates the build process for them and compiles Tor Browser from a range of
+;; repositories and produces a range of tarballs for different architectures and
+;; locales. So we need to cherry-pick what is needed for guix and produce our own
+;; tarball. See https://gitweb.torproject.org/builders/tor-browser-build.git/projects/\
+;; {tor-browser,firefox}/{build,config} for the rationale applied here. See also
+;; the Hacking on Tor Browser document for a high level introduction at
+;; https://trac.torproject.org/projects/tor/wiki/doc/Tor Browser/Hacking).
+;;
+;; TODO: Import langpacks.
+(define-public torbrowser-unbundle
+  (let ((commit (string-append "tor-browser-" %torbrowser-version
+                               "-" %torbrowser-build)))
+    (package
+     (name "torbrowser-unbundle")
+     (version %torbrowser-build-version)
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.torproject.org/tor-browser.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "17fa3p6rpqirdm8arb7j73sl54rhw89ssn6pyg6v7kl6hpp7v0wc"))))
+     (build-system gnu-build-system)
+     (inputs
+      `(("alsa-lib" ,alsa-lib)
+        ("bzip2" ,bzip2)
+        ("cups" ,cups)
+        ("dbus-glib" ,dbus-glib)
+        ("ffmpeg" ,ffmpeg)
+        ("freetype" ,freetype)
+        ("gdk-pixbuf" ,gdk-pixbuf)
+        ("glib" ,glib)
+        ("gtk+" ,gtk+)
+        ("gtk+-2" ,gtk+-2)
+        ;("graphite2" ,graphite2)
+        ;("harfbuzz" ,harfbuzz)
+        ;("icu4c" ,icu4c-67)
+        ("libcanberra" ,libcanberra)
+        ("libgnome" ,libgnome)
+        ("libjpeg-turbo" ,libjpeg-turbo)
+        ;("libogg" ,libogg)
+        ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
+        ;("libvorbis" ,libvorbis)
+        ("libxft" ,libxft)
+        ("libevent" ,libevent)
+        ("libxinerama" ,libxinerama)
+        ("libxscrnsaver" ,libxscrnsaver)
+        ("libxcomposite" ,libxcomposite)
+        ("libxt" ,libxt)
+        ("libffi" ,libffi)
+        ;("libvpx" ,libvpx)
+        ("mesa" ,mesa)
+        ("mit-krb5" ,mit-krb5)
+        ;; See <https://bugs.gnu.org/32833>
+        ;;   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 <http://hydra.gnu.org/build/378133>.
+        #:validate-runpath? #f
+        #:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
+        #: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.desktop")))
+              #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 inputs)
+                                                     "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.js")
+                (let ((tbb-prefs (open-file "browser/app/profile/000-tor-browser.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 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
+               (for-each (lambda (file)
+                           (format #t "patching checksums in ~a~%" file)
+                           (substitute* (find-files "." "Cargo.lock$")
+                             (("^checksum = \".*\"")
+                              (string-append "checksum = \"" 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 tools in
+              ;; about:buildconfig, reducing Tor Browser's closure significant.
+              ;; 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)
+                                "<!-- Guix: not a runtime dependency -->"
+                                (string-drop hash 8))))
+              #t))
+
+          (replace 'configure
+            (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bash (which "bash"))
+                     (flags `(,(string-append "--prefix=" 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 timestamp.
+                (setenv "LDFLAGS" (string-append
+                                   "-Wl,-rpath="
+                                   (assoc-ref outputs "out")
+                                   "/lib/firefox"))
+                (substitute* ".mozconfig"
+                  ;; Arch independent builddir.
+                  (("(mk_add_options MOZ_OBJDIR=@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=dev-build")
+                   (string-append "ac_add_options --with-tor-browser-version=org.gnu\n"
+                                  "ac_add_options --with-unsigned-addon-scopes=app,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="
+                                   (assoc-ref %build-inputs "clang") "/bin/clang\n"
+                                  "ac_add_options --with-libclang-path="
+                                  (assoc-ref %build-inputs "clang") "/lib\n")))
+
+                (substitute* "browser/app/profile/000-tor-browser.js"
+                  ;; Tor Browser updates are disabled on mozconfig, but let'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.snowflake.1\".*")
+                   "\n"))
+
+                (substitute*
+                 "browser/extensions/tor-launcher/src/defaults/preferences/torlauncher-prefs.js"
+                  ;; Not multilingual. See tor-browser/build:141. Currently disabled on
+                  ;; tor-launcher, but let's make sure while missing langpacks.
+                 (("(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 nondeterministic?
+              (make-file-writable "Cargo.lock")
+              (invoke "./mach" "build")
+              #t))
+
+          ;; Tor Browser just do a stage-package here and copy files to its 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" "libnssdbm3.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") #o555)
+                (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/default")))
+                (with-directory-excursion
+                 icons-src
+                 (for-each
+                   (lambda (file)
+                     (let* ((size (string-filter char-numeric? file))
+                            (icons (string-append out "/share/icons/hicolor/"
+                                                  size "x" size "/apps")))
+                       (mkdir-p icons)
+                       (copy-file file (string-append icons "/torbrowser.png"))))
+                   '("default16.png" "default32.png" "default48.png" "default64.png"
+                     "default128.png"))))
+              #t))
+
+          (add-after 'install-icons 'install-fonts
+            (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (lib (string-append out "/lib/firefox/"))
+                     (fonts  (string-append (or (assoc-ref native-inputs
+                                                           "torbrowser-fonts")
+                                                (assoc-ref inputs
+                                                           "torbrowser-fonts"))
+                                            "/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-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (lib (string-append out "/lib/firefox"))
+                     (ext (string-append out "/lib/firefox/browser/extensions"))
+                     (torb-ext (string-append out
+                                 "/lib/firefox/chrome/torbutton/content/extensions"))
+                     (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-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (tordir (string-append out "/lib/firefox/TorBrowser/Tor"))
+                     (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-keys)
+              (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 "/" file)
+                                               #:log (%make-void-port "w")))
+                           '("Browser" "fontconfig" "Tor")))
+                (copy-file (string-append ptconf "/linux/torrc-defaults-appendix")
+                           (string-append data "/Tor/torrc-defaults-appendix"))
+                (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 the only
+recommended way to anonymously browse the web that is supported by the project.
+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
-- 
2.28.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCHv3 9/9] gnu: Add torbrowser-unbundle.
  2020-09-24 23:18               ` [bug#42380] [PATCHv2 " André Batista
@ 2020-10-07 15:51                 ` André Batista
  2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
  0 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2020-10-07 15:51 UTC (permalink / raw)
  To: 42380


[-- Attachment #1.1: Type: text/plain, Size: 982 bytes --]

Hello Guix,

This new version of the patch addresses the following:
- inherits definition from icecat[1];
- use source tarballs for tor-browser and tor-launcher[2];
- does not define torbutton anymore (it is bundled with tor-browser);
- unbundles some system libs (nss, nspr, zlib, libevent and icu)

1. There are four phases which are almost exact copies from icecat.
I've tried to use let, define and package-properties to remove the
hardcoded strings which are in the way of inheritance, but I've had
no success. The phases are: 'install-icons,
'apply-guix-specific-patches, 'neutralise-store-references and
'wrap-program. Maybe someone here can shed a light.

2. Those tarballs and also the one used for fonts are not kept for
long on dist.torproject.org. Usually they are removed when there is
a new browser version. So this will be a problem for time-machine.
On the other hand, the git repos for fonts and torbrowser source
are huge, so I'm unsure which would be preferable.

[-- Attachment #1.2: 0001-gnu-Add-torbrowser-unbundle.patch --]
[-- Type: text/plain, Size: 49896 bytes --]

From 2daf59f3a3d12d1c2ea8c94d9a0d748d26e5b1c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Wed, 7 Oct 2020 11:52:21 -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-desktop.patch: New file.
* gnu/packages/patches/torbrowser-start-script.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.
---
 gnu/local.mk                                  |   3 +
 .../patches/torbrowser-start-desktop.patch    |  22 +
 .../patches/torbrowser-start-script.patch     | 181 +++++
 gnu/packages/tor.scm                          | 691 +++++++++++++++++-
 4 files changed, 896 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/torbrowser-start-desktop.patch
 create mode 100644 gnu/packages/patches/torbrowser-start-script.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 83d2d72ab1..7cfc2e901f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -37,6 +37,7 @@
 # Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
 # Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
 # Copyright © 2020 Martin Becze <mjbecze@riseup.net>
+# Copyright © 2020 André Batista <nandre@riseup.net>
 #
 # This file is part of GNU Guix.
 #
@@ -1629,6 +1630,8 @@ dist_patch_DATA =						\
   %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-desktop.patch           \
+  %D%/packages/patches/torbrowser-start-script.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-desktop.patch b/gnu/packages/patches/torbrowser-start-desktop.patch
new file mode 100644
index 0000000000..6832ed363b
--- /dev/null
+++ b/gnu/packages/patches/torbrowser-start-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.desktop.orig    2020-07-05 18:47:40.689484877 -0300
++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser.desktop 2020-07-24 14:36:37.720579884 -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 shell.
+ # It preserves arguments and environment for the start-tor-browser script.
+@@ -28,7 +28,7 @@
+ GenericName=Web Browser
+ Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
+ Categories=Network;WebBrowser;Security;
+-Exec=sh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/start-tor-browser --detach)' dummy %k
+-X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
+-Icon=web-browser
++Exec=sh -c start-tor-browser
++X-TorBrowser-ExecShell=start-tor-browser --detach
++Icon=torbrowser
+ StartupWMClass=Tor Browser
diff --git a/gnu/packages/patches/torbrowser-start-script.patch b/gnu/packages/patches/torbrowser-start-script.patch
new file mode 100644
index 0000000000..b8c8d9a26a
--- /dev/null
+++ b/gnu/packages/patches/torbrowser-start-script.patch
@@ -0,0 +1,181 @@
+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.orig    2020-07-05 18:47:40.685485004 -0300
++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser 2020-07-23 18:13:32.426282743 -0300
+@@ -5,6 +5,14 @@
+ #
+ # 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"
++
+ complain_dialog_title="Tor Browser"
+ 
+ # First, make sure DISPLAY is set.  If it isn't, we're hosed; scream
+@@ -134,8 +142,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 +195,22 @@
+ 	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"
++   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 +225,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 +247,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 +309,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,<dir>fonts</dir>,<dir>${TBB_STORE_PATH}/fonts</dir>,"
++
+ cd "${HOME}"
+ 
+ # We pass all additional command-line arguments we get to Firefox.
+@@ -357,23 +326,23 @@
+ 
+ if [ "$show_usage" -eq 1 ]; then
+     # Display Firefox help, then our help
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default --help 2>/dev/null
++    TOR_CONTROL_PASSWD=${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=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-       -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++       -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
+     disown "$!"
+ elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
+         tee "$logfile"
+ elif [ "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" < /dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" < /dev/null
+ else
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
+ fi
+ 
+ exit $?
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index b1e417f29c..5f88a0968e 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -32,26 +32,64 @@
   #:use-module (guix utils)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix build-system cargo)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages assembly)
+  #:use-module (gnu packages audio)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cups)
+  #:use-module (gnu packages databases)
+  #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages gl)
+  #:use-module (gnu packages glib)
+  #:use-module (gnu packages gnome)
   #:use-module (gnu packages golang)
+  #:use-module (gnu packages gtk)
+  #:use-module (gnu packages gnuzilla)
+  #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages image)
+  #:use-module (gnu packages kerberos)
+  #:use-module (gnu packages libcanberra)
   #:use-module (gnu packages libevent)
+  #:use-module (gnu packages libffi)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages llvm)
+  #:use-module (gnu packages node)
+  #:use-module (gnu packages nss)
   #:use-module (gnu packages pcre)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-crypto)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages qt)
+  #:use-module (gnu packages readline)
+  #:use-module (gnu packages rsync) ; for httpse
+  #:use-module (gnu packages rust)
+  #:use-module (gnu packages rust-apps)
+  #:use-module (gnu packages sqlite)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages w3m))
+  #:use-module (gnu packages version-control)
+  #:use-module (gnu packages video)
+  #:use-module (gnu packages vim) ; for xxd
+  #:use-module (gnu packages w3m)
+  #:use-module (gnu packages xdisorg)
+  #:use-module (gnu packages xiph)
+  #:use-module (gnu packages xorg)
+  #:use-module (gnu packages xml) ; for httpse
+  #:use-module (ice-9 match)
+  #:use-module ((srfi srfi-1) #:hide (zip)))
 
 (define-public tor
   (package
@@ -398,3 +436,654 @@ incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol.
 The obfs naming was chosen primarily because it was shorter, in terms of
 protocol ancestery obfs4 is much closer to ScrambleSuit than obfs2/obfs3.")
    (license license:gpl3+)))
+
+;; Upstream does not seem to keep tor-browser and tor-browser-build versions
+;; in sync
+(define %torbrowser-version "78.3.0esr-10.0-2")
+(define %torbrowser-build-version "10.0")
+(define %torbrowser-build "build2")
+(define %tbb-build "build3")
+(define %torbrowser-build-id "20201001000000");must be of the form YYYYMMDDhhmmss
+
+;; Fonts for Tor Browser. Avoid downloading 4Gb+ git repo on
+;; https://github.com/googlei18n/noto-fonts.git to use just a handful.
+;; Use the fonts on Tor Browser release tarball.
+(define torbrowser-fonts
+  (package
+    (name "torbrowser-fonts")
+    (version %torbrowser-build-version)
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://dist.torproject.org/torbrowser/"
+                           version "/tor-browser-linux64-"
+                           version "_en-US.tar.xz"))
+       (sha256
+        (base32
+         "1l2rfknffnh6hsi16dzps1wav5s723vyk57fzv9y5vjmbcbf7l2l"))))
+    (build-system trivial-build-system)
+    (native-inputs
+     `(("tar" ,tar)
+       ("xz" ,xz)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+                   (use-modules (guix build utils))
+                   (let ((src (assoc-ref %build-inputs "source"))
+                         (src-dir "tor-browser_en-US/Browser/fonts")
+                         (fonts (string-append %output "/share/fonts"))
+                         (tar (assoc-ref %build-inputs "tar"))
+                         (xz (assoc-ref %build-inputs "xz")))
+                     (mkdir-p fonts)
+                     (format #t "Untaring torbrowser ball ...~%")
+                     (invoke (string-append tar "/bin/tar") "-xf" src
+                             "-C" fonts "--strip-components=3"
+                             (string-append "--use-compress-program=" xz "/bin/xz")
+                             src-dir)
+                     #t))))
+    (home-page "https://github.com/googlei18n/noto-fonts")
+    (synopsis "Tor Browser bundled fonts")
+    (description "Free fonts bundled with Tor Browser.  Includes a subset of Noto,
+Arimo, Cousine, Tinos and STIX fonts.")
+    (license license:silofl1.1)))
+
+(define tor-browser-build
+  (let ((commit (string-append "tbb-" %torbrowser-build-version
+                               "-" %tbb-build)))
+    (package
+      (name "tor-browser-build")
+      (version %torbrowser-build-version)
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://git.torproject.org/builders/tor-browser-build.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "14wawaf555dvr3dznphyz4sd3r8q53klhrcb8igiadmdx8wqc33m"))))
+      (build-system trivial-build-system)
+      (arguments
+       `(#:modules ((guix build utils))
+         #:builder (begin
+                     (use-modules (guix build utils))
+                     (format #t "Copying build scripts ...~%")
+                     (copy-recursively (string-append
+                                        (assoc-ref %build-inputs "source")
+                                        "/projects/tor-browser")
+                                       %output
+                                       #:log (%make-void-port "w")))))
+      (home-page "https://www.torproject.org")
+      (synopsis "Tor Browser build scripts")
+      (description "Tor Browser runtime scripts.")
+      (license (license:non-copyleft "file://LICENSE")))))
+
+(define tor-launcher
+  (package
+    (name "tor-launcher")
+    (version "0.2.25")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://dist.torproject.org/torbrowser/"
+                           %torbrowser-build-version "/src-" name "-"
+                           version ".tar.xz"))
+       (sha256
+        (base32
+         "1d7137ffx5vgycnk1fb6n5fc8ppndcygyx0jvylbd9bmrs2426rv"))))
+    (build-system trivial-build-system)
+    (native-inputs
+     `(("tar" ,tar)
+       ("xz" ,xz)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+                   (use-modules (guix build utils))
+                   (let ((src (assoc-ref %build-inputs "source"))
+                         (tar (assoc-ref %build-inputs "tar"))
+                         (xz (assoc-ref %build-inputs "xz")))
+                     (mkdir-p %output)
+                     (format #t "Extracting source ...~%")
+                     (invoke (string-append tar "/bin/tar") "-xf" src
+                             "-C" %output "--strip-components=1"
+                             (string-append "--use-compress-program=" xz "/bin/xz"))))))
+    (home-page "https://www.torproject.org")
+    (synopsis "Tor Browser built-in controler extension")
+    (description "Browser extension that starts the tor process (which
+connects the browser and other applications to the Tor Network), and
+which helps people configure and use @code{tor}. The first window that
+you see when you start Tor Browser is displayed by this extension.")
+    (license (license:non-copyleft "file://src/LICENSE"))))
+
+(define https-everywhere-lib-wasm
+  (let ((commit "af199004083ce200f285735f68a5a57c47eed0e6"))
+    (package
+      (name "https-everywhere-lib-wasm")
+      (version "2020.08.13")
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/EFForg/https-everywhere-lib-wasm")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "14xv637hf9kzdyr2w0cvx0g5if9nrzflf29p1spdl228yqlv9d5r"))))
+      (build-system trivial-build-system)
+      (arguments
+       `(#:modules ((guix build utils))
+         #:builder (begin
+                     (use-modules (guix build utils))
+                     (format #t "Copying source ...~%")
+                     (copy-recursively (assoc-ref %build-inputs "source")
+                                       %output
+                                       #:log (%make-void-port "w")))))
+      (home-page "https://github.com/EFForg/https-everywhere-lib-wasm")
+      (synopsis "Browser extension for protection against known attacks")
+      (description "Browser extension that protects users from a range of
+known attacks on web browsing activity such as Cross-site scripting, clickjack and
+makes possible for the users to block or choose on a per site basis which remote
+javascript to run while browsing the web.")
+      (license license:gpl2+))))
+
+(define-public https-everywhere
+  (package
+    (name "https-everywhere")
+    (version "2020.8.13")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/EFForg/" name "/archive/"
+                           version ".tar.gz"))
+       (sha256
+        (base32
+         "0xb8q7izlyq80zzvj2j7wqp3srxxmi0wgwrb47lc5w38r7yzqjjd"))))
+    (build-system trivial-build-system)
+    (native-inputs
+     `(("bash" ,bash)
+       ("coreutils" ,coreutils)
+       ("findutils" ,findutils)
+       ("git" ,git)
+       ("grep" ,grep)
+       ("gzip" ,gzip)
+       ("https-everywhere-lib-wasm"
+        ,https-everywhere-lib-wasm)
+       ("libxml2" ,libxml2)
+       ("libxslt" ,libxslt)
+       ("openssl" ,openssl)
+       ("python" ,python)
+       ("rsync" ,rsync)
+       ("sed" ,sed)
+       ("tar" ,tar)
+       ("util-linux" ,util-linux) ; for getopt
+       ("xxd" ,xxd)
+       ("which" ,which)
+       ("zip" ,zip)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+                   (use-modules (guix build utils))
+                   (let ((src (assoc-ref %build-inputs "source"))
+                         (httpse-libwasm (assoc-ref %build-inputs
+                                                    "https-everywhere-lib-wasm"))
+                         (bash (assoc-ref %build-inputs "bash"))
+                         (coreutils (assoc-ref %build-inputs "coreutils"))
+                         (python (assoc-ref %build-inputs "python"))
+                         (openssl (assoc-ref %build-inputs "openssl"))
+                         (git (assoc-ref %build-inputs "git"))
+                         (grep (assoc-ref %build-inputs "grep"))
+                         (findutils (assoc-ref %build-inputs "findutils"))
+                         (sed (assoc-ref %build-inputs "sed"))
+                         (which (assoc-ref %build-inputs "which"))
+                         (rsync (assoc-ref %build-inputs "rsync"))
+                         (libxml2 (assoc-ref %build-inputs "libxml2"))
+                         (libxslt (assoc-ref %build-inputs "libxslt"))
+                         (util-linux (assoc-ref %build-inputs "util-linux"))
+                         (xxd (assoc-ref %build-inputs "xxd"))
+                         (zip (assoc-ref %build-inputs "zip"))
+                         (tar (assoc-ref %build-inputs "tar"))
+                         (gzip (assoc-ref %build-inputs "gzip")))
+                     (setenv "SHELL" (string-append bash "/bin/bash"))
+                     (set-path-environment-variable
+                      "PATH" '("bin")
+                      (list bash sed findutils which git python tar openssl rsync
+                            libxml2 libxslt util-linux grep xxd gzip zip coreutils))
+                     (set-path-environment-variable
+                      "LIBRARY_PATH" '("lib")
+                      (list bash sed findutils which git python tar openssl rsync
+                            libxml2 libxslt util-linux grep xxd gzip zip coreutils))
+                     (format #t "Untaring source tarball ...~%")
+                     (invoke "tar" "-xf" src "--strip-components=1")
+                     ;; Python3.6 is hardcoded on these scripts. Using v3.8 appears to
+                     ;; be harmless.
+                     (substitute* '("install-dev-dependencies.sh"
+                                    "make.sh"
+                                    "hooks/precommit"
+                                    "test/firefox.sh"
+                                    "test/manual.sh"
+                                    "test/rules/src/https_everywhere_checker/check_rules.py"
+                                    "test/script.py"
+                                    "test/validations.sh"
+                                    "test/validations/filename/run.py"
+                                    "test/validations/relaxng/run.py"
+                                    "test/validations/securecookie/run.py"
+                                    "test/validations/special/run.py"
+                                    "utils/create_zip.py"
+                                    "utils/chromium-translations.py"
+                                    "utils/create-platform-certs/split_combined_cert_file.py"
+                                    "utils/mk-client-whitelist/dbconnect.py"
+                                    "utils/mk-client-whitelist/run.py"
+                                    "utils/merge-rulesets.py"
+                                    "utils/setversion.py"
+                                    "utils/zipfile_deterministic.py")
+                       (("python3.6") "python3"))
+                     (make-file-writable "lib-wasm")
+                     (copy-recursively httpse-libwasm
+                                       "lib-wasm"
+                                       #:log (%make-void-port "w"))
+                     ;; Remove precompiled binaries from source. This breaks
+                     ;; http-everywhere at runtime, but building is successful.
+                     ;; Once lib-wasm is successfuly cross-compiled to wasm,
+                     ;; remove this.
+                     (with-directory-excursion "lib-wasm/pkg"
+                       (for-each (lambda (file)
+                                   (if (file-exists? file)
+                                       (delete-file file)
+                                       (display (string-append
+                                                 "Warning: file " file
+                                                 " not found! Skipping...\n"))))
+                                 '("https_everywhere_lib_wasm.js"
+                                   "https_everywhere_lib_wasm_bg.wasm")))
+                     (for-each patch-shebang
+                               (find-files "."
+                                           (lambda (file stat)
+                                             ;; Filter out symlinks.
+                                             (eq? 'regular (stat:type stat)))
+                                           #:stat lstat))
+                     ;; Failing to generate the xpi, but copy-dir appears to be enough.
+                     ;; Failing on missing 'wasm'? Not generating rulesets.
+                     (invoke "./make.sh")
+                     (copy-recursively "pkg/xpi-eff" %output
+                                       #:log (%make-void-port "w"))
+                     #t))))
+    (home-page "https://www.eff.org/https-everywhere")
+    (synopsis "Browser extension for automatic HTTPS usage")
+    (description "Browser extension that automatically makes the browser to use
+HTTPS instead of plain HTTP when the remote destination makes it available to users.")
+    (license license:gpl2+)))
+
+(define noscript
+  (package
+    (name "noscript")
+    (version "11.0.46")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://secure.informaction.com/download/releases/"
+                           name "-" version ".xpi"))
+       (sha256
+        (base32
+         "1gbhzc4jldsc11fxpjkvlvixdlpmqz774vhni08lmszyqbjzim0s"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+                   (format #t "Copying source ...~%")
+                   (copy-file (assoc-ref %build-inputs "source")
+                              %output))))
+    (home-page "https://noscript.net")
+    (synopsis "Browser extension for protection against known attacks")
+    (description "Browser extension that protects users from a range of
+known attacks on web browsing activity such as Cross-site scripting, clickjack and
+makes possible for the users to block or choose on a per site basis which remote
+javascript to run while browsing the web.")
+    (license license:gpl2+)))
+
+;; (Un)fortunatly Tor Browser has it's own reproducible build system - RBM - which
+;; automates the build process for them and compiles Tor Browser from a range of
+;; repositories and produces a range of tarballs for different architectures and
+;; locales. So we need to cherry-pick what is needed for guix and produce our own
+;; tarball. See https://gitweb.torproject.org/builders/tor-browser-build.git/projects/\
+;; {tor-browser,firefox}/{build,config} for the rationale applied here. See also
+;; the Hacking on Tor Browser document for a high level introduction at
+;; https://trac.torproject.org/projects/tor/wiki/doc/Tor Browser/Hacking).
+;;
+;; TODO: Import langpacks.
+(define-public torbrowser-unbundle
+  (package
+    (inherit icecat)
+    (name "torbrowser-unbundle")
+    (version %torbrowser-build-version)
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://dist.torproject.org/torbrowser/"
+                           %torbrowser-build-version
+                           "/src-firefox-tor-browser-"
+                           %torbrowser-version "-" %torbrowser-build
+                           ".tar.xz"))
+       (sha256
+        (base32
+         "0w4p53rnswdrknxaprzqg0w4mhpvagdhj3ksh5l0alv8w4cfjd4c"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("obfs4" ,obfs4)
+       ("nspr" ,nspr)
+       ("nss" ,nss-3.57)
+       ("tor" ,tor-client)
+       ,@(package-inputs icecat)))
+    (native-inputs
+     `(("https-everywhere" ,https-everywhere)
+       ("noscript" ,noscript)
+       ("tor-browser-build" ,tor-browser-build)
+       ("tor-launcher" ,tor-launcher)
+       ("torbrowser-fonts" ,torbrowser-fonts)
+       ("torbrowser-start-script.patch"
+        ,(search-patch "torbrowser-start-script.patch"))
+       ("torbrowser-start-desktop.patch"
+        ,(search-patch "torbrowser-start-desktop.patch"))
+       ,@(package-native-inputs icecat)))
+    (properties '())
+    (arguments
+     (substitute-keyword-arguments (package-arguments icecat)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           ;; On mach build system this is done on configure.
+           (delete 'bootstrap)
+           ;; Doesn't seem to be needed for TorBrowser
+           (delete 'fix-ffmpeg-runtime-linker)
+           ;; Tried to make use of these using let, but inheritance appears to block it.
+           (delete 'install-icons)
+           (delete 'install-desktop-entry)
+           (add-after 'unpack 'make-bundle
+             (lambda* (#:key inputs native-inputs #:allow-other-keys)
+               (let ((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 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")))
+               #t))
+           (replace 'apply-guix-specific-patches
+             (lambda* (#:key inputs native-inputs #:allow-other-keys)
+               (let ((patch (string-append (assoc-ref (or native-inputs inputs)
+                                                      "patch")
+                                           "/bin/patch")))
+                 (for-each (match-lambda
+                             ((label . file)
+                              ;; Only difference to icecat is browser name.
+                              (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-bridge-preferences
+             (lambda* (#:key inputs native-inputs #:allow-other-keys)
+               (begin
+                 (let ((tbb-prefs (open-file
+                                   "browser/app/profile/000-tor-browser.js" "a"))
+                       (bridge-prefs
+                        (open-input-file
+                         "tbb-scripts/Bundle-Data/PTConfigs/bridge_prefs.js")))
+                   (display (get-string-all bridge-prefs) tbb-prefs)
+                   (close-output-port tbb-prefs)))
+               #t))
+           (replace 'configure
+             (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (bash (which "bash"))
+                      (flags `(,(string-append "--prefix=" 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 "python-2")
+                                                 "/bin/python"))
+                 (setenv "CC" "gcc")  ; needed when Stylo is enabled
+                 (setenv "MOZ_BUILD_DATE" ,%torbrowser-build-id) ; avoid timestamp.
+                 (setenv "LDFLAGS" (string-append "-Wl,-rpath="
+                                                  (assoc-ref outputs "out")
+                                                  "/lib"))
+                 (substitute* ".mozconfig"
+                   ;; Arch independent builddir.
+                   (("(mk_add_options MOZ_OBJDIR=@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=dev-build")
+                    (string-append
+                     "ac_add_options --with-tor-browser-version=org.gnu\n"
+                     "ac_add_options --with-unsigned-addon-scopes=app,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"
+                     "ac_add_options --enable-system-pixman\n"
+                     "ac_add_options --enable-system-ffi\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-nspr\n"
+                     "ac_add_options --with-system-nss\n"
+                     "ac_add_options --with-system-zlib\n"
+                     ;; Without these clang is not found.
+                     "ac_add_options --with-clang-path="
+                     (assoc-ref %build-inputs "clang") "/bin/clang\n"
+                     "ac_add_options --with-libclang-path="
+                     (assoc-ref %build-inputs "clang") "/lib\n")))
+                 (substitute* "browser/app/profile/000-tor-browser.js"
+                   ;; Tor Browser updates are disabled on mozconfig, but let'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.snowflake.1\".*")
+                    "\n"))
+                 (substitute*
+                     "browser/extensions/tor-launcher/src/defaults/preferences/torlauncher-prefs.js"
+                   ;; Not multilingual. See tor-browser/build:141. Currently disabled on
+                   ;; tor-launcher, but let's make sure while missing langpacks.
+                   (("(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))
+           (add-after 'configure 'install-desk-icons
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out")))
+                 (with-directory-excursion "browser/branding/official"
+                   (for-each
+                    (lambda (file)
+                      (let* ((size (string-filter char-numeric? file))
+                             (icons (string-append out "/share/icons/hicolor/"
+                                                   size "x" size "/apps")))
+                        (mkdir-p icons)
+                        (copy-file file (string-append icons "/torbrowser.png"))))
+                    '("default16.png" "default22.png" "default24.png"
+                      "default32.png" "default48.png" "default64.png"
+                      "default128.png" "default256.png" "default512.png"))
+                   #t))))
+           (replace 'build
+             (lambda _ (invoke "./mach" "build")
+                     #t))
+           (replace 'neutralise-store-references
+             (lambda _
+               ;; difference from icecat "objdir" preffix. We could use find-files there.
+               (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)
+                                 "<!-- Guix: not a runtime dependency -->"
+                                 (string-drop hash 8))))
+               #t))
+           ;; Tor Browser just do a stage-package here and copy files to its 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"))
+                      (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" "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") #o555)
+                 (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-fonts
+             (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (lib (string-append out "/lib/"))
+                      (fonts  (string-append (or (assoc-ref native-inputs
+                                                            "torbrowser-fonts")
+                                                 (assoc-ref inputs
+                                                            "torbrowser-fonts"))
+                                             "/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-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (lib (string-append out "/lib"))
+                      (ext (string-append lib "/browser/extensions"))
+                      (torb-ext (string-append lib
+                                               "/chrome/torbutton/content/extensions"))
+                      (httpse-id "https-everywhere")
+                      (noscript-id "{73a6fe31-595d-460b-a920-fcc0f8843232}")
+                      (httpse (assoc-ref inputs "https-everywhere"))
+                      (noscript (assoc-ref inputs "noscript")))
+                 (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-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (tordir (string-append out "/lib/TorBrowser/Tor"))
+                      (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-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (lib (string-append out "/lib"))
+                      (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 "/" file)
+                                                 #:log (%make-void-port "w")))
+                             '("Browser" "fontconfig" "Tor")))
+                 (copy-file (string-append ptconf "/linux/torrc-defaults-appendix")
+                            (string-append data "/Tor/torrc-defaults-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
+           (replace 'wrap-program
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (lib (string-append out "/lib"))
+                      (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")))
+                 ;; Only difference to icecat is browser name.
+                 (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 the only
+recommended way to anonymously browse the web that is supported by the project.
+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
-- 
2.28.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] Wow!
  2020-09-15 15:23   ` André Batista
@ 2021-05-25 15:05     ` Xinglu Chen
  2021-05-25 19:12       ` Leo Famulari
  0 siblings, 1 reply; 56+ messages in thread
From: Xinglu Chen @ 2021-05-25 15:05 UTC (permalink / raw)
  To: André Batista, Raghav Gururajan, Ludovic Courtès; +Cc: 42380

[-- Attachment #1: Type: text/plain, Size: 82 bytes --]

What’s the status of these patches?  I would love to see Tor Browser in
Guix!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] Wow!
  2021-05-25 15:05     ` Xinglu Chen
@ 2021-05-25 19:12       ` Leo Famulari
  2021-05-25 21:24         ` Ludovic Courtès
  0 siblings, 1 reply; 56+ messages in thread
From: Leo Famulari @ 2021-05-25 19:12 UTC (permalink / raw)
  To: Xinglu Chen
  Cc: André Batista, Raghav Gururajan, Ludovic Courtès, 42380

[-- Attachment #1: Type: text/plain, Size: 801 bytes --]

On Tue, May 25, 2021 at 05:05:47PM +0200, Xinglu Chen wrote:
> What’s the status of these patches?  I would love to see Tor Browser in
> Guix!

Does this package build the Tor browser from source? Or is it just a
launcher, like the Debian package?

My understanding is that the Tor people discourage anyone else from
distributing builds of the Tor browser.

If it builds from source, we should probably call it something besides
"Tor browser", since it will be different from the official Tor browser
due to the unbundling and other changes.

Also, if it builds from source, it will be easy to identify users of
this package as being Guix users and since the Guix userbase is
relatively small, it will be much easier than usual to positively
identify the person using the package.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] Wow!
  2021-05-25 19:12       ` Leo Famulari
@ 2021-05-25 21:24         ` Ludovic Courtès
  2021-05-28  1:45           ` André Batista
  0 siblings, 1 reply; 56+ messages in thread
From: Ludovic Courtès @ 2021-05-25 21:24 UTC (permalink / raw)
  To: Leo Famulari; +Cc: André Batista, Raghav Gururajan, Xinglu Chen, 42380

Hi,

Leo Famulari <leo@famulari.name> skribis:

> On Tue, May 25, 2021 at 05:05:47PM +0200, Xinglu Chen wrote:
>> What’s the status of these patches?  I would love to see Tor Browser in
>> Guix!
>
> Does this package build the Tor browser from source? Or is it just a
> launcher, like the Debian package?

It builds from source.

And sorry for dropping the ball, André!  If anyone’s willing to give it
a try and report back, or to comment on the patch, that’d be great.

> My understanding is that the Tor people discourage anyone else from
> distributing builds of the Tor browser.
>
> If it builds from source, we should probably call it something besides
> "Tor browser", since it will be different from the official Tor browser
> due to the unbundling and other changes.
>
> Also, if it builds from source, it will be easy to identify users of
> this package as being Guix users and since the Guix userbase is
> relatively small, it will be much easier than usual to positively
> identify the person using the package.

Good points.  I think we could ask the Tor Browser folks (we met with a
couple of them at Reproducible Builds Summits in the past and I’m
confident we’d understand each other :-)).

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] Wow!
  2021-05-25 21:24         ` Ludovic Courtès
@ 2021-05-28  1:45           ` André Batista
  2021-06-03 20:43             ` Ludovic Courtès
  0 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2021-05-28  1:45 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Raghav Gururajan, Xinglu Chen, 42380, Leo Famulari

Hi,

ter 25 mai 2021 às 23:24:01 (1621995841), ludo@gnu.org enviou:
> Leo Famulari <leo@famulari.name> skribis:
> 
> > Does this package build the Tor browser from source? Or is it just a
> > launcher, like the Debian package?
> 
> It builds from source.

Apart from noscript which Tor Browser itself does not build from source
and https-everywhere which at the time I thought I'd be able to build
from source but I got stuck on rust dependency nightmare and had to
delay. Unfortunately, this issue still remains to be solved.

> And sorry for dropping the ball, André!  If anyone’s willing to give it
> a try and report back, or to comment on the patch, that’d be great.

No problem, Ludo, it was lacking feedback and I know it's somewhat a
big and delicate piece of software to be merging without it.

> > My understanding is that the Tor people discourage anyone else from
> > distributing builds of the Tor browser.

That's also my understanding, however I do think that building from
source is: 1. the very core of software freedom, despite the relevance
other concerns such as diminishing anonymity set; 2. one of the main
strenghts and what Guix strives for.

> > If it builds from source, we should probably call it something besides
> > "Tor browser", since it will be different from the official Tor browser
> > due to the unbundling and other changes.

I've initially called the package definition "torbrowser-unbundle" and
also inserted a warning that it was _not_ official Tor Browser, but I
did not try to patch sources to rename the browser as it appears after
installed. I can both agree to another name that makes it clearly
appart from the official browser by Tor Project ("nottorbrowser?",
"onionbrowser?") and to work on a patching sources to remove the user
visible name and logo, if it's deemed necessary. (That may take a while
however).

> > Also, if it builds from source, it will be easy to identify users of
> > this package as being Guix users and since the Guix userbase is
> > relatively small, it will be much easier than usual to positively
> > identify the person using the package.

I've tested it with panopticlick.eff.org and it's user identifying bits
remain the same as the official Tor Browser. That said, panopticlick
is certainly not a silver bullet and you have grounds to be concerned.
If someone were to need/want the very best assurances on anonymity set,
I'd advise not to risk it and go with the larger crowd.

On the other hand, until not long ago and maybe currently still, guix
users were using IceCat with tor and that's a much more telling tale.

> Good points.  I think we could ask the Tor Browser folks (we met with a
> couple of them at Reproducible Builds Summits in the past and I’m
> confident we’d understand each other :-)).

That would be great :)

In the mean time, I'll take this as an invitation to send a new patch
version with the latest Tor Browser stable. I've made some minor
improvements such as using tarballs from archive.torproject.org instead
of {git|dist}.torproject.org.

Since they are planning a new stable release in the next few days, I'll
take the time to work on a reproducibility issue that have arised with
the new zip routine to package extensions inside omni.ja which affected
the timestamps, at least the way I did it.

Cheers,




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v4 0/9] gnu: Add torbrowser-unbundle.
  2020-10-07 15:51                 ` [bug#42380] [PATCHv3 " André Batista
@ 2021-06-03  3:17                   ` André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 1/9] gnu: Add go-torproject-org-ptlib André Batista
                                       ` (8 more replies)
  0 siblings, 9 replies; 56+ messages in thread
From: André Batista @ 2021-06-03  3:17 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

*** Updated patch series to add torbrowser-unbundle current stable ***

The first 8 patches are identical to the previous versions, except
they've been updated to reflect line number changes on current guix.

Tor Browser is now built mainly from tarballs, except for
tor-browser-builder which needs a git repo. torbutton is not defined
anymore since it's already bundled.

The browser is fully working, but there are still two issues I'd like
to solve: 1. build extensions from source; 2. make it deterministic
again. I've left comments on code if anyone cares to try and solve
them before I get the time to give it another go.

Cheers,

André Batista (9):
  gnu: Add go-torproject-org-ptlib.
  gnu: Add go-github-com-agl-ed25519.
  gnu: Add go-github-com-dchest-siphash.
  gnu: Add go-github-com-dchest-uniuri.
  gnu: Add go-github-com-dsnet-compress.
  gnu: Add go-schwanenlied-me-yawning-bsaes.
  gnu: Add go-gitlab-com-yawning-utls.
  gnu: Add obfs4.
  gnu: Add torbrowser-unbundle.

 gnu/local.mk                                  |   3 +
 gnu/packages/golang.scm                       | 201 +++++
 .../patches/torbrowser-start-desktop.patch    |  22 +
 .../patches/torbrowser-start-script.patch     | 181 +++++
 gnu/packages/tor.scm                          | 755 +++++++++++++++++-
 5 files changed, 1159 insertions(+), 3 deletions(-)
 create mode 100644 gnu/packages/patches/torbrowser-start-desktop.patch
 create mode 100644 gnu/packages/patches/torbrowser-start-script.patch

-- 
2.31.1





^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v4 1/9] gnu: Add go-torproject-org-ptlib.
  2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
@ 2021-06-03  3:17                     ` André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 2/9] gnu: Add go-github-com-agl-ed25519 André Batista
                                       ` (7 subsequent siblings)
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2021-06-03  3:17 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

* gnu/packages/golang.scm (go-torproject-org-ptlib): New variable.

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 8c3c81ceda..940f38af76 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -25,6 +25,7 @@
 ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
 ;;; Copyright © 2021 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2021 André Batista <nandre@riseup.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -7033,3 +7034,27 @@ simplifications, and enforces style rules.")
      "This package provides a library for fast, structured, leveled logging in
 Go.")
     (license license:expat)))
+
+(define-public go-torproject-org-ptlib
+  (package
+   (name "go-torproject-org-ptlib")
+   (version "1.1.0")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://git.torproject.org/pluggable-transports/goptlib.git")
+           (commit (string-append "v" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "1lh938194hvkf8pqgnxwf6hvjv9rv0j3kasi07r2ckrj8sxzk4jc"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:import-path "git.torproject.org/pluggable-transports/goptlib.git"))
+   (home-page "https://git.torproject.org/pluggable-transports/goptlib.git")
+   (synopsis "Go library for Tor Pluggable Transports")
+   (description "Library for writing Tor Pluggable Transports in Go.  Pluggable
+Transports are a means of connecting to the Tor Network from places where it
+is censored.")
+   (license license:cc0)))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v4 2/9] gnu: Add go-github-com-agl-ed25519.
  2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 1/9] gnu: Add go-torproject-org-ptlib André Batista
@ 2021-06-03  3:17                     ` André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 3/9] gnu: Add go-github-com-dchest-siphash André Batista
                                       ` (6 subsequent siblings)
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2021-06-03  3:17 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

* gnu/packages/golang.scm (go-github-com-agl-ed25519): New variable.

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 940f38af76..2569d450b2 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -7058,3 +7058,41 @@ Go.")
 Transports are a means of connecting to the Tor Network from places where it
 is censored.")
    (license license:cc0)))
+
+(define-public go-github-com-agl-ed25519
+  (let ((commit "c4161f4c7483313562781c61b9a20aba73daf9de")
+        (revision "0"))
+    (package
+     (name "go-github-com-agl-ed25519")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/agl/ed25519")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "1wjlbzi0w63rmlzgk3amw274wsl0zhcn4yx2lraffbkhqappahxc"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/agl/ed25519"
+        #:phases
+        (modify-phases %standard-phases
+          (add-before 'reset-gzip-timestamps 'make-files-writable
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let ((out (assoc-ref outputs "out")))
+                   (for-each (lambda (file) (chmod file #o644))
+                     (find-files out "\\.gz"))
+             #t))))))
+     (home-page "https://github.com/agl/ed25519")
+     (synopsis "Go library for ed25519 public-key signatures")
+     (description "This library is a Go implementation of ed25519 public-key
+signature system which was designed to be faster than previous digital signature
+systems without sacrificing security.  It is currently used in the
+implementation of obfs4 and should be not be used on newer projects since it
+is unmaintained.  Newer software should use x-crypto instead.")
+     ;; License file is referred but it is missing. Probably because the
+     ;; author decided to discontinue the project.
+     (license (license:non-copyleft "file://ed25519.go")))))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v4 3/9] gnu: Add go-github-com-dchest-siphash.
  2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 1/9] gnu: Add go-torproject-org-ptlib André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 2/9] gnu: Add go-github-com-agl-ed25519 André Batista
@ 2021-06-03  3:17                     ` André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 4/9] gnu: Add go-github-com-dchest-uniuri André Batista
                                       ` (5 subsequent siblings)
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2021-06-03  3:17 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

* gnu/packages/golang.scm (go-github-com-dchest-siphash): New variable.

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 2569d450b2..037163766d 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -7096,3 +7096,30 @@ is unmaintained.  Newer software should use x-crypto instead.")
      ;; License file is referred but it is missing. Probably because the
      ;; author decided to discontinue the project.
      (license (license:non-copyleft "file://ed25519.go")))))
+
+(define-public go-github-com-dchest-siphash
+  (let ((commit "34f201214d993633bb24f418ba11736ab8b55aa7")
+        (revision "0"))
+    (package
+     (name "go-github-com-dchest-siphash")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dchest/siphash")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "08s076y7vmjqnq7jz0762hkm896r6r31v8b31a3gy0n8rfa01k8k"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dchest/siphash"))
+     (home-page "https://github.com/dchest/siphash")
+     (synopsis "Go library for siphash")
+     (description "Go implementation of SipHash-2-4, a fast short-input
+Pseudo Random Function which is suitable for usage in message authentication
+codes and was based on the design created by Jean-Philippe Aumasson and Daniel
+J. Bernstein. ")
+     (license license:cc0))))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v4 4/9] gnu: Add go-github-com-dchest-uniuri.
  2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
                                       ` (2 preceding siblings ...)
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 3/9] gnu: Add go-github-com-dchest-siphash André Batista
@ 2021-06-03  3:17                     ` André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 5/9] gnu: Add go-github-com-dsnet-compress André Batista
                                       ` (4 subsequent siblings)
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2021-06-03  3:17 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

* gnu/packages/golang.scm (go-github-com-dchest-uniuri): New variable.

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 037163766d..08b5b6ba9b 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -7123,3 +7123,28 @@ Pseudo Random Function which is suitable for usage in message authentication
 codes and was based on the design created by Jean-Philippe Aumasson and Daniel
 J. Bernstein. ")
      (license license:cc0))))
+
+(define-public go-github-com-dchest-uniuri
+  (let ((commit "8902c56451e9b58ff940bbe5fec35d5f9c04584a")
+        (revision "0"))
+    (package
+     (name "go-github-com-dchest-uniuri")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dchest/uniuri")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "1x5bsbm1nlphsv96zd0rbclfaa1swpz5bp14x7s5dbxp0awk2gd4"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dchest/uniuri"))
+     (home-page "https://github.com/dchest/uniuri")
+     (synopsis "Go library for random URIs")
+     (description "Package uniuri generates random strings good for use in
+Universal Resource Identifiers to uniquely identify objects.")
+     (license license:cc0))))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v4 5/9] gnu: Add go-github-com-dsnet-compress.
  2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
                                       ` (3 preceding siblings ...)
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 4/9] gnu: Add go-github-com-dchest-uniuri André Batista
@ 2021-06-03  3:17                     ` André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 6/9] gnu: Add go-schwanenlied-me-yawning-bsaes André Batista
                                       ` (3 subsequent siblings)
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2021-06-03  3:17 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

* gnu/packages/golang.scm (go-github-com-dsnet-compress): New variable.

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 08b5b6ba9b..f554a8305e 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -7148,3 +7148,29 @@ J. Bernstein. ")
      (description "Package uniuri generates random strings good for use in
 Universal Resource Identifiers to uniquely identify objects.")
      (license license:cc0))))
+
+(define-public go-github-com-dsnet-compress
+  (let ((commit "cc9eb1d7ad760af14e8f918698f745e80377af4f")
+        (revision "0"))
+    (package
+     (name "go-github-com-dsnet-compress")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dsnet/compress")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "159liclywmyb6zx88ga5gn42hfl4cpk1660zss87fkx31hdq9fgx"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "github.com/dsnet/compress"))
+     (home-page "https://github.com/dsnet/compress")
+     (synopsis "Go library for extended compression")
+     (description "This is a collection of compression related libraries.
+The goal of this project is to provide pure Go implementations for popular
+compression algorithms bey ond what the Go standard library provides.")
+     (license (license:non-copyleft "file://LICENSE.md")))))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v4 6/9] gnu: Add go-schwanenlied-me-yawning-bsaes.
  2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
                                       ` (4 preceding siblings ...)
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 5/9] gnu: Add go-github-com-dsnet-compress André Batista
@ 2021-06-03  3:17                     ` André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 7/9] gnu: Add go-gitlab-com-yawning-utls André Batista
                                       ` (2 subsequent siblings)
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2021-06-03  3:17 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

* gnu/packages/golang.scm (go-schwanenlied-me-yawning-bsaes): New variable.

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index f554a8305e..6cf7ffc90c 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -7174,3 +7174,32 @@ Universal Resource Identifiers to uniquely identify objects.")
 The goal of this project is to provide pure Go implementations for popular
 compression algorithms bey ond what the Go standard library provides.")
      (license (license:non-copyleft "file://LICENSE.md")))))
+
+(define-public go-schwanenlied-me-yawning-bsaes
+  (let ((commit "26d1add596b6d800bdeeb3bc3b2c7b316c056b6d")
+        (revision "0"))
+    (package
+     (name "go-schwanenlied-me-yawning-bsaes")
+     (version (git-version "0.0.0" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.schwanenlied.me/yawning/bsaes.git")
+             (commit commit)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32
+         "0h4dsyw54n9rcwprqy93wv2v1gcvlq1vfqdp1g7wxdkq457rhvys"))))
+     (build-system go-build-system)
+     (arguments
+      '(#:import-path "git.schwanenlied.me/yawning/bsaes.git"))
+     (home-page "https://git.schwanenlied.me/yawning/bsaes.git")
+     (synopsis "Go AES library")
+     (description "Portable pure-Go constant time Advanced Encryption
+Standard (AES) for eletronic data encryption.  This implementation if
+based on code from [BearSSL](https://bearssl.org/).  On AMD64 systems
+with hardware support for AES New Instructions (AES-NI) and a
+sufficiently recent Go runtime, it will transparently call crypto/aes
+when NewCipher is invoked.")
+     (license (license:non-copyleft "file://LICENSE.txt")))))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v4 7/9] gnu: Add go-gitlab-com-yawning-utls.
  2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
                                       ` (5 preceding siblings ...)
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 6/9] gnu: Add go-schwanenlied-me-yawning-bsaes André Batista
@ 2021-06-03  3:17                     ` André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 8/9] gnu: Add obfs4 André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 9/9] gnu: Add torbrowser-unbundle André Batista
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2021-06-03  3:17 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

* gnu/packages/golang.scm (go-gitlab-com-yawning-utls): New variable.

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 6cf7ffc90c..b4e8c1f338 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -7203,3 +7203,34 @@ with hardware support for AES New Instructions (AES-NI) and a
 sufficiently recent Go runtime, it will transparently call crypto/aes
 when NewCipher is invoked.")
      (license (license:non-copyleft "file://LICENSE.txt")))))
+
+(define-public go-gitlab-com-yawning-utls
+  (package
+   (name "go-gitlab-com-yawning-utls")
+   (version "0.0.10-1")
+   (source
+    (origin
+     (method git-fetch)
+     (uri (git-reference
+           (url "https://gitlab.com/yawning/utls.git")
+           (commit (string-append "v" version))))
+     (file-name (git-file-name name version))
+     (sha256
+      (base32
+       "15c46s56r45n22rmq9spnczydnkqrnxff28h5mpnk5yvcqif3lgb"))))
+   (build-system go-build-system)
+   (arguments
+    '(#:tests? #f ;; Tries to connect and fails.
+      #:import-path "gitlab.com/yawning/utls.git"))
+   (propagated-inputs
+    `(("go-schwanenlied-me-yawning-bsaes" ,go-schwanenlied-me-yawning-bsaes)
+      ("go-github-com-dsnet-compress" ,go-github-com-dsnet-compress)
+      ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)))
+   (home-page "https://gitlab.com/yawning/utls.git")
+   (synopsis "Go library for uTLS")
+   (description "This library is a fork of the main Transport Layer Security
+protocol in Go (crypto/tls) which provides ClientHello fingerprinting resistance,
+low level access to handshakes and fake session tickets among other features.
+This fork was made for the specific purpose of improving obfs4proxy's meek_lite
+transport protocol.")
+   (license license:gpl3+)))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v4 8/9] gnu: Add obfs4.
  2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
                                       ` (6 preceding siblings ...)
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 7/9] gnu: Add go-gitlab-com-yawning-utls André Batista
@ 2021-06-03  3:17                     ` André Batista
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 9/9] gnu: Add torbrowser-unbundle André Batista
  8 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2021-06-03  3:17 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

* gnu/packages/tor.scm (obfs4): New variable.
* Alphabetically order module imports.

diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index bd11dd3a75..52d78cba79 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -9,7 +9,7 @@
 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
 ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
-;;; Copyright © 2020 André Batista <nandre@riseup.net>
+;;; Copyright © 2020, 2021 André Batista <nandre@riseup.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -33,13 +33,16 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system go)
   #:use-module (guix build-system python)
   #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
-  #:use-module (gnu packages libevent)
-  #:use-module (gnu packages linux)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages golang)
+  #:use-module (gnu packages libevent)
+  #:use-module (gnu packages linux)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -423,3 +426,75 @@ statistics and status reports on:
 
 Potential client and exit connections are scrubbed of sensitive information.")
     (license license:gpl3+)))
+
+(define-public obfs4
+  (package
+    (name "obfs4")
+    (version "0.0.11")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.torproject.org/pluggable-transports/obfs4.git")
+             (commit (string-append "obfs4proxy-" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "1y2kjwrk64l1h8b87m4iqsanib5rn68gzkdri1vd132qrlypycjn"))))
+    (build-system go-build-system)
+    (arguments
+     '(#:import-path "git.torproject.org/pluggable-transports/obfs4.git"
+       #:tests? #f ;; No test files
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'build
+           (lambda* (#:key outputs configure-flags #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (copy-recursively
+                "src/git.torproject.org/pluggable-transports/obfs4.git"
+                "src/gitlab.com/yawning/obfs4.git"
+                #:log (%make-void-port "w"))
+               (with-directory-excursion
+                   "src/git.torproject.org/pluggable-transports/obfs4.git/obfs4proxy"
+                 (invoke "go" "build" "-ldflags" "-s"))
+               #t)))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (src "src/git.torproject.org/pluggable-transports/obfs4.git")
+                    (bin (string-append out "/bin"))
+                    (share (string-append out "/share"))
+                    (doc (string-append share "/doc"))
+                    (man (string-append share "/man/man1")))
+               (mkdir-p man)
+               (mkdir bin)
+               (mkdir doc)
+               (with-directory-excursion
+                   (string-append src "/obfs4proxy")
+                 (copy-file "obfs4proxy"
+                            (string-append bin "/obfs4proxy")))
+               (with-directory-excursion
+                   (string-append src "/doc")
+                 (copy-file "obfs4proxy.1"
+                            (string-append man "/obfs4proxy.1"))
+                 (copy-file "obfs4-spec.txt"
+                            (string-append doc "/obfs4-spec.txt")))
+               #t))))))
+    (propagated-inputs
+     `(("go-torproject-org-ptlib" ,go-torproject-org-ptlib)
+       ("go-github-com-agl-ed25519" ,go-github-com-agl-ed25519)
+       ("go-github-com-dchest-siphash" ,go-github-com-dchest-siphash)
+       ("go-github-com-dchest-uniuri" ,go-github-com-dchest-uniuri)
+       ("go-github-com-dsnet-compress" ,go-github-com-dsnet-compress)
+       ("go-schwanenlied-me-yawning-bsaes" ,go-schwanenlied-me-yawning-bsaes)
+       ("go-gitlab-com-yawning-utls" ,go-gitlab-com-yawning-utls)
+       ("go-golang-org-x-net" ,go-golang-org-x-net)
+       ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)
+       ("go-golang-org-x-text" ,go-golang-org-x-text)))
+    (home-page "https://git.torproject.org/pluggable-transports/obfs4.git")
+    (synopsis "Obfs4 implements an obfuscation protocol")
+    (description "This is a look-like nothing obfuscation protocol that
+incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol.
+The obfs naming was chosen primarily because it was shorter, in terms of
+protocol ancestery obfs4 is much closer to ScrambleSuit than obfs2/obfs3.")
+    (license license:gpl3+)))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v4 9/9] gnu: Add torbrowser-unbundle.
  2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
                                       ` (7 preceding siblings ...)
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 8/9] gnu: Add obfs4 André Batista
@ 2021-06-03  3:17                     ` André Batista
  2021-06-03  4:10                       ` [bug#42380] [PATCH v5 " André Batista
  8 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2021-06-03  3:17 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

* gnu/packages/tor.scm (torbrowser-unbundle): New variable.
* gnu/packages/patches/torbrowser-start-desktop.patch: New file.
* gnu/packages/patches/torbrowser-start-script.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.

 create mode 100644 gnu/packages/patches/torbrowser-start-desktop.patch
 create mode 100644 gnu/packages/patches/torbrowser-start-script.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index a5820b5827..c5fdb8fc16 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -42,6 +42,7 @@
 # Copyright © 2021 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 # Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
 # Copyright © 2021 Arun Isaac <arunisaac@systemreboot.net>
+# Copyright © 2021 André Batista <nandre@riseup.net>
 #
 # This file is part of GNU Guix.
 #
@@ -1739,6 +1740,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/tipp10-qt5.patch			\
   %D%/packages/patches/tk-find-library.patch			\
   %D%/packages/patches/tla2tools-build-xml.patch		\
+  %D%/packages/patches/torbrowser-start-desktop.patch           \
+  %D%/packages/patches/torbrowser-start-script.patch            \
   %D%/packages/patches/transcode-ffmpeg.patch	\
   %D%/packages/patches/transmission-honor-localedir.patch	\
   %D%/packages/patches/ttf2eot-cstddef.patch			\
diff --git a/gnu/packages/patches/torbrowser-start-desktop.patch b/gnu/packages/patches/torbrowser-start-desktop.patch
new file mode 100644
index 0000000000..6832ed363b
--- /dev/null
+++ b/gnu/packages/patches/torbrowser-start-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.desktop.orig    2020-07-05 18:47:40.689484877 -0300
++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser.desktop 2020-07-24 14:36:37.720579884 -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 shell.
+ # It preserves arguments and environment for the start-tor-browser script.
+@@ -28,7 +28,7 @@
+ GenericName=Web Browser
+ Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
+ Categories=Network;WebBrowser;Security;
+-Exec=sh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/start-tor-browser --detach)' dummy %k
+-X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
+-Icon=web-browser
++Exec=sh -c start-tor-browser
++X-TorBrowser-ExecShell=start-tor-browser --detach
++Icon=torbrowser
+ StartupWMClass=Tor Browser
diff --git a/gnu/packages/patches/torbrowser-start-script.patch b/gnu/packages/patches/torbrowser-start-script.patch
new file mode 100644
index 0000000000..b8c8d9a26a
--- /dev/null
+++ b/gnu/packages/patches/torbrowser-start-script.patch
@@ -0,0 +1,181 @@
+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.orig    2020-07-05 18:47:40.685485004 -0300
++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser 2020-07-23 18:13:32.426282743 -0300
+@@ -5,6 +5,14 @@
+ #
+ # 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"
++
+ complain_dialog_title="Tor Browser"
+ 
+ # First, make sure DISPLAY is set.  If it isn't, we're hosed; scream
+@@ -134,8 +142,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 +195,22 @@
+ 	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"
++   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 +225,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 +247,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 +309,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,<dir>fonts</dir>,<dir>${TBB_STORE_PATH}/fonts</dir>,"
++
+ cd "${HOME}"
+ 
+ # We pass all additional command-line arguments we get to Firefox.
+@@ -357,23 +326,23 @@
+ 
+ if [ "$show_usage" -eq 1 ]; then
+     # Display Firefox help, then our help
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default --help 2>/dev/null
++    TOR_CONTROL_PASSWD=${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=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-       -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++       -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
+     disown "$!"
+ elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
+         tee "$logfile"
+ elif [ "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" < /dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" < /dev/null
+ else
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
+ fi
+ 
+ exit $?
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index 52d78cba79..bfb1ac1841 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -498,3 +498,677 @@ incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol.
 The obfs naming was chosen primarily because it was shorter, in terms of
 protocol ancestery obfs4 is much closer to ScrambleSuit than obfs2/obfs3.")
     (license license:gpl3+)))
+
+;; torbrowser and tor-browser-builder build versions are not always in sync
+(define %torbrowser-version "78.11.0esr-10.0-1")
+(define %tbb-build-version "10.0.17")
+(define %torbrowser-build "build1")
+(define %tbb-build "build1")
+(define %torbrowser-build-id "20210602000000");must be of the form YYYYMMDDhhmmss
+
+;; Fonts for Tor Browser. Avoid downloading 4Gb+ git repo on
+;; https://github.com/googlei18n/noto-fonts.git to use just a handful.
+;; Use the fonts on Tor Browser release tarball.
+(define torbrowser-fonts
+  (package
+    (name "torbrowser-fonts")
+    (version %tbb-build-version)
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://archive.torproject.org/tor-package-archive/torbrowser/"
+                           version "/tor-browser-linux64-"
+                           version "_en-US.tar.xz"))
+       (sha256
+        (base32
+         "13x38n1cvqmxjz0jf2fda8lx2k25szzmg7gvv08z3q5na7109m2m"))))
+    (build-system trivial-build-system)
+    (native-inputs
+     `(("tar" ,tar)
+       ("xz" ,xz)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+                   (use-modules (guix build utils))
+                   (let ((src (assoc-ref %build-inputs "source"))
+                         (src-dir "tor-browser_en-US/Browser/fonts")
+                         (fonts (string-append %output "/share/fonts"))
+                         (tar (assoc-ref %build-inputs "tar"))
+                         (xz (assoc-ref %build-inputs "xz")))
+                     (mkdir-p fonts)
+                     (format #t "Untaring torbrowser ball ...~%")
+                     (invoke (string-append tar "/bin/tar") "-xf" src
+                             "-C" fonts "--strip-components=3"
+                             (string-append "--use-compress-program=" xz "/bin/xz")
+                             src-dir)
+                     #t))))
+    (home-page "https://github.com/googlei18n/noto-fonts")
+    (synopsis "Tor Browser bundled fonts")
+    (description "Free fonts bundled with Tor Browser.  Includes a subset of Noto,
+Arimo, Cousine, Tinos and STIX fonts.")
+    (license license:silofl1.1)))
+
+(define tor-browser-build
+  (let ((commit (string-append "tbb-desktop-" %tbb-build-version
+                               "-" %tbb-build)))
+    (package
+      (name "tor-browser-build")
+      (version %tbb-build-version)
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://git.torproject.org/builders/tor-browser-build.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1qwgghy79wx0w1yz132yyaln4g42s72133n6gbdf07rkf5n44izc"))))
+      (build-system trivial-build-system)
+      (arguments
+       `(#:modules ((guix build utils))
+         #:builder (begin
+                     (use-modules (guix build utils))
+                     (format #t "Copying build scripts ...~%")
+                     (copy-recursively (string-append
+                                        (assoc-ref %build-inputs "source")
+                                        "/projects/tor-browser")
+                                       %output
+                                       #:log (%make-void-port "w")))))
+      (home-page "https://www.torproject.org")
+      (synopsis "Tor Browser build scripts")
+      (description "Tor Browser runtime scripts.")
+      (license (license:non-copyleft "file://LICENSE")))))
+
+(define tor-launcher
+  (package
+    (name "tor-launcher")
+    (version "0.2.28")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://archive.torproject.org/tor-package-archive/torbrowser/"
+                           %tbb-build-version "/src-" name "-"
+                           version ".tar.xz"))
+       (sha256
+        (base32
+         "0mbd1q46d8nqisn6n79sp6m29332ymb2pf13xzgq1ml7rfcy6jjy"))))
+    (build-system trivial-build-system)
+    (native-inputs
+     `(("tar" ,tar)
+       ("xz" ,xz)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+                   (use-modules (guix build utils))
+		   (format #t "Extracting source ...~%")
+                   (let ((src (assoc-ref %build-inputs "source"))
+                         (tar (assoc-ref %build-inputs "tar"))
+                         (xz (assoc-ref %build-inputs "xz")))
+                     (mkdir-p %output)
+                     (format #t "Extracting source ...~%")
+                     (invoke (string-append tar "/bin/tar") "-xf" src
+                             "-C" %output "--strip-components=1"
+                             (string-append "--use-compress-program=" xz "/bin/xz"))))))
+    (home-page "https://www.torproject.org")
+    (synopsis "Tor Browser built-in controler extension")
+    (description "Browser extension that starts the tor process (which
+connects the browser and other applications to the Tor Network), and
+which helps people configure and use @code{tor}. The first window that
+you see when you start Tor Browser is displayed by this extension.")
+    (license (license:non-copyleft "file://src/LICENSE"))))
+
+(define https-everywhere-lib-wasm
+  (let ((commit "45b1622f1240659aca4762fa336aad1322d6d50f"))
+    (package
+      (name "https-everywhere-lib-wasm")
+      (version "2021.4.15")
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/EFForg/https-everywhere-lib-wasm")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1lq62rzypdzmnnzvfns3ccvv1g7p7g9s8jx788zzigr3gnmkpffx"))))
+      (build-system trivial-build-system)
+      (arguments
+       `(#:modules ((guix build utils))
+         #:builder (begin
+                     (use-modules (guix build utils))
+                     (format #t "Copying source ...~%")
+                     (copy-recursively (assoc-ref %build-inputs "source")
+                                       %output
+                                       #:log (%make-void-port "w")))))
+      (home-page "https://github.com/EFForg/https-everywhere-lib-wasm")
+      (synopsis "Browser extension for protection against known attacks")
+      (description "Browser extension that protects users from a range of
+known attacks on web browsing activity such as Cross-site scripting, clickjack and
+makes possible for the users to block or choose on a per site basis which remote
+javascript to run while browsing the web.")
+      (license license:gpl2+))))
+
+;; Both https-everywhere and noscript are rellying on some precompiled code for now.
+;; Also read on the work on chromium extensions on gnu/build/chromium-extensions.scm
+;; to see if can be adapted.
+(define-public https-everywhere
+  (package
+    (name "https-everywhere")
+    (version "2021.4.15")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/EFForg/" name "/archive/"
+                           version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "1bknx8l8gxmpwb13pvn6pdbavknci8q0jhygdaz50ilc1xld89i3"))))
+    (build-system trivial-build-system)
+    (native-inputs
+     `(("bash" ,bash)
+       ("coreutils" ,coreutils)
+       ("findutils" ,findutils)
+       ("git" ,git)
+       ("grep" ,grep)
+       ("gzip" ,gzip)
+       ("https-everywhere-lib-wasm"
+        ,https-everywhere-lib-wasm)
+       ("libxml2" ,libxml2)
+       ("libxslt" ,libxslt)
+       ("openssl" ,openssl)
+       ("python" ,python)
+       ("rsync" ,rsync)
+       ("sed" ,sed)
+       ("tar" ,tar)
+       ("util-linux" ,util-linux) ; for getopt
+       ("xxd" ,xxd)
+       ("which" ,which)
+       ("zip" ,zip)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+                   (use-modules (guix build utils))
+                   (let ((src (assoc-ref %build-inputs "source"))
+                         (httpse-libwasm (assoc-ref %build-inputs
+                                                    "https-everywhere-lib-wasm"))
+                         (bash (assoc-ref %build-inputs "bash"))
+                         (coreutils (assoc-ref %build-inputs "coreutils"))
+                         (python (assoc-ref %build-inputs "python"))
+                         (openssl (assoc-ref %build-inputs "openssl"))
+                         (git (assoc-ref %build-inputs "git"))
+                         (grep (assoc-ref %build-inputs "grep"))
+                         (findutils (assoc-ref %build-inputs "findutils"))
+                         (sed (assoc-ref %build-inputs "sed"))
+                         (which (assoc-ref %build-inputs "which"))
+                         (rsync (assoc-ref %build-inputs "rsync"))
+                         (libxml2 (assoc-ref %build-inputs "libxml2"))
+                         (libxslt (assoc-ref %build-inputs "libxslt"))
+                         (util-linux (assoc-ref %build-inputs "util-linux"))
+                         (xxd (assoc-ref %build-inputs "xxd"))
+                         (zip (assoc-ref %build-inputs "zip"))
+                         (tar (assoc-ref %build-inputs "tar"))
+                         (gzip (assoc-ref %build-inputs "gzip")))
+                     (setenv "SHELL" (string-append bash "/bin/bash"))
+                     (set-path-environment-variable
+                      "PATH" '("bin")
+                      (list bash sed findutils which git python tar openssl rsync
+                            libxml2 libxslt util-linux grep xxd gzip zip coreutils))
+                     (set-path-environment-variable
+                      "LIBRARY_PATH" '("lib")
+                      (list bash sed findutils which git python tar openssl rsync
+                            libxml2 libxslt util-linux grep xxd gzip zip coreutils))
+                     (format #t "Untaring source tarball ...~%")
+                     (invoke "tar" "-xf" src "--strip-components=1")
+                     ;; Python3.6 is hardcoded on these scripts. Using v3.8 appears to
+                     ;; be harmless.
+                     (substitute* '("install-dev-dependencies.sh"
+                                    "make.sh"
+                                    "hooks/precommit"
+                                    "test/firefox.sh"
+                                    "test/manual.sh"
+                                    "test/rules/src/https_everywhere_checker/check_rules.py"
+                                    "test/script.py"
+                                    "test/validations.sh"
+                                    "test/validations/filename/run.py"
+                                    "test/validations/relaxng/run.py"
+                                    "test/validations/securecookie/run.py"
+                                    "test/validations/special/run.py"
+                                    "utils/create_zip.py"
+                                    "utils/chromium-translations.py"
+                                    "utils/create-platform-certs/split_combined_cert_file.py"
+                                    ;; "utils/mk-client-whitelist/dbconnect.py"
+                                    ;; "utils/mk-client-whitelist/run.py"
+                                    "utils/merge-rulesets.py"
+                                    "utils/setversion.py"
+                                    "utils/zipfile_deterministic.py")
+                       (("python3.6") "python3"))
+                     (make-file-writable "lib-wasm")
+                     (copy-recursively httpse-libwasm
+                                       "lib-wasm"
+                                       #:log (%make-void-port "w"))
+                     ;; Remove precompiled binaries from source. This breaks
+                     ;; http-everywhere at runtime, but building is successful.
+                     ;; For now building takes the precompiled version included with sources.
+		     ;; Tor Browser upstream does the same. In case you want to remove the
+		     ;; precompiled version, use the routine below. It successfully builds
+		     ;; but at run time rules seem to be broken.
+                     ;(with-directory-excursion "lib-wasm/pkg"
+                     ;  (for-each (lambda (file)
+                     ;              (if (file-exists? file)
+                     ;                  (delete-file file)
+                     ;                  (display (string-append
+                     ;                            "Warning: file " file
+                     ;                            " not found! Skipping...\n"))))
+                     ;            '("https_everywhere_lib_wasm.js"
+                     ;              "https_everywhere_lib_wasm_bg.wasm")))
+                     (for-each patch-shebang
+                               (find-files "."
+                                           (lambda (file stat)
+                                             ;; Filter out symlinks.
+                                             (eq? 'regular (stat:type stat)))
+                                           #:stat lstat))
+                     ;; Failing to generate the xpi, but copy-dir appears to be enough.
+                     ;; Failing on missing 'wasm'? Not generating rulesets. Once lib-wasm
+		     ;; gets cross-compiled, try to move the '.xpi' extension instead.
+                     (invoke "./make.sh")
+                     (copy-recursively "pkg/xpi-eff" %output
+                                       #:log (%make-void-port "w"))
+                     #t))))
+    (home-page "https://www.eff.org/https-everywhere")
+    (synopsis "Browser extension for automatic HTTPS usage")
+    (description "Browser extension that automatically makes the browser to use
+HTTPS instead of plain HTTP when the remote destination makes it available to users.")
+    (license license:gpl2+)))
+
+(define noscript
+  (package
+    (name "noscript")
+    (version "11.2.8")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://secure.informaction.com/download/releases/"
+                           name "-" version ".xpi"))
+       (sha256
+        (base32
+         "0rrlhlzljlmgns7j49c43ilb8wij2zcysrbpap1xxsfbkbczji27"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+		   ;; Fake build for now. Upstream Tor Browser does not build it as well.
+                   (format #t "Copying source ...~%")
+                   (copy-file (assoc-ref %build-inputs "source")
+                              %output))))
+    (home-page "https://noscript.net")
+    (synopsis "Browser extension for protection against known attacks")
+    (description "Browser extension that protects users from a range of
+known attacks on web browsing activity such as Cross-site scripting, clickjack and
+makes possible for the users to block or choose on a per site basis which remote
+javascript to run while browsing the web.")
+    (license license:gpl2+)))
+
+;; (Un)fortunatly Tor Browser has it's own reproducible build system - RBM - which
+;; automates the build process for them and compiles Tor Browser from a range of
+;; repositories and produces a range of tarballs for different architectures and
+;; locales. So we need to cherry-pick what is needed for guix and produce our own
+;; tarball. See https://gitweb.torproject.org/builders/tor-browser-build.git/projects/\
+;; {tor-browser,firefox}/{build,config} for the rationale applied here. See also
+;; the Hacking on Tor Browser document for a high level introduction at
+;; https://trac.torproject.org/projects/tor/wiki/doc/Tor Browser/Hacking).
+;;
+;; TODO: Import langpacks from https://archive.torproject.org/tor-package-archive/\
+;; torbrowser/'version'/langpacks-tor-browser-linux64-version.tar.xz
+(define-public torbrowser-unbundle
+  (let ((commit (string-append "tor-browser-" %torbrowser-version
+                               "-" %torbrowser-build)))
+    (package
+      (inherit icecat)
+      (name "torbrowser-unbundle")
+      (version %tbb-build-version)
+      (source
+       (origin
+	 (method url-fetch)
+	 (uri (string-append "https://archive.torproject.org/tor-package-archive/torbrowser/"
+			     %tbb-build-version
+			     "/src-firefox-tor-browser-"
+			     %torbrowser-version "-" %torbrowser-build
+			     ".tar.xz"))
+	 (sha256
+          (base32
+           "1jnb7v9zn7y2fk7gqvq1ijlwl16i7wf83y1xn2djqcp1j42n1yvq"))))
+      (build-system gnu-build-system)
+      (inputs
+       `(("obfs4" ,obfs4)
+	 ("tor" ,tor-client)
+	 ,@(package-inputs icecat)))
+      (native-inputs
+       `(("https-everywhere" ,https-everywhere)
+	 ("noscript" ,noscript)
+	 ("tor-browser-build" ,tor-browser-build)
+	 ("tor-launcher" ,tor-launcher)
+	 ("torbrowser-fonts" ,torbrowser-fonts)
+	 ("torbrowser-start-script.patch"
+          ,(search-patch "torbrowser-start-script.patch"))
+	 ("torbrowser-start-desktop.patch"
+          ,(search-patch "torbrowser-start-desktop.patch"))
+	 ,@(package-native-inputs icecat)))
+      (properties '())
+      (arguments
+       (substitute-keyword-arguments (package-arguments icecat)
+	 ((#:phases phases)
+          `(modify-phases ,phases
+             ;; On mach build system this is done on configure.
+             (delete 'bootstrap)
+             ;; Doesn't seem to be needed for TorBrowser
+             (delete 'fix-ffmpeg-runtime-linker)
+             ;; Tried to make use of these using let, but inheritance appears to block it.
+             (delete 'install-icons)
+             (delete 'install-desktop-entry)
+             (add-after 'unpack 'make-bundle
+               (lambda* (#:key inputs native-inputs #:allow-other-keys)
+		 (let ((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 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 "browser/app/profile/000-tor-browser.js")
+		   (make-file-writable (string-append tbb-scripts-dir
+						      "/RelativeLink/start-tor-browser"))
+                   (make-file-writable (string-append tbb-scripts-dir
+						      "/RelativeLink/start-tor-browser.desktop")))
+		 #t))
+             (replace 'apply-guix-specific-patches
+               (lambda* (#:key inputs native-inputs #:allow-other-keys)
+		 (let ((patch (string-append (assoc-ref (or native-inputs inputs)
+							"patch")
+                                             "/bin/patch")))
+                   (for-each (match-lambda
+                               ((label . file)
+				;; Only difference to icecat is browser name.
+				(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-bridge-preferences
+               (lambda* (#:key inputs native-inputs #:allow-other-keys)
+		 (begin
+                   (let ((tbb-prefs (open-file
+                                     "browser/app/profile/000-tor-browser.js" "a"))
+			 (bridge-prefs
+                          (open-input-file
+                           "tbb-scripts/Bundle-Data/PTConfigs/bridge_prefs.js")))
+                     (display (get-string-all bridge-prefs) tbb-prefs)
+                     (close-output-port tbb-prefs)))
+		 #t))
+             (replace 'configure
+               (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(bash (which "bash"))
+			(flags `(,(string-append "--prefix=" 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 "python-2")
+                                                   "/bin/python"))
+                   (setenv "CC" "gcc")  ; needed when Stylo is enabled
+                   (setenv "MOZ_BUILD_DATE" ,%torbrowser-build-id) ; avoid timestamp.
+                   (setenv "LDFLAGS" (string-append "-Wl,-rpath="
+                                                    (assoc-ref outputs "out")
+                                                    "/lib"))
+                   (substitute* ".mozconfig"
+                     ;; Arch independent builddir.
+                     (("(mk_add_options MOZ_OBJDIR=@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=dev-build")
+		      ;; If we decide to rebrand this browser, here is the place to do it.
+                      (string-append
+                       "ac_add_options --with-tor-browser-version=org.gnu\n"
+                       "ac_add_options --with-unsigned-addon-scopes=app,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"
+                       "ac_add_options --enable-system-pixman\n"
+                       "ac_add_options --enable-system-ffi\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-nspr\n" ;; broken for now, see icecat.
+                       ;;"ac_add_options --with-system-nss\n"
+                       "ac_add_options --with-system-zlib\n"
+                       ;; Without these clang is not found.
+                       "ac_add_options --with-clang-path="
+                       (assoc-ref %build-inputs "clang") "/bin/clang\n"
+                       "ac_add_options --with-libclang-path="
+                       (assoc-ref %build-inputs "clang") "/lib\n")))
+                   (substitute* "browser/app/profile/000-tor-browser.js"
+                     ;; Tor Browser updates are disabled on mozconfig, but let'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.snowflake.1\".*")
+                      "\n"))
+                   (substitute*
+                       "browser/extensions/tor-launcher/src/defaults/preferences/torlauncher-prefs.js"
+                     ;; Not multilingual. See tor-browser/build:141. Currently disabled on
+                     ;; tor-launcher, but let's make sure while missing langpacks.
+                     (("(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))
+             (add-after 'configure 'install-desk-icons
+               (lambda* (#:key outputs #:allow-other-keys)
+		 (let ((out (assoc-ref outputs "out")))
+                   (with-directory-excursion "browser/branding/official"
+                     (for-each
+                      (lambda (file)
+			(let* ((size (string-filter char-numeric? file))
+                               (icons (string-append out "/share/icons/hicolor/"
+                                                     size "x" size "/apps")))
+                          (mkdir-p icons)
+                          (copy-file file (string-append icons "/torbrowser.png"))))
+                      '("default16.png" "default22.png" "default24.png"
+			"default32.png" "default48.png" "default64.png"
+			"default128.png" "default256.png" "default512.png"))
+                     #t))))
+             (replace 'build
+               (lambda _
+		 (make-file-writable "Cargo.lock")
+		 (invoke "./mach" "build")
+                 #t))
+             (replace 'neutralise-store-references
+               (lambda _
+		 ;; difference from icecat "objdir" preffix. We could use find-files there.
+		 (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)
+                                   "<!-- Guix: not a runtime dependency -->"
+                                   (string-drop hash 8))))
+		 #t))
+             ;; Tor Browser just do a stage-package here and copy files to its 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"))
+			(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" "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") #o555)
+                   (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-fonts
+               (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(lib (string-append out "/lib/"))
+			(fonts  (string-append (or (assoc-ref native-inputs
+                                                              "torbrowser-fonts")
+                                                   (assoc-ref inputs
+                                                              "torbrowser-fonts"))
+                                               "/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-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(lib (string-append out "/lib"))
+			(ext (string-append lib "/browser/extensions"))
+			(torb-ext (string-append lib
+						 "/chrome/torbutton/content/extensions"))
+			(httpse-id "https-everywhere")
+			(noscript-id "{73a6fe31-595d-460b-a920-fcc0f8843232}")
+			(httpse (assoc-ref inputs "https-everywhere"))
+			(noscript (assoc-ref inputs "noscript")))
+                   (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. This step is
+		   ;; changing some timestamps and making everything non-deterministic.
+		   ;; To check insert 'resource://torbutton/content/extensions/https-everywhere/'
+		   ;; on the browser address field. Check 'reset-gzip-timestamps' to see what
+		   ;; can be done.
+		   ;; https://gitweb.torproject.org/builders/tor-browser-build.git/tree/projects/\
+		   ;; tor-browser/build?h=tbb-desktop-10.0.17-build1&id=16fa8c3bf91a9c1a827a7d23be344de599cd10bb#n77g
+                   (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-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(tordir (string-append out "/lib/TorBrowser/Tor"))
+			(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-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(lib (string-append out "/lib"))
+			(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 "/" file)
+                                                   #:log (%make-void-port "w")))
+                               '("Browser" "fontconfig" "Tor")))
+                   (copy-file (string-append ptconf "/linux/torrc-defaults-appendix")
+                              (string-append data "/Tor/torrc-defaults-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
+             (replace 'wrap-program
+               (lambda* (#:key inputs outputs #:allow-other-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(lib (string-append out "/lib"))
+			(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")))
+                   ;; Only difference to icecat is browser name.
+                   (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 the only
+recommended way to anonymously browse the web that is supported by the project.
+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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v5 9/9] gnu: Add torbrowser-unbundle.
  2021-06-03  3:17                     ` [bug#42380] [PATCH v4 9/9] gnu: Add torbrowser-unbundle André Batista
@ 2021-06-03  4:10                       ` André Batista
  2021-06-03 21:07                         ` Maxime Devos
  2021-06-03 21:07                         ` Maxime Devos
  0 siblings, 2 replies; 56+ messages in thread
From: André Batista @ 2021-06-03  4:10 UTC (permalink / raw)
  To: 42380; +Cc: André Batista

* gnu/packages/tor.scm (torbrowser-unbundle): New variable.
* gnu/packages/patches/torbrowser-start-desktop.patch: New file.
* gnu/packages/patches/torbrowser-start-script.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.

 create mode 100644 gnu/packages/patches/torbrowser-start-desktop.patch
 create mode 100644 gnu/packages/patches/torbrowser-start-script.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index a5820b5827..c5fdb8fc16 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -42,6 +42,7 @@
 # Copyright © 2021 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 # Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
 # Copyright © 2021 Arun Isaac <arunisaac@systemreboot.net>
+# Copyright © 2021 André Batista <nandre@riseup.net>
 #
 # This file is part of GNU Guix.
 #
@@ -1739,6 +1740,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/tipp10-qt5.patch			\
   %D%/packages/patches/tk-find-library.patch			\
   %D%/packages/patches/tla2tools-build-xml.patch		\
+  %D%/packages/patches/torbrowser-start-desktop.patch           \
+  %D%/packages/patches/torbrowser-start-script.patch            \
   %D%/packages/patches/transcode-ffmpeg.patch	\
   %D%/packages/patches/transmission-honor-localedir.patch	\
   %D%/packages/patches/ttf2eot-cstddef.patch			\
diff --git a/gnu/packages/patches/torbrowser-start-desktop.patch b/gnu/packages/patches/torbrowser-start-desktop.patch
new file mode 100644
index 0000000000..6832ed363b
--- /dev/null
+++ b/gnu/packages/patches/torbrowser-start-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.desktop.orig    2020-07-05 18:47:40.689484877 -0300
++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser.desktop 2020-07-24 14:36:37.720579884 -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 shell.
+ # It preserves arguments and environment for the start-tor-browser script.
+@@ -28,7 +28,7 @@
+ GenericName=Web Browser
+ Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
+ Categories=Network;WebBrowser;Security;
+-Exec=sh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/start-tor-browser --detach)' dummy %k
+-X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
+-Icon=web-browser
++Exec=sh -c start-tor-browser
++X-TorBrowser-ExecShell=start-tor-browser --detach
++Icon=torbrowser
+ StartupWMClass=Tor Browser
diff --git a/gnu/packages/patches/torbrowser-start-script.patch b/gnu/packages/patches/torbrowser-start-script.patch
new file mode 100644
index 0000000000..b8c8d9a26a
--- /dev/null
+++ b/gnu/packages/patches/torbrowser-start-script.patch
@@ -0,0 +1,181 @@
+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.orig    2020-07-05 18:47:40.685485004 -0300
++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser 2020-07-23 18:13:32.426282743 -0300
+@@ -5,6 +5,14 @@
+ #
+ # 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"
++
+ complain_dialog_title="Tor Browser"
+ 
+ # First, make sure DISPLAY is set.  If it isn't, we're hosed; scream
+@@ -134,8 +142,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 +195,22 @@
+ 	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"
++   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 +225,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 +247,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 +309,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,<dir>fonts</dir>,<dir>${TBB_STORE_PATH}/fonts</dir>,"
++
+ cd "${HOME}"
+ 
+ # We pass all additional command-line arguments we get to Firefox.
+@@ -357,23 +326,23 @@
+ 
+ if [ "$show_usage" -eq 1 ]; then
+     # Display Firefox help, then our help
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default --help 2>/dev/null
++    TOR_CONTROL_PASSWD=${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=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-       -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++       -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null &
+     disown "$!"
+ elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" 2>&1 </dev/null | \
+         tee "$logfile"
+ elif [ "$show_output" -eq 1 ]; then
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" < /dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" < /dev/null
+ else
+-    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
+-        -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
++    TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ${TBB_STORE_PATH}/firefox --class "Tor Browser" \
++        -profile Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
+ fi
+ 
+ exit $?
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index 52d78cba79..d5832b19df 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -28,31 +28,71 @@
 
 (define-module (gnu packages tor)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
+  #:use-module (guix monads)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix store)
   #:use-module (guix download)
   #:use-module (guix git-download)
-  #:use-module (guix build-system gnu)
+  #:use-module (guix build-system cargo)
   #:use-module (guix build-system go)
+  #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages assembly)
+  #:use-module (gnu packages audio)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cups)
+  #:use-module (gnu packages databases)
+  #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages gl)
+  #:use-module (gnu packages glib)
+  #:use-module (gnu packages gnome)
   #:use-module (gnu packages golang)
+  #:use-module (gnu packages gtk)
+  #:use-module (gnu packages gnuzilla)
+  #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages image)
+  #:use-module (gnu packages kerberos)
+  #:use-module (gnu packages libcanberra)
   #:use-module (gnu packages libevent)
+  #:use-module (gnu packages libffi)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages llvm)
+  #:use-module (gnu packages node)
+  #:use-module (gnu packages nss)
   #:use-module (gnu packages pcre)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-crypto)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages qt)
-  #:use-module (gnu packages autotools)
+  #:use-module (gnu packages readline)
+  #:use-module (gnu packages rsync) ; for httpse
+  #:use-module (gnu packages rust)
+  #:use-module (gnu packages rust-apps)
+  #:use-module (gnu packages sqlite)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages w3m))
+  #:use-module (gnu packages version-control)
+  #:use-module (gnu packages video)
+  #:use-module (gnu packages vim) ; for xxd
+  #:use-module (gnu packages w3m)
+  #:use-module (gnu packages xdisorg)
+  #:use-module (gnu packages xiph)
+  #:use-module (gnu packages xorg)
+  #:use-module (gnu packages xml) ; for httpse
+  #:use-module (ice-9 match)
+  #:use-module ((srfi srfi-1) #:hide (zip)))
 
 (define-public tor
   (package
@@ -498,3 +538,677 @@ incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol.
 The obfs naming was chosen primarily because it was shorter, in terms of
 protocol ancestery obfs4 is much closer to ScrambleSuit than obfs2/obfs3.")
     (license license:gpl3+)))
+
+;; torbrowser and tor-browser-builder build versions are not always in sync
+(define %torbrowser-version "78.11.0esr-10.0-1")
+(define %tbb-build-version "10.0.17")
+(define %torbrowser-build "build1")
+(define %tbb-build "build1")
+(define %torbrowser-build-id "20210602000000");must be of the form YYYYMMDDhhmmss
+
+;; Fonts for Tor Browser. Avoid downloading 4Gb+ git repo on
+;; https://github.com/googlei18n/noto-fonts.git to use just a handful.
+;; Use the fonts on Tor Browser release tarball.
+(define torbrowser-fonts
+  (package
+    (name "torbrowser-fonts")
+    (version %tbb-build-version)
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://archive.torproject.org/tor-package-archive/torbrowser/"
+                           version "/tor-browser-linux64-"
+                           version "_en-US.tar.xz"))
+       (sha256
+        (base32
+         "13x38n1cvqmxjz0jf2fda8lx2k25szzmg7gvv08z3q5na7109m2m"))))
+    (build-system trivial-build-system)
+    (native-inputs
+     `(("tar" ,tar)
+       ("xz" ,xz)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+                   (use-modules (guix build utils))
+                   (let ((src (assoc-ref %build-inputs "source"))
+                         (src-dir "tor-browser_en-US/Browser/fonts")
+                         (fonts (string-append %output "/share/fonts"))
+                         (tar (assoc-ref %build-inputs "tar"))
+                         (xz (assoc-ref %build-inputs "xz")))
+                     (mkdir-p fonts)
+                     (format #t "Untaring torbrowser ball ...~%")
+                     (invoke (string-append tar "/bin/tar") "-xf" src
+                             "-C" fonts "--strip-components=3"
+                             (string-append "--use-compress-program=" xz "/bin/xz")
+                             src-dir)
+                     #t))))
+    (home-page "https://github.com/googlei18n/noto-fonts")
+    (synopsis "Tor Browser bundled fonts")
+    (description "Free fonts bundled with Tor Browser.  Includes a subset of Noto,
+Arimo, Cousine, Tinos and STIX fonts.")
+    (license license:silofl1.1)))
+
+(define tor-browser-build
+  (let ((commit (string-append "tbb-desktop-" %tbb-build-version
+                               "-" %tbb-build)))
+    (package
+      (name "tor-browser-build")
+      (version %tbb-build-version)
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://git.torproject.org/builders/tor-browser-build.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1qwgghy79wx0w1yz132yyaln4g42s72133n6gbdf07rkf5n44izc"))))
+      (build-system trivial-build-system)
+      (arguments
+       `(#:modules ((guix build utils))
+         #:builder (begin
+                     (use-modules (guix build utils))
+                     (format #t "Copying build scripts ...~%")
+                     (copy-recursively (string-append
+                                        (assoc-ref %build-inputs "source")
+                                        "/projects/tor-browser")
+                                       %output
+                                       #:log (%make-void-port "w")))))
+      (home-page "https://www.torproject.org")
+      (synopsis "Tor Browser build scripts")
+      (description "Tor Browser runtime scripts.")
+      (license (license:non-copyleft "file://LICENSE")))))
+
+(define tor-launcher
+  (package
+    (name "tor-launcher")
+    (version "0.2.28")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://archive.torproject.org/tor-package-archive/torbrowser/"
+                           %tbb-build-version "/src-" name "-"
+                           version ".tar.xz"))
+       (sha256
+        (base32
+         "0mbd1q46d8nqisn6n79sp6m29332ymb2pf13xzgq1ml7rfcy6jjy"))))
+    (build-system trivial-build-system)
+    (native-inputs
+     `(("tar" ,tar)
+       ("xz" ,xz)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+                   (use-modules (guix build utils))
+		   (format #t "Extracting source ...~%")
+                   (let ((src (assoc-ref %build-inputs "source"))
+                         (tar (assoc-ref %build-inputs "tar"))
+                         (xz (assoc-ref %build-inputs "xz")))
+                     (mkdir-p %output)
+                     (format #t "Extracting source ...~%")
+                     (invoke (string-append tar "/bin/tar") "-xf" src
+                             "-C" %output "--strip-components=1"
+                             (string-append "--use-compress-program=" xz "/bin/xz"))))))
+    (home-page "https://www.torproject.org")
+    (synopsis "Tor Browser built-in controler extension")
+    (description "Browser extension that starts the tor process (which
+connects the browser and other applications to the Tor Network), and
+which helps people configure and use @code{tor}. The first window that
+you see when you start Tor Browser is displayed by this extension.")
+    (license (license:non-copyleft "file://src/LICENSE"))))
+
+(define https-everywhere-lib-wasm
+  (let ((commit "45b1622f1240659aca4762fa336aad1322d6d50f"))
+    (package
+      (name "https-everywhere-lib-wasm")
+      (version "2021.4.15")
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/EFForg/https-everywhere-lib-wasm")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1lq62rzypdzmnnzvfns3ccvv1g7p7g9s8jx788zzigr3gnmkpffx"))))
+      (build-system trivial-build-system)
+      (arguments
+       `(#:modules ((guix build utils))
+         #:builder (begin
+                     (use-modules (guix build utils))
+                     (format #t "Copying source ...~%")
+                     (copy-recursively (assoc-ref %build-inputs "source")
+                                       %output
+                                       #:log (%make-void-port "w")))))
+      (home-page "https://github.com/EFForg/https-everywhere-lib-wasm")
+      (synopsis "Browser extension for protection against known attacks")
+      (description "Browser extension that protects users from a range of
+known attacks on web browsing activity such as Cross-site scripting, clickjack and
+makes possible for the users to block or choose on a per site basis which remote
+javascript to run while browsing the web.")
+      (license license:gpl2+))))
+
+;; Both https-everywhere and noscript are rellying on some precompiled code for now.
+;; Also read on the work on chromium extensions on gnu/build/chromium-extensions.scm
+;; to see if can be adapted.
+(define-public https-everywhere
+  (package
+    (name "https-everywhere")
+    (version "2021.4.15")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/EFForg/" name "/archive/"
+                           version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "1bknx8l8gxmpwb13pvn6pdbavknci8q0jhygdaz50ilc1xld89i3"))))
+    (build-system trivial-build-system)
+    (native-inputs
+     `(("bash" ,bash)
+       ("coreutils" ,coreutils)
+       ("findutils" ,findutils)
+       ("git" ,git)
+       ("grep" ,grep)
+       ("gzip" ,gzip)
+       ("https-everywhere-lib-wasm"
+        ,https-everywhere-lib-wasm)
+       ("libxml2" ,libxml2)
+       ("libxslt" ,libxslt)
+       ("openssl" ,openssl)
+       ("python" ,python)
+       ("rsync" ,rsync)
+       ("sed" ,sed)
+       ("tar" ,tar)
+       ("util-linux" ,util-linux) ; for getopt
+       ("xxd" ,xxd)
+       ("which" ,which)
+       ("zip" ,zip)))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+                   (use-modules (guix build utils))
+                   (let ((src (assoc-ref %build-inputs "source"))
+                         (httpse-libwasm (assoc-ref %build-inputs
+                                                    "https-everywhere-lib-wasm"))
+                         (bash (assoc-ref %build-inputs "bash"))
+                         (coreutils (assoc-ref %build-inputs "coreutils"))
+                         (python (assoc-ref %build-inputs "python"))
+                         (openssl (assoc-ref %build-inputs "openssl"))
+                         (git (assoc-ref %build-inputs "git"))
+                         (grep (assoc-ref %build-inputs "grep"))
+                         (findutils (assoc-ref %build-inputs "findutils"))
+                         (sed (assoc-ref %build-inputs "sed"))
+                         (which (assoc-ref %build-inputs "which"))
+                         (rsync (assoc-ref %build-inputs "rsync"))
+                         (libxml2 (assoc-ref %build-inputs "libxml2"))
+                         (libxslt (assoc-ref %build-inputs "libxslt"))
+                         (util-linux (assoc-ref %build-inputs "util-linux"))
+                         (xxd (assoc-ref %build-inputs "xxd"))
+                         (zip (assoc-ref %build-inputs "zip"))
+                         (tar (assoc-ref %build-inputs "tar"))
+                         (gzip (assoc-ref %build-inputs "gzip")))
+                     (setenv "SHELL" (string-append bash "/bin/bash"))
+                     (set-path-environment-variable
+                      "PATH" '("bin")
+                      (list bash sed findutils which git python tar openssl rsync
+                            libxml2 libxslt util-linux grep xxd gzip zip coreutils))
+                     (set-path-environment-variable
+                      "LIBRARY_PATH" '("lib")
+                      (list bash sed findutils which git python tar openssl rsync
+                            libxml2 libxslt util-linux grep xxd gzip zip coreutils))
+                     (format #t "Untaring source tarball ...~%")
+                     (invoke "tar" "-xf" src "--strip-components=1")
+                     ;; Python3.6 is hardcoded on these scripts. Using v3.8 appears to
+                     ;; be harmless.
+                     (substitute* '("install-dev-dependencies.sh"
+                                    "make.sh"
+                                    "hooks/precommit"
+                                    "test/firefox.sh"
+                                    "test/manual.sh"
+                                    "test/rules/src/https_everywhere_checker/check_rules.py"
+                                    "test/script.py"
+                                    "test/validations.sh"
+                                    "test/validations/filename/run.py"
+                                    "test/validations/relaxng/run.py"
+                                    "test/validations/securecookie/run.py"
+                                    "test/validations/special/run.py"
+                                    "utils/create_zip.py"
+                                    "utils/chromium-translations.py"
+                                    "utils/create-platform-certs/split_combined_cert_file.py"
+                                    ;; "utils/mk-client-whitelist/dbconnect.py"
+                                    ;; "utils/mk-client-whitelist/run.py"
+                                    "utils/merge-rulesets.py"
+                                    "utils/setversion.py"
+                                    "utils/zipfile_deterministic.py")
+                       (("python3.6") "python3"))
+                     (make-file-writable "lib-wasm")
+                     (copy-recursively httpse-libwasm
+                                       "lib-wasm"
+                                       #:log (%make-void-port "w"))
+                     ;; Remove precompiled binaries from source. This breaks
+                     ;; http-everywhere at runtime, but building is successful.
+                     ;; For now building takes the precompiled version included with sources.
+		     ;; Tor Browser upstream does the same. In case you want to remove the
+		     ;; precompiled version, use the routine below. It successfully builds
+		     ;; but at run time rules seem to be broken.
+                     ;(with-directory-excursion "lib-wasm/pkg"
+                     ;  (for-each (lambda (file)
+                     ;              (if (file-exists? file)
+                     ;                  (delete-file file)
+                     ;                  (display (string-append
+                     ;                            "Warning: file " file
+                     ;                            " not found! Skipping...\n"))))
+                     ;            '("https_everywhere_lib_wasm.js"
+                     ;              "https_everywhere_lib_wasm_bg.wasm")))
+                     (for-each patch-shebang
+                               (find-files "."
+                                           (lambda (file stat)
+                                             ;; Filter out symlinks.
+                                             (eq? 'regular (stat:type stat)))
+                                           #:stat lstat))
+                     ;; Failing to generate the xpi, but copy-dir appears to be enough.
+                     ;; Failing on missing 'wasm'? Not generating rulesets. Once lib-wasm
+		     ;; gets cross-compiled, try to move the '.xpi' extension instead.
+                     (invoke "./make.sh")
+                     (copy-recursively "pkg/xpi-eff" %output
+                                       #:log (%make-void-port "w"))
+                     #t))))
+    (home-page "https://www.eff.org/https-everywhere")
+    (synopsis "Browser extension for automatic HTTPS usage")
+    (description "Browser extension that automatically makes the browser to use
+HTTPS instead of plain HTTP when the remote destination makes it available to users.")
+    (license license:gpl2+)))
+
+(define noscript
+  (package
+    (name "noscript")
+    (version "11.2.8")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://secure.informaction.com/download/releases/"
+                           name "-" version ".xpi"))
+       (sha256
+        (base32
+         "0rrlhlzljlmgns7j49c43ilb8wij2zcysrbpap1xxsfbkbczji27"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder (begin
+		   ;; Fake build for now. Upstream Tor Browser does not build it as well.
+                   (format #t "Copying source ...~%")
+                   (copy-file (assoc-ref %build-inputs "source")
+                              %output))))
+    (home-page "https://noscript.net")
+    (synopsis "Browser extension for protection against known attacks")
+    (description "Browser extension that protects users from a range of
+known attacks on web browsing activity such as Cross-site scripting, clickjack and
+makes possible for the users to block or choose on a per site basis which remote
+javascript to run while browsing the web.")
+    (license license:gpl2+)))
+
+;; (Un)fortunatly Tor Browser has it's own reproducible build system - RBM - which
+;; automates the build process for them and compiles Tor Browser from a range of
+;; repositories and produces a range of tarballs for different architectures and
+;; locales. So we need to cherry-pick what is needed for guix and produce our own
+;; tarball. See https://gitweb.torproject.org/builders/tor-browser-build.git/projects/\
+;; {tor-browser,firefox}/{build,config} for the rationale applied here. See also
+;; the Hacking on Tor Browser document for a high level introduction at
+;; https://trac.torproject.org/projects/tor/wiki/doc/Tor Browser/Hacking).
+;;
+;; TODO: Import langpacks from https://archive.torproject.org/tor-package-archive/\
+;; torbrowser/'version'/langpacks-tor-browser-linux64-version.tar.xz
+(define-public torbrowser-unbundle
+  (let ((commit (string-append "tor-browser-" %torbrowser-version
+                               "-" %torbrowser-build)))
+    (package
+      (inherit icecat)
+      (name "torbrowser-unbundle")
+      (version %tbb-build-version)
+      (source
+       (origin
+	 (method url-fetch)
+	 (uri (string-append "https://archive.torproject.org/tor-package-archive/torbrowser/"
+			     %tbb-build-version
+			     "/src-firefox-tor-browser-"
+			     %torbrowser-version "-" %torbrowser-build
+			     ".tar.xz"))
+	 (sha256
+          (base32
+           "1jnb7v9zn7y2fk7gqvq1ijlwl16i7wf83y1xn2djqcp1j42n1yvq"))))
+      (build-system gnu-build-system)
+      (inputs
+       `(("obfs4" ,obfs4)
+	 ("tor" ,tor-client)
+	 ,@(package-inputs icecat)))
+      (native-inputs
+       `(("https-everywhere" ,https-everywhere)
+	 ("noscript" ,noscript)
+	 ("tor-browser-build" ,tor-browser-build)
+	 ("tor-launcher" ,tor-launcher)
+	 ("torbrowser-fonts" ,torbrowser-fonts)
+	 ("torbrowser-start-script.patch"
+          ,(search-patch "torbrowser-start-script.patch"))
+	 ("torbrowser-start-desktop.patch"
+          ,(search-patch "torbrowser-start-desktop.patch"))
+	 ,@(package-native-inputs icecat)))
+      (properties '())
+      (arguments
+       (substitute-keyword-arguments (package-arguments icecat)
+	 ((#:phases phases)
+          `(modify-phases ,phases
+             ;; On mach build system this is done on configure.
+             (delete 'bootstrap)
+             ;; Doesn't seem to be needed for TorBrowser
+             (delete 'fix-ffmpeg-runtime-linker)
+             ;; Tried to make use of these using let, but inheritance appears to block it.
+             (delete 'install-icons)
+             (delete 'install-desktop-entry)
+             (add-after 'unpack 'make-bundle
+               (lambda* (#:key inputs native-inputs #:allow-other-keys)
+		 (let ((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 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 "browser/app/profile/000-tor-browser.js")
+		   (make-file-writable (string-append tbb-scripts-dir
+						      "/RelativeLink/start-tor-browser"))
+                   (make-file-writable (string-append tbb-scripts-dir
+						      "/RelativeLink/start-tor-browser.desktop")))
+		 #t))
+             (replace 'apply-guix-specific-patches
+               (lambda* (#:key inputs native-inputs #:allow-other-keys)
+		 (let ((patch (string-append (assoc-ref (or native-inputs inputs)
+							"patch")
+                                             "/bin/patch")))
+                   (for-each (match-lambda
+                               ((label . file)
+				;; Only difference to icecat is browser name.
+				(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-bridge-preferences
+               (lambda* (#:key inputs native-inputs #:allow-other-keys)
+		 (begin
+                   (let ((tbb-prefs (open-file
+                                     "browser/app/profile/000-tor-browser.js" "a"))
+			 (bridge-prefs
+                          (open-input-file
+                           "tbb-scripts/Bundle-Data/PTConfigs/bridge_prefs.js")))
+                     (display (get-string-all bridge-prefs) tbb-prefs)
+                     (close-output-port tbb-prefs)))
+		 #t))
+             (replace 'configure
+               (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(bash (which "bash"))
+			(flags `(,(string-append "--prefix=" 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 "python-2")
+                                                   "/bin/python"))
+                   (setenv "CC" "gcc")  ; needed when Stylo is enabled
+                   (setenv "MOZ_BUILD_DATE" ,%torbrowser-build-id) ; avoid timestamp.
+                   (setenv "LDFLAGS" (string-append "-Wl,-rpath="
+                                                    (assoc-ref outputs "out")
+                                                    "/lib"))
+                   (substitute* ".mozconfig"
+                     ;; Arch independent builddir.
+                     (("(mk_add_options MOZ_OBJDIR=@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=dev-build")
+		      ;; If we decide to rebrand this browser, here is the place to do it.
+                      (string-append
+                       "ac_add_options --with-tor-browser-version=org.gnu\n"
+                       "ac_add_options --with-unsigned-addon-scopes=app,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"
+                       "ac_add_options --enable-system-pixman\n"
+                       "ac_add_options --enable-system-ffi\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-nspr\n" ;; broken for now, see icecat.
+                       ;;"ac_add_options --with-system-nss\n"
+                       "ac_add_options --with-system-zlib\n"
+                       ;; Without these clang is not found.
+                       "ac_add_options --with-clang-path="
+                       (assoc-ref %build-inputs "clang") "/bin/clang\n"
+                       "ac_add_options --with-libclang-path="
+                       (assoc-ref %build-inputs "clang") "/lib\n")))
+                   (substitute* "browser/app/profile/000-tor-browser.js"
+                     ;; Tor Browser updates are disabled on mozconfig, but let'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.snowflake.1\".*")
+                      "\n"))
+                   (substitute*
+                       "browser/extensions/tor-launcher/src/defaults/preferences/torlauncher-prefs.js"
+                     ;; Not multilingual. See tor-browser/build:141. Currently disabled on
+                     ;; tor-launcher, but let's make sure while missing langpacks.
+                     (("(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))
+             (add-after 'configure 'install-desk-icons
+               (lambda* (#:key outputs #:allow-other-keys)
+		 (let ((out (assoc-ref outputs "out")))
+                   (with-directory-excursion "browser/branding/official"
+                     (for-each
+                      (lambda (file)
+			(let* ((size (string-filter char-numeric? file))
+                               (icons (string-append out "/share/icons/hicolor/"
+                                                     size "x" size "/apps")))
+                          (mkdir-p icons)
+                          (copy-file file (string-append icons "/torbrowser.png"))))
+                      '("default16.png" "default22.png" "default24.png"
+			"default32.png" "default48.png" "default64.png"
+			"default128.png" "default256.png" "default512.png"))
+                     #t))))
+             (replace 'build
+               (lambda _
+		 (make-file-writable "Cargo.lock")
+		 (invoke "./mach" "build")
+                 #t))
+             (replace 'neutralise-store-references
+               (lambda _
+		 ;; difference from icecat "objdir" preffix. We could use find-files there.
+		 (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)
+                                   "<!-- Guix: not a runtime dependency -->"
+                                   (string-drop hash 8))))
+		 #t))
+             ;; Tor Browser just do a stage-package here and copy files to its 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"))
+			(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" "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") #o555)
+                   (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-fonts
+               (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(lib (string-append out "/lib/"))
+			(fonts  (string-append (or (assoc-ref native-inputs
+                                                              "torbrowser-fonts")
+                                                   (assoc-ref inputs
+                                                              "torbrowser-fonts"))
+                                               "/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-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(lib (string-append out "/lib"))
+			(ext (string-append lib "/browser/extensions"))
+			(torb-ext (string-append lib
+						 "/chrome/torbutton/content/extensions"))
+			(httpse-id "https-everywhere")
+			(noscript-id "{73a6fe31-595d-460b-a920-fcc0f8843232}")
+			(httpse (assoc-ref inputs "https-everywhere"))
+			(noscript (assoc-ref inputs "noscript")))
+                   (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. This step is
+		   ;; changing some timestamps and making everything non-deterministic.
+		   ;; To check insert 'resource://torbutton/content/extensions/https-everywhere/'
+		   ;; on the browser address field. Check 'reset-gzip-timestamps' to see what
+		   ;; can be done.
+		   ;; https://gitweb.torproject.org/builders/tor-browser-build.git/tree/projects/\
+		   ;; tor-browser/build?h=tbb-desktop-10.0.17-build1&id=16fa8c3bf91a9c1a827a7d23be344de599cd10bb#n77g
+                   (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-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(tordir (string-append out "/lib/TorBrowser/Tor"))
+			(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-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(lib (string-append out "/lib"))
+			(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 "/" file)
+                                                   #:log (%make-void-port "w")))
+                               '("Browser" "fontconfig" "Tor")))
+                   (copy-file (string-append ptconf "/linux/torrc-defaults-appendix")
+                              (string-append data "/Tor/torrc-defaults-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
+             (replace 'wrap-program
+               (lambda* (#:key inputs outputs #:allow-other-keys)
+		 (let* ((out (assoc-ref outputs "out"))
+			(lib (string-append out "/lib"))
+			(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")))
+                   ;; Only difference to icecat is browser name.
+                   (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 the only
+recommended way to anonymously browse the web that is supported by the project.
+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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] Wow!
  2021-05-28  1:45           ` André Batista
@ 2021-06-03 20:43             ` Ludovic Courtès
  0 siblings, 0 replies; 56+ messages in thread
From: Ludovic Courtès @ 2021-06-03 20:43 UTC (permalink / raw)
  To: André Batista; +Cc: Raghav Gururajan, Xinglu Chen, 42380, Leo Famulari

Hi,

André Batista <nandre@riseup.net> skribis:

> Apart from noscript which Tor Browser itself does not build from source
> and https-everywhere which at the time I thought I'd be able to build
> from source but I got stuck on rust dependency nightmare and had to
> delay. Unfortunately, this issue still remains to be solved.

OK, not too bad.

>> > My understanding is that the Tor people discourage anyone else from
>> > distributing builds of the Tor browser.
>
> That's also my understanding, however I do think that building from
> source is: 1. the very core of software freedom, despite the relevance
> other concerns such as diminishing anonymity set; 2. one of the main
> strenghts and what Guix strives for.

+1

> In the mean time, I'll take this as an invitation to send a new patch
> version with the latest Tor Browser stable. I've made some minor
> improvements such as using tarballs from archive.torproject.org instead
> of {git|dist}.torproject.org.
>
> Since they are planning a new stable release in the next few days, I'll
> take the time to work on a reproducibility issue that have arised with
> the new zip routine to package extensions inside omni.ja which affected
> the timestamps, at least the way I did it.

Exciting, thank you!

Ludo’.




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v5 9/9] gnu: Add torbrowser-unbundle.
  2021-06-03  4:10                       ` [bug#42380] [PATCH v5 " André Batista
@ 2021-06-03 21:07                         ` Maxime Devos
  2021-07-10  3:10                           ` André Batista
  2021-06-03 21:07                         ` Maxime Devos
  1 sibling, 1 reply; 56+ messages in thread
From: Maxime Devos @ 2021-06-03 21:07 UTC (permalink / raw)
  To: André Batista, 42380

[-- Attachment #1: Type: text/plain, Size: 11721 bytes --]

Some comments, maybe the have already been addressed previously:

> +++ b/gnu/packages/patches/torbrowser-start-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.desktop.orig    2020-07-05 18:47:40.689484877 -0300
> ++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser.desktop 2020-07-24 14:36:37.720579884 -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 shell.
> + # It preserves arguments and environment for the start-tor-browser script.
> +@@ -28,7 +28,7 @@
> + GenericName=Web Browser
> + Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
> + Categories=Network;WebBrowser;Security;
> +-Exec=sh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/start-tor-browser --detach)' dummy %k
> +-X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
> +-Icon=web-browser
> ++Exec=sh -c start-tor-browser
> ++X-TorBrowser-ExecShell=start-tor-browser --detach
> ++Icon=torbrowser

What's the reason for switching the icon from web-browser to torbrowser?
Also, the guixy way would be to simply replace "$(dirname "$*")/STUFF"
by /gnu/store/[...]/MORE-STUF/STUFF.

Otherwise, you're assuming "sh" is in the profile. It would also
be possible to replace "sh" with (string-append (assoc-ref inputs "bash") "/bin/sh")
I guess.

> + StartupWMClass=Tor Browser
> diff --git a/gnu/packages/patches/torbrowser-start-script.patch b/gnu/packages/patches/torbrowser-start-script.patch
> new file mode 100644
> index 0000000000..b8c8d9a26a
> --- /dev/null
> +++ b/gnu/packages/patches/torbrowser-start-script.patch
> @@ -0,0 +1,181 @@
> +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.orig    2020-07-05 18:47:40.685485004 -0300
> ++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser 2020-07-23 18:13:32.426282743 -0300
> +@@ -5,6 +5,14 @@
> + #
> + # 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"
> ++
> + complain_dialog_title="Tor Browser"
> + 
> + # First, make sure DISPLAY is set.  If it isn't, we're hosed; scream
> +@@ -134,8 +142,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"

Why rename tor-browser.log to torbrowser.log?

> + [...]
> ++# 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"
> ++   echo "ClientTransportPlugin meek_lite,obfs2,obfs3,obfs4,scramblesuit exec ${TBB_STORE_PATH}/TorBrowser/Tor/PluggableTransports/obfs4proxy"\
> ++     >> "${TORRC}"
> ++   cd "${TBB_HOME}"
> + fi

"mkdir" and "cp" are from coreutils, which are not guaranteed to be in
the profile. I'd suggest:

(1) (preferred) use substitute* in a build phase to replace
    'mkdir' and 'cp' & co with the absolute store path
(2) or add coreutils to propagated-inputs

Likewise for sed. 

> [...]
> 
> + 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

Is this required on Guix and would it work well on Guix? Copying .desktop files around
seems counter to ‘Guix suppots transactional upgrades and roll-backs, [...]. [...]
reproducible operating systems’ and not very functional. Shouldn't
"guix install torbrowser-unbundle" be sufficient?

noscript seems an useful extension for IceCat as well.
Maybe move it to gnuzilla.scm? Maybe move https-everywhere
there as well? (Separate issue: https-everywhere seems to
be bundled in IceCat ...)

> +(define https-everywhere-lib-wasm
> +  (let ((commit "45b1622f1240659aca4762fa336aad1322d6d50f"))
> +    (package
> +      (name "https-everywhere-lib-wasm")
> +      (version "2021.4.15")
> +      (source
> +       (origin
> +         (method git-fetch)
> +         (uri (git-reference
> +               (url "https://github.com/EFForg/https-everywhere-lib-wasm")
> +               (commit commit)))
> +         (file-name (git-file-name name version))
> +         (sha256
> +          (base32
> +           "1lq62rzypdzmnnzvfns3ccvv1g7p7g9s8jx788zzigr3gnmkpffx"))))
> +      (build-system trivial-build-system)
> +      (arguments
> +       `(#:modules ((guix build utils))
> +         #:builder (begin
> +                     (use-modules (guix build utils))
> +                     (format #t "Copying source ...~%")
> +                     (copy-recursively (assoc-ref %build-inputs "source")
> +                                       %output
> +                                       #:log (%make-void-port "w")))))

Why are you copying the source code to somewhere else?
This doesn't seem to accomplish anything. I would suggest
something like:

;; Source code of ‘HTTPS Everywhere WASM Library’,
;; licensed as license:lgpl2.1+, used in 'https-everywhere'
;; as an input.
(define https-everywhere-lib-wasm/source-code
  (origin (method git-fetch) [...]))

Note that you can use 'origin' objects in 'inputs' and 'native-inputs'.


> +      (home-page "https://github.com/EFForg/https-everywhere-lib-wasm")
> +      (synopsis "Browser extension for protection against known attacks")
> +      (description "Browser extension that protects users from a range of
> +known attacks on web browsing activity such as Cross-site scripting, clickjack and
> +makes possible for the users to block or choose on a per site basis which remote
> +javascript to run while browsing the web.")
> +      (license license:gpl2+))))

The license file seems to tell something different: LGPL2.1+ instead of GPL2+:
https://github.com/EFForg/https-everywhere-lib-wasm/blob/master/LICENSE


> [...]
> +      (native-inputs
> +       `(("https-everywhere" ,https-everywhere)
> +	   ("noscript" ,noscript)

noscript and https-everywhere seem more like 'inputs' than
'native-inputs' to me, but IIUC they are source-code only
and not compiled, so it doesn't really matter here I guess.

> [...]
> +             (add-after 'unpack 'make-bundle
> +               (lambda* (#:key inputs native-inputs #:allow-other-keys)
> +		 (let ((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 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 "browser/app/profile/000-tor-browser.js")
> +		   (make-file-writable (string-append tbb-scripts-dir
> +						      "/RelativeLink/start-tor-browser"))
> +                   (make-file-writable (string-append tbb-scripts-dir
> +						      "/RelativeLink/start-tor-browser.desktop")))
> +		 #t))

Returning #t at the end of a phase is not required anymore.
The warning will disappear when core-updates is merged.

> +             (replace 'configure
> +               (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
> +		 (let* ((out (assoc-ref outputs "out"))
> +			(bash (which "bash"))
> +			(flags `(,(string-append "--prefix=" out)
> +				 ,@configure-flags)))
> +                   (setenv "SHELL" bash)
> +                   (setenv "AUTOCONF" (string-append
> +                                       (assoc-ref %build-inputs "autoconf")
> +                                       "/bin/autoconf"))

In build phases, use 'inputs' or 'native-inputs' instead of %build-inputs.
It's more explicit, maybe there are other reasons as well. (Here it should
be native-inputs I guess).


> +                   (setenv "CONFIG_SHELL" bash)
> +                   (setenv "PYTHON" (string-append (assoc-ref inputs "python-2")
> +                                                   "/bin/python"))

This most likely should be (assoc-ref (or native-inputs inputs) "python-2")
instead of (assoc-ref inputs "python-2").

> +                   (setenv "CC" "gcc")  ; needed when Stylo is enabled
This most likely should be ,(cc-for-target) instead of "gcc".

(The native-inputs/inputs and "gcc" / (cc-for-target) distinction is important
when cross-compiling (though not all dependencies are cross-compilable currently,
so it's a bit moot for now.))

> +             (add-after 'install-extensions 'link-binaries
> +               (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
You're not using 'native-inputs' in this build phase so you can remove it
from the arguments list.

> +              [...]
> +             (add-after 'link-binaries 'copy-bundle-data
> +               (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)

Likewise.

> +      (description
> +       "Tor Browser is the Tor Project version of Firefox browser.  It is the only
> +recommended way to anonymously browse the web that is supported by the project.
> +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.")

This seems unnecessarily scary. All packages in guix are ‘at your own risk’
and every new package is ‘in testing’ for a while, whatever that means.
What about

 "Warning: this is not the official built of Tor Browser from upstream.
As such, the Guix version of Tor Browser may have small differences
that might allow a malicious actor to identify you as a Guix user."

?

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v5 9/9] gnu: Add torbrowser-unbundle.
  2021-06-03  4:10                       ` [bug#42380] [PATCH v5 " André Batista
  2021-06-03 21:07                         ` Maxime Devos
@ 2021-06-03 21:07                         ` Maxime Devos
  1 sibling, 0 replies; 56+ messages in thread
From: Maxime Devos @ 2021-06-03 21:07 UTC (permalink / raw)
  To: André Batista, 42380

[-- Attachment #1: Type: text/plain, Size: 11721 bytes --]

Some comments, maybe the have already been addressed previously:

> +++ b/gnu/packages/patches/torbrowser-start-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.desktop.orig    2020-07-05 18:47:40.689484877 -0300
> ++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser.desktop 2020-07-24 14:36:37.720579884 -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 shell.
> + # It preserves arguments and environment for the start-tor-browser script.
> +@@ -28,7 +28,7 @@
> + GenericName=Web Browser
> + Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
> + Categories=Network;WebBrowser;Security;
> +-Exec=sh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/start-tor-browser --detach)' dummy %k
> +-X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
> +-Icon=web-browser
> ++Exec=sh -c start-tor-browser
> ++X-TorBrowser-ExecShell=start-tor-browser --detach
> ++Icon=torbrowser

What's the reason for switching the icon from web-browser to torbrowser?
Also, the guixy way would be to simply replace "$(dirname "$*")/STUFF"
by /gnu/store/[...]/MORE-STUF/STUFF.

Otherwise, you're assuming "sh" is in the profile. It would also
be possible to replace "sh" with (string-append (assoc-ref inputs "bash") "/bin/sh")
I guess.

> + StartupWMClass=Tor Browser
> diff --git a/gnu/packages/patches/torbrowser-start-script.patch b/gnu/packages/patches/torbrowser-start-script.patch
> new file mode 100644
> index 0000000000..b8c8d9a26a
> --- /dev/null
> +++ b/gnu/packages/patches/torbrowser-start-script.patch
> @@ -0,0 +1,181 @@
> +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.orig    2020-07-05 18:47:40.685485004 -0300
> ++++ torbrowser-68.10.0esr-9.5-1/tbb-scripts/RelativeLink/start-tor-browser 2020-07-23 18:13:32.426282743 -0300
> +@@ -5,6 +5,14 @@
> + #
> + # 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"
> ++
> + complain_dialog_title="Tor Browser"
> + 
> + # First, make sure DISPLAY is set.  If it isn't, we're hosed; scream
> +@@ -134,8 +142,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"

Why rename tor-browser.log to torbrowser.log?

> + [...]
> ++# 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"
> ++   echo "ClientTransportPlugin meek_lite,obfs2,obfs3,obfs4,scramblesuit exec ${TBB_STORE_PATH}/TorBrowser/Tor/PluggableTransports/obfs4proxy"\
> ++     >> "${TORRC}"
> ++   cd "${TBB_HOME}"
> + fi

"mkdir" and "cp" are from coreutils, which are not guaranteed to be in
the profile. I'd suggest:

(1) (preferred) use substitute* in a build phase to replace
    'mkdir' and 'cp' & co with the absolute store path
(2) or add coreutils to propagated-inputs

Likewise for sed. 

> [...]
> 
> + 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

Is this required on Guix and would it work well on Guix? Copying .desktop files around
seems counter to ‘Guix suppots transactional upgrades and roll-backs, [...]. [...]
reproducible operating systems’ and not very functional. Shouldn't
"guix install torbrowser-unbundle" be sufficient?

noscript seems an useful extension for IceCat as well.
Maybe move it to gnuzilla.scm? Maybe move https-everywhere
there as well? (Separate issue: https-everywhere seems to
be bundled in IceCat ...)

> +(define https-everywhere-lib-wasm
> +  (let ((commit "45b1622f1240659aca4762fa336aad1322d6d50f"))
> +    (package
> +      (name "https-everywhere-lib-wasm")
> +      (version "2021.4.15")
> +      (source
> +       (origin
> +         (method git-fetch)
> +         (uri (git-reference
> +               (url "https://github.com/EFForg/https-everywhere-lib-wasm")
> +               (commit commit)))
> +         (file-name (git-file-name name version))
> +         (sha256
> +          (base32
> +           "1lq62rzypdzmnnzvfns3ccvv1g7p7g9s8jx788zzigr3gnmkpffx"))))
> +      (build-system trivial-build-system)
> +      (arguments
> +       `(#:modules ((guix build utils))
> +         #:builder (begin
> +                     (use-modules (guix build utils))
> +                     (format #t "Copying source ...~%")
> +                     (copy-recursively (assoc-ref %build-inputs "source")
> +                                       %output
> +                                       #:log (%make-void-port "w")))))

Why are you copying the source code to somewhere else?
This doesn't seem to accomplish anything. I would suggest
something like:

;; Source code of ‘HTTPS Everywhere WASM Library’,
;; licensed as license:lgpl2.1+, used in 'https-everywhere'
;; as an input.
(define https-everywhere-lib-wasm/source-code
  (origin (method git-fetch) [...]))

Note that you can use 'origin' objects in 'inputs' and 'native-inputs'.


> +      (home-page "https://github.com/EFForg/https-everywhere-lib-wasm")
> +      (synopsis "Browser extension for protection against known attacks")
> +      (description "Browser extension that protects users from a range of
> +known attacks on web browsing activity such as Cross-site scripting, clickjack and
> +makes possible for the users to block or choose on a per site basis which remote
> +javascript to run while browsing the web.")
> +      (license license:gpl2+))))

The license file seems to tell something different: LGPL2.1+ instead of GPL2+:
https://github.com/EFForg/https-everywhere-lib-wasm/blob/master/LICENSE


> [...]
> +      (native-inputs
> +       `(("https-everywhere" ,https-everywhere)
> +	   ("noscript" ,noscript)

noscript and https-everywhere seem more like 'inputs' than
'native-inputs' to me, but IIUC they are source-code only
and not compiled, so it doesn't really matter here I guess.

> [...]
> +             (add-after 'unpack 'make-bundle
> +               (lambda* (#:key inputs native-inputs #:allow-other-keys)
> +		 (let ((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 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 "browser/app/profile/000-tor-browser.js")
> +		   (make-file-writable (string-append tbb-scripts-dir
> +						      "/RelativeLink/start-tor-browser"))
> +                   (make-file-writable (string-append tbb-scripts-dir
> +						      "/RelativeLink/start-tor-browser.desktop")))
> +		 #t))

Returning #t at the end of a phase is not required anymore.
The warning will disappear when core-updates is merged.

> +             (replace 'configure
> +               (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
> +		 (let* ((out (assoc-ref outputs "out"))
> +			(bash (which "bash"))
> +			(flags `(,(string-append "--prefix=" out)
> +				 ,@configure-flags)))
> +                   (setenv "SHELL" bash)
> +                   (setenv "AUTOCONF" (string-append
> +                                       (assoc-ref %build-inputs "autoconf")
> +                                       "/bin/autoconf"))

In build phases, use 'inputs' or 'native-inputs' instead of %build-inputs.
It's more explicit, maybe there are other reasons as well. (Here it should
be native-inputs I guess).


> +                   (setenv "CONFIG_SHELL" bash)
> +                   (setenv "PYTHON" (string-append (assoc-ref inputs "python-2")
> +                                                   "/bin/python"))

This most likely should be (assoc-ref (or native-inputs inputs) "python-2")
instead of (assoc-ref inputs "python-2").

> +                   (setenv "CC" "gcc")  ; needed when Stylo is enabled
This most likely should be ,(cc-for-target) instead of "gcc".

(The native-inputs/inputs and "gcc" / (cc-for-target) distinction is important
when cross-compiling (though not all dependencies are cross-compilable currently,
so it's a bit moot for now.))

> +             (add-after 'install-extensions 'link-binaries
> +               (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
You're not using 'native-inputs' in this build phase so you can remove it
from the arguments list.

> +              [...]
> +             (add-after 'link-binaries 'copy-bundle-data
> +               (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)

Likewise.

> +      (description
> +       "Tor Browser is the Tor Project version of Firefox browser.  It is the only
> +recommended way to anonymously browse the web that is supported by the project.
> +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.")

This seems unnecessarily scary. All packages in guix are ‘at your own risk’
and every new package is ‘in testing’ for a while, whatever that means.
What about

 "Warning: this is not the official built of Tor Browser from upstream.
As such, the Guix version of Tor Browser may have small differences
that might allow a malicious actor to identify you as a Guix user."

?

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v5 9/9] gnu: Add torbrowser-unbundle.
  2021-06-03 21:07                         ` Maxime Devos
@ 2021-07-10  3:10                           ` André Batista
  0 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2021-07-10  3:10 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 42380

[-- Attachment #1: Type: text/plain, Size: 9776 bytes --]

Hi Maxim,

I don't know why but I've overlooked your message when it first arrived,
I'm sorry and thanks for your help.

qui 03 jun 2021 às 23:07:23 (1622772443), maximedevos@telenet.be enviou:
> > + GenericName=Web Browser
> > + Comment=Tor Browser is +1 for privacy and −1 for mass surveillance
> > + Categories=Network;WebBrowser;Security;
> > +-Exec=sh -c '"$(dirname "$*")"/Browser/start-tor-browser --detach || ([ ! -x "$(dirname "$*")"/Browser/start-tor-browser ] && "$(dirname "$*")"/start-tor-browser --detach)' dummy %k
> > +-X-TorBrowser-ExecShell=./Browser/start-tor-browser --detach
> > +-Icon=web-browser
> > ++Exec=sh -c start-tor-browser
> > ++X-TorBrowser-ExecShell=start-tor-browser --detach
> > ++Icon=torbrowser
> 
> What's the reason for switching the icon from web-browser to torbrowser?

If I'm not mistaken, this was done to get the newer icon set from sources.
Without this change it was getting the older icons which were still
available. I'll check this again.

> Also, the guixy way would be to simply replace "$(dirname "$*")/STUFF"
> by /gnu/store/[...]/MORE-STUF/STUFF.
> Otherwise, you're assuming "sh" is in the profile. It would also
> be possible to replace "sh" with (string-append (assoc-ref inputs "bash") "/bin/sh")
> I guess.

You are right, I'm getting warnings on sh or bash when compiling.

> > + # First, make sure DISPLAY is set.  If it isn't, we're hosed; scream
> > +@@ -134,8 +142,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"
> 
> Why rename tor-browser.log to torbrowser.log?

I think this had no reason other than my personal choice.

> > + [...]
> > ++# 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"
> > ++   echo "ClientTransportPlugin meek_lite,obfs2,obfs3,obfs4,scramblesuit exec ${TBB_STORE_PATH}/TorBrowser/Tor/PluggableTransports/obfs4proxy"\
> > ++     >> "${TORRC}"
> > ++   cd "${TBB_HOME}"
> > + fi
> 
> "mkdir" and "cp" are from coreutils, which are not guaranteed to be in
> the profile. I'd suggest:
> 
> (1) (preferred) use substitute* in a build phase to replace
>     'mkdir' and 'cp' & co with the absolute store path
> (2) or add coreutils to propagated-inputs
> 
> Likewise for sed. 

Noted. I'll write a build phase.

> > [...]
> > 
> > + 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
> 
> Is this required on Guix and would it work well on Guix? Copying .desktop files around
> seems counter to ‘Guix suppots transactional upgrades and roll-backs, [...]. [...]
> reproducible operating systems’ and not very functional. Shouldn't
> "guix install torbrowser-unbundle" be sufficient?

Yes, it should. I think I was trying to change things as little as
possible from what the official bundle does/provides, but I agree that
it would be better to just remove this part of the script and have it
behave as an ordinary application.

> noscript seems an useful extension for IceCat as well.
> Maybe move it to gnuzilla.scm? Maybe move https-everywhere
> there as well? (Separate issue: https-everywhere seems to
> be bundled in IceCat ...)

I was thinking the better outcome would be to have something as it
was done for ungoogled-chromium to provide extensions that would
be compatible with both icecat and torbrowser. Unfortunatly, I've
been unable to address most of the things I had intended for now
at least. I'll also keep a note on this and address it as soon as
I can.

> Why are you copying the source code to somewhere else?

Because I did not know any better.

> This doesn't seem to accomplish anything. I would suggest
> something like:
> 
> ;; Source code of ‘HTTPS Everywhere WASM Library’,
> ;; licensed as license:lgpl2.1+, used in 'https-everywhere'
> ;; as an input.
> (define https-everywhere-lib-wasm/source-code
>   (origin (method git-fetch) [...]))
> 
> Note that you can use 'origin' objects in 'inputs' and 'native-inputs'.

Thanks, I did not know this. I'll change accordingly.

> > +      (license license:gpl2+))))
> 
> The license file seems to tell something different: LGPL2.1+ instead of GPL2+:
> https://github.com/EFForg/https-everywhere-lib-wasm/blob/master/LICENSE

Ouch. You are right.

> > [...]
> > +      (native-inputs
> > +       `(("https-everywhere" ,https-everywhere)
> > +	   ("noscript" ,noscript)
> 
> noscript and https-everywhere seem more like 'inputs' than
> 'native-inputs' to me, but IIUC they are source-code only
> and not compiled, so it doesn't really matter here I guess.

Noted.

> > +                   (make-file-writable (string-append tbb-scripts-dir
> > +						      "/RelativeLink/start-tor-browser.desktop")))
> > +		 #t))
> 
> Returning #t at the end of a phase is not required anymore.
> The warning will disappear when core-updates is merged.

Noted.

> > +             (replace 'configure
> > +               (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
> > +		 (let* ((out (assoc-ref outputs "out"))
> > +			(bash (which "bash"))
> > +			(flags `(,(string-append "--prefix=" out)
> > +				 ,@configure-flags)))
> > +                   (setenv "SHELL" bash)
> > +                   (setenv "AUTOCONF" (string-append
> > +                                       (assoc-ref %build-inputs "autoconf")
> > +                                       "/bin/autoconf"))
> 
> In build phases, use 'inputs' or 'native-inputs' instead of %build-inputs.
> It's more explicit, maybe there are other reasons as well. (Here it should
> be native-inputs I guess).

Noted.

> > +                   (setenv "CONFIG_SHELL" bash)
> > +                   (setenv "PYTHON" (string-append (assoc-ref inputs "python-2")
> > +                                                   "/bin/python"))
> 
> This most likely should be (assoc-ref (or native-inputs inputs) "python-2")
> instead of (assoc-ref inputs "python-2").
> 
> > +                   (setenv "CC" "gcc")  ; needed when Stylo is enabled
> This most likely should be ,(cc-for-target) instead of "gcc".
> 
> (The native-inputs/inputs and "gcc" / (cc-for-target) distinction is important
> when cross-compiling (though not all dependencies are cross-compilable currently,
> so it's a bit moot for now.))

Noted. This and the previous code snippets came from Thunderbird if I
remember correctly and I didn't really give it much tought. I'll try to
address them both.

> > +             (add-after 'install-extensions 'link-binaries
> > +               (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
> You're not using 'native-inputs' in this build phase so you can remove it
> from the arguments list.
> > +              [...]
> > +             (add-after 'link-binaries 'copy-bundle-data
> > +               (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
> 
> Likewise.

Noted.

> > +      (description
> > +       "Tor Browser is the Tor Project version of Firefox browser.  It is the only
> > +recommended way to anonymously browse the web that is supported by the project.
> > +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.")
> 
> This seems unnecessarily scary. All packages in guix are ‘at your own risk’
> and every new package is ‘in testing’ for a while, whatever that means.
> What about

I wrote this to give some consideration to the fact that TorProject
strongly advises people _NOT_ to build their own TorBrowsers and not
to use anything other than the one they provide. I've also intended to
make it clear that the anonymity set might be reduced and that guix
users could be distinguished from other TB users, specially given the
nature of guix would imply that at sometime or other guix users would
even be using different software versions, which applies to extensions,
libs and even the tor software under the hood. I also gathered that
it would be sometime before this could be merged into guix and that
maybe some users would find this recipe on the mailing lists and
install themselves, so I thought it would be a good thing to be over
scary rather than give a false impression that it was something one
should do without a second thought.

Thanks for your valuable input. I've been a little short on time and
got stuck for a while, but I do intent to go back to it and when I
do I'll contemplate your suggestions.

Cheers,


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 667 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser.
  2020-07-15 21:15 [bug#42380] [WIP] gnu: Add torbrowser-unbundle André Batista
  2020-07-25 14:49 ` [bug#42380] [PATCH] " André Batista
  2020-09-12 13:35 ` [bug#42380] Wow! Raghav Gururajan
@ 2023-12-12 11:21 ` Clément Lassieur
  2023-12-14 21:54   ` André Batista
  2023-12-21 13:56   ` [bug#42380] [PATCH v2] gnu: Add torbrowser Clément Lassieur
  2023-12-27 21:22 ` [bug#42380] [WIP] gnu: Add torbrowser-unbundle Anonymousemail via Guix-patches via
  3 siblings, 2 replies; 56+ messages in thread
From: Clément Lassieur @ 2023-12-12 11:21 UTC (permalink / raw)
  To: 42380
  Cc: Xinglu Chen, André Batista, Raghav Gururajan,
	Ludovic Courtès, Maxime Devos, Efraim Flashner,
	Clément Lassieur, Leo Famulari

* gnu/packages/tor.scm (torbrowser): New variable.
(torbrowser-assets): New variable.
* gnu/packages/browser-extensions.scm (noscript): New variable.
(noscript/icecat): New variable.

Change-Id: I73dc53905e4a028108bb34aae07e44256cf16c85
---

Hi, this is a package for Tor Browser.  I initially wanted to base my work on
André's but I believe pretty much everything is new now.  André's work helped
nonetheless, so thank you André.

A few notes:
 - HTTPS-everywhere extension is now built-in.
 - There is a package for Noscript.
 - Bridge support (lyrebird) will come later (patches are being polished and
   are for the testing branch)
 - I took inspiration from OpenBSD's package (they build it too) and from
   Nix (they use the bundle).
 - Some work could be done to improve icecat-minimal inheritance (icons,
   sandbox, wrap-program) but it's not trivial.
 - The name is "torbrowser" because it's obvious that we don't bundle anything
   in Guix, that's how other distros do and it's simpler.
 - It should be FSDG compatible (no DRM, no link to addons.mozilla.org).

Comments are welcome!

Clément

 gnu/packages/browser-extensions.scm |  26 +++
 gnu/packages/gnupg.scm              |   3 +-
 gnu/packages/tor.scm                | 280 ++++++++++++++++++++++++++++
 3 files changed, 307 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/browser-extensions.scm b/gnu/packages/browser-extensions.scm
index 21c519eda31c..9efa94b77396 100644
--- a/gnu/packages/browser-extensions.scm
+++ b/gnu/packages/browser-extensions.scm
@@ -21,6 +21,7 @@
 (define-module (gnu packages browser-extensions)
   #:use-module (guix gexp)
   #:use-module (guix packages)
+  #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
@@ -221,3 +222,28 @@ (define passff
 
 (define-public passff/icecat
   (make-icecat-extension passff))
+
+(define noscript
+  (package
+    (name "noscript")
+    (version "11.4.28")
+    (source (origin
+              (method url-fetch/zipbomb)
+              (uri (string-append
+                    "https://noscript.net/download/releases/noscript-" version
+                    ".xpi"))
+              (sha256
+               (base32
+                "051wawi0yjyramp743yjawqaz59g3m2gcivm24b44ibd4arpdl2l"))))
+    (build-system copy-build-system)
+    (properties '((addon-id . "{73a6fe31-595d-460b-a920-fcc0f8843232}")))
+    (arguments
+     `(#:install-plan '(("." ,(assq-ref properties 'addon-id)))))
+    (home-page "https://noscript.net")
+    (synopsis "Software providing extra protection for various browsers.")
+    (description "The NoScript Security Suite is a software providing extra
+protection for web browsers.")
+    (license license:gpl3+)))
+
+(define-public noscript/icecat
+  (make-icecat-extension noscript))
diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index a5b8587a141c..bec74b3f3f49 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -70,7 +70,6 @@ (define-module (gnu packages gnupg)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages tor)
   #:use-module (gnu packages web)
   #:use-module (gnu packages xorg)
   #:use-module (gnu packages xdisorg)
@@ -1124,7 +1123,7 @@ (define-public parcimonie
            perl-try-tiny
            perl-type-tiny
            perl-types-path-tiny
-           torsocks))
+           (@ (gnu packages tor) torsocks))) ;avoid dependency loop
     (native-inputs
      (list perl-file-which
            perl-gnupg-interface
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index 71f32b3f4331..31e9945f5d39 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -36,11 +36,15 @@ (define-module (gnu packages tor)
   #:use-module (guix utils)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system mozilla)
   #:use-module (guix build-system python)
   #:use-module (guix build-system pyproject)
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages browser-extensions)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages check)
@@ -48,6 +52,7 @@ (define-module (gnu packages tor)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages glib)
+  #:use-module (gnu packages gnuzilla)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-check)
@@ -483,3 +488,278 @@ (define-public tractor
 the onion proxy and sets up proxy in user session, so you don't have to mess
 up with TOR on your system anymore.")
     (license license:gpl3+)))
+
+(define torbrowser-assets
+  ;; This is a prebuilt Torbrowser from which we take the assets we need.
+  (package
+    (name "torbrowser-assets")
+    ;; To find the last version, look at https://www.torproject.org/download/.
+    (version "13.0.6")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append
+         "https://archive.torproject.org/tor-package-archive/torbrowser/"
+         version "/tor-browser-linux-x86_64-" version ".tar.xz"))
+       (sha256
+        (base32
+         "0d72jgcp9rbpfjivsh6vg6bgbppkhrlficwk4jz0f8h69cj8ygzd"))))
+    (arguments
+     (list
+      #:install-plan
+      ''(("Browser" "." #:include-regexp
+          ("^\\./TorBrowser/Data/Tor/torrc-defaults"
+           "^\\./fonts/"
+           "^\\./fontconfig/fonts.conf")))))
+    (build-system copy-build-system)
+    (home-page "https://www.torproject.org")
+    (synopsis "Tor Browser assets")
+    (description "This package contains fonts and configuration files for Tor
+Browser.")
+    (license license:silofl1.1)))
+
+(define-public torbrowser
+  (package
+    (inherit icecat-minimal)
+    (name "torbrowser")
+    ;; To find the last version, browse
+    ;; https://archive.torproject.org/tor-package-archive/torbrowser/<version>
+    ;; (<version> is the version of the `torbrowser-assets` package).  There
+    ;; should be only one archive that starts with "src-firefox-tor-browser-".
+    (version "115.5.0esr-13.0-1-build4")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append
+         "https://archive.torproject.org/tor-package-archive/torbrowser/"
+         (package-version torbrowser-assets)
+         "/src-firefox-tor-browser-" version ".tar.xz"))
+       (sha256
+        (base32
+         "0p0qsfc2l2bicqjr1kxciiij5qz7n8xqyvyn8f13fvk0wyg94c6v"))))
+    (build-system mozilla-build-system)
+    (arguments
+     (substitute-keyword-arguments (package-arguments icecat-minimal)
+       ((#:configure-flags flags '())
+        #~(cons*
+           "--without-relative-data-dir" ;store is read-only
+           "--disable-base-browser-update"
+           "--enable-update-channel=release"
+           "--with-branding=browser/branding/tb-release"
+           (string-append "--prefix=" #$output)
+           (string-append "--with-base-browser-version="
+                          #$(package-version
+                             (this-package-input "torbrowser-assets")))
+           #$flags))
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            (add-before 'configure 'setenv
+              (lambda _
+                (setenv "CONFIG_SHELL" (which "bash"))
+                ;; Install location is prefix/lib/$MOZ_APP_NAME.  Also
+                ;; $MOZ_APP_NAME is the executable name.  Default is
+                ;; "firefox".
+                (setenv "MOZ_APP_NAME" "torbrowser")
+                ;; Profile location (relative to "~/.").  Default is
+                ;; lower($MOZ_APP_VENDOR/$MOZ_APP_BASENAME), which is:
+                ;; ~/.tor project/firefox.
+                (setenv "MOZ_APP_PROFILE" "torbrowser/browser")
+                ;; WM_CLASS (default is "$MOZ_APP_NAME-$MOZ_UPDATE_CHANNEL").
+                (setenv "MOZ_APP_REMOTINGNAME" "Tor Browser")
+                ;; Persistent state directory for the build system (default is
+                ;; $HOME/.mozbuild).
+                (setenv "MOZBUILD_STATE_PATH"
+                        (in-vicinity (getcwd) ".mozbuild"))))
+            (add-before 'configure 'mozconfig
+              (lambda* (#:key configure-flags #:allow-other-keys)
+                (with-output-to-file "mozconfig"
+                  (lambda ()
+                    (format #t ". $topsrcdir/mozconfig-linux-x86_64~%")
+                    (for-each (lambda (flag)
+                                (format #t "ac_add_options ~a~%" flag))
+                              configure-flags)))))
+            (replace 'configure
+              (lambda _
+                (invoke "make" "-C" "tools/torbrowser" "config")))
+            (add-before 'build 'fix-addons-placeholder
+              (lambda _
+                (substitute*
+                    "toolkit/locales/en-US/toolkit/about/aboutAddons.ftl"
+                  (("addons.mozilla.org") "gnuzilla.gnu.org"))))
+            (replace 'build
+              (lambda _
+                (invoke "make" "-C" "tools/torbrowser" "build")))
+            (add-after 'install 'deploy-assets
+              (lambda _
+                (let ((assets #$(this-package-input "torbrowser-assets"))
+                      (lib (in-vicinity #$output "lib/torbrowser"))
+                      (tor #$(this-package-input "tor")))
+                  ;; TorBrowser/Data/Tor/torrc-defaults
+                  (copy-recursively (in-vicinity assets "TorBrowser")
+                                    (in-vicinity lib "TorBrowser"))
+                  ;; The geoip and geoip6 files are in the same directory as
+                  ;; torrc-defaults.  (See TorProcess.sys.mjs.)
+                  (mkdir-p (in-vicinity lib "TorBrowser/Data/Tor"))
+                  (copy-file (in-vicinity tor "share/tor/geoip")
+                             (in-vicinity lib "TorBrowser/Data/Tor/geoip"))
+                  (copy-file (in-vicinity tor "share/tor/geoip6")
+                             (in-vicinity lib "TorBrowser/Data/Tor/geoip6"))
+                  ;; Fonts
+                  (copy-recursively (in-vicinity assets "fontconfig")
+                                    (in-vicinity lib "fontconfig"))
+                  (substitute* (in-vicinity lib "fontconfig/fonts.conf")
+                    (("<dir>fonts</dir>")
+                     (format #f "<dir>~a</dir>" (in-vicinity lib "fonts"))))
+                  (delete-file-recursively (in-vicinity lib "fonts"))
+                  (copy-recursively (in-vicinity assets "fonts")
+                                    (in-vicinity lib "fonts")))))
+            (replace 'build-sandbox-whitelist
+              (lambda* (#:key inputs #:allow-other-keys)
+                (define (runpath-of lib)
+                  (call-with-input-file lib
+                    (compose elf-dynamic-info-runpath
+                             elf-dynamic-info
+                             parse-elf
+                             get-bytevector-all)))
+                (define (runpaths-of-input label)
+                  (let* ((dir (string-append (assoc-ref inputs label) "/lib"))
+                         (libs (find-files dir "\\.so$")))
+                    (append-map runpath-of libs)))
+                ;; Populate the sandbox read-path whitelist as needed by ffmpeg.
+                (let* ((whitelist
+                        (map (cut string-append <> "/")
+                             (delete-duplicates
+                              `(,(string-append (assoc-ref inputs "shared-mime-info")
+                                                "/share/mime")
+                                ,@(append-map runpaths-of-input
+                                              '("mesa" "ffmpeg"))))))
+                       (whitelist-string (string-join whitelist ",")))
+                  (with-output-to-file "whitelist.txt"
+                    (lambda ()
+                      (display whitelist-string))))))
+            (add-after 'install 'autoconfig
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let ((lib (in-vicinity #$output "lib/torbrowser"))
+                      (config-file "tor-browser.cfg"))
+                  (with-output-to-file (in-vicinity
+                                        lib "defaults/pref/autoconfig.js")
+                    (lambda ()
+                      (format #t "// first line must be a comment~%")
+                      (format #t "pref(~s, ~s);~%"
+                              "general.config.filename" config-file)
+                      (format #t "pref(~s, ~a);~%"
+                              "general.config.obscure_value" "0")))
+                  (with-output-to-file (in-vicinity lib config-file)
+                    (lambda ()
+                      (format #t "// first line must be a comment~%")
+                      ;; Locking prevents these values being written to
+                      ;; prefs.js, avoiding Store path capture.
+                      (format #t "lockPref(~s, ~s);~%"
+                              "extensions.torlauncher.torrc-defaults_path"
+                              (in-vicinity
+                               lib "TorBrowser/Data/Tor/torrc-defaults"))
+                      (format #t "lockPref(~s, ~s);~%"
+                              "extensions.torlauncher.tor_path"
+                              (search-input-file inputs "bin/tor"))
+                      ;; Required for Guix packaged extensions
+                      ;; SCOPE_PROFILE=1, SCOPE_APPLICATION=4, SCOPE_SYSTEM=8
+                      ;; Default is 5.
+                      (format #t "pref(~s, ~a);~%"
+                              "extensions.enabledScopes" "13")
+                      (format #t "pref(~s, ~s);~%"
+                              "security.sandbox.content.read_path_whitelist"
+                              (call-with-input-file "whitelist.txt"
+                                get-string-all))
+                      ;; Add-ons pannel (see settings.js in Icecat source).
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.getAddons.search.browseURL"
+                              "https://gnuzilla.gnu.org/mozzarella")
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.getAddons.get.url"
+                              "https://gnuzilla.gnu.org/mozzarella")
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.getAddons.link.url"
+                              "https://gnuzilla.gnu.org/mozzarella")
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.getAddons.discovery.api_url"
+                              "https://gnuzilla.gnu.org/mozzarella")
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.getAddons.langpacks.url"
+                              "https://gnuzilla.gnu.org/mozzarella")
+                      (format #t "pref(~s, ~s);~%"
+                              "lightweightThemes.getMoreURL"
+                              "https://gnuzilla.gnu.org/mozzarella"))))))
+            (replace 'wrap-program
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let* ((gtk #$(this-package-input "gtk+"))
+                       (gtk-share (string-append gtk "/share"))
+                       (fonts.conf (in-vicinity
+                                    #$output
+                                    "lib/torbrowser/fontconfig/fonts.conf"))
+                       (ld-libs '#$(cons
+                                    (file-append
+                                     (this-package-input "libcanberra")
+                                     "/lib/gtk-3.0/modules")
+                                    (map
+                                     (lambda (label)
+                                       (file-append
+                                        (this-package-input label) "/lib"))
+                                     '("libpng-apng"
+                                       "libxscrnsaver"
+                                       "mesa"
+                                       "pciutils"
+                                       "mit-krb5"
+                                       "eudev"
+                                       "pulseaudio"
+                                       "libnotify")))))
+                  (wrap-program
+                      (in-vicinity #$output "lib/torbrowser/torbrowser")
+                    `("XDG_DATA_DIRS" prefix (,gtk-share))
+                    `("LD_LIBRARY_PATH" prefix ,ld-libs)
+                    `("FONTCONFIG_FILE" prefix (,fonts.conf))))))
+            (replace 'install-desktop-entry
+              (lambda _
+                (let ((apps (in-vicinity #$output "share/applications")))
+                  (mkdir-p apps)
+                  (make-desktop-entry-file
+                   (in-vicinity apps "torbrowser.desktop")
+                   #:name "Tor Browser"
+                   #:exec
+                   (format #f "~a %u" (in-vicinity #$output "bin/torbrowser"))
+                   #:comment
+                   "Tor Browser is +1 for privacy and -1 for mass surveillance"
+                   #:categories '("Network" "WebBrowser" "Security")
+                   #:startup-w-m-class "Tor Browser"
+                   #:icon "tor-browser"))))
+            (replace 'install-icons
+              (lambda* (#:key inputs #:allow-other-keys)
+                (for-each
+                 (lambda (size)
+                   (let ((oldpath (string-append
+                                   "browser/branding/tb-release/default"
+                                   size ".png"))
+                         (newpath (string-append #$output
+                                                 "/share/icons/hicolor/"
+                                                 size "x" size "/apps")))
+                     (mkdir-p newpath)
+                     (copy-file oldpath
+                                (in-vicinity newpath "tor-browser.png"))))
+                 '("16" "22" "24" "32" "48" "64" "128" "256"))))))))
+    (inputs
+     (modify-inputs (package-inputs icecat-minimal)
+       (append bash-minimal
+               tor
+               torbrowser-assets)))
+    (propagated-inputs
+     (list noscript/icecat))
+    (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 the
+only recommended way to anonymously browse the web that is supported by the
+project.  It modifies Firefox in order to avoid many know application level
+attacks on the privacy of Tor users.")
+    (license license:mpl2.0)))       ;And others, see
+                                     ;toolkit/content/license.html

base-commit: bb3ab24a296ffa5273b2e82a02ed057e90c095f3
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser.
  2023-12-12 11:21 ` [bug#42380] [PATCH] gnu: Add torbrowser Clément Lassieur
@ 2023-12-14 21:54   ` André Batista
  2023-12-15 17:04     ` André Batista
                       ` (2 more replies)
  2023-12-21 13:56   ` [bug#42380] [PATCH v2] gnu: Add torbrowser Clément Lassieur
  1 sibling, 3 replies; 56+ messages in thread
From: André Batista @ 2023-12-14 21:54 UTC (permalink / raw)
  To: Clément Lassieur
  Cc: Raghav Gururajan, Ludovic Courtès, Maxime Devos,
	Efraim Flashner, Leo Famulari, 42380

Hi Clément,

ter 12 dez 2023 às 12:21:18 (1702394478), clement@lassieur.org enviou:
> 
> Hi, this is a package for Tor Browser.  I initially wanted to base my work on
> André's but I believe pretty much everything is new now.  André's work helped
> nonetheless, so thank you André.
>

Nice to see someone picking that up. Even though there were quite a lot
of changes both on guix and on Tor Browser which made my package
definition mostly obsolete, I should state beforehand that your code is
both clearer and more concise which also means more maintainable than
mine. Moreover the removal of mozilla's store was a most needed
improvement.

However, I do think that there are things which need to be fixed before
commiting this patch. I've made some intersperced comments bellow, both
to you and other reviewers.

First and foremost:

The noscript addon seems to be missing from the browser. If one goes
to the 'about:addons' tab, it is neither listed nor manageable there.
This makes the security slider almost useless and also implies that
as things stand we would lead guixen to run potentialy harmful and
nonfree javascript code unknowingly and without a warning.

You can check that on https://coveryourtracks.eff.org for the
difference between this browser fingerprint and the upstream one.

Other than that, the current recipe is not deterministic. This is
probably due to the 'BuildID' which is a timestamp.

See: (#$output)/lib/torbrowser/platform.ini

Moreover, both upstream torbrowser and guix' icecat build an
internationalized browser with several locales and the browser as is
offers users on startup to change or set the browser locale even though
we did not provide any other than en-US.

I don't think the current en-US only is a show stopper, but let's make
a note on internationalizing it later.

> A few notes:
>  - HTTPS-everywhere extension is now built-in.

In my understading, the extension got removed as the feature it provided
is now part of firefox itself.

>  - The name is "torbrowser" because it's obvious that we don't bundle anything
>    in Guix, that's how other distros do and it's simpler.

What { is || is not } obvious is highly subjective. Maybe to most people
it is obvious that the distro version of some software is not the
upstream one. On the other hand, maybe it's not obvious to many that,
with regards to TorBrowser's goals, this is a significative difference
as it potentialy implies a reduced anonymity set.

'torbrowser-unbundle' was a pun on the original torbrowser name ("Tor
Browser Bundle") and it was intended as some kind of warning to users
that the guix package cannot live up to a vital upstream goal, namely
that all users are using an identical browser in order to avoid, best
as possible, any leak which could be used to fingerprint/deanonymize
users. It was also kind of an homage to upstream directives if you
will.

However, even if some guix users may be unaware, this is an improvement
to the current situation where people use icecat with tor which
undeniably means a reduced anonymity set. Also, the hint may have been
too weak to convey the intended warning. So I won't strongly oppose
naming it simply 'torbrowser' if I'm the only one who sees a point on
doing otherwise.

>
> diff --git a/gnu/packages/browser-extensions.scm b/gnu/packages/browser-extensions.scm
> index 21c519eda31c..9efa94b77396 100644
> --- a/gnu/packages/browser-extensions.scm
> +++ b/gnu/packages/browser-extensions.scm
> @@ -21,6 +21,7 @@
>  (define-module (gnu packages browser-extensions)
>    #:use-module (guix gexp)
>    #:use-module (guix packages)
> +  #:use-module (guix download)
>    #:use-module (guix git-download)
>    #:use-module (guix build-system copy)
>    #:use-module (guix build-system gnu)
> @@ -221,3 +222,28 @@ (define passff
>  
>  (define-public passff/icecat
>    (make-icecat-extension passff))
> +
> +(define noscript
> +  (package
> +    (name "noscript")
> +    (version "11.4.28")
> +    (source (origin
> +              (method url-fetch/zipbomb)
> +              (uri (string-append
> +                    "https://noscript.net/download/releases/noscript-" version
> +                    ".xpi"))
> +              (sha256
> +               (base32
> +                "051wawi0yjyramp743yjawqaz59g3m2gcivm24b44ibd4arpdl2l"))))
> +    (build-system copy-build-system)
> +    (properties '((addon-id . "{73a6fe31-595d-460b-a920-fcc0f8843232}")))
> +    (arguments
> +     `(#:install-plan '(("." ,(assq-ref properties 'addon-id)))))
> +    (home-page "https://noscript.net")
> +    (synopsis "Software providing extra protection for various browsers.")
> +    (description "The NoScript Security Suite is a software providing extra
> +protection for web browsers.")
> +    (license license:gpl3+)))
> +
> +(define-public noscript/icecat
> +  (make-icecat-extension noscript))

As I understand it, we are not building noscript from source, but getting
a previously built which has minified JS. I never got to build it from
source and also don't think this makes it uncommitable (agains FSDG), but
maybe we could have a note to re-work this definition later in order to
have it built from source (the guix way!).

...

> diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
> index 71f32b3f4331..31e9945f5d39 100644
> --- a/gnu/packages/tor.scm
> +++ b/gnu/packages/tor.scm

...

> +(define-public torbrowser
> +  (package
> +    (inherit icecat-minimal)
> +    (name "torbrowser")
> +    ;; To find the last version, browse
> +    ;; https://archive.torproject.org/tor-package-archive/torbrowser/<version>
> +    ;; (<version> is the version of the `torbrowser-assets` package).  There
> +    ;; should be only one archive that starts with "src-firefox-tor-browser-".
> +    (version "115.5.0esr-13.0-1-build4")

Is there any reason why you chose to use the 'src' version, instead of
the TorBrowser release version (aka torbroser-assets one). At first I
think it would be better if our version were the same as upstream as
it would be clearer to both users and maintainers which version guix
is offering without installing it.

Besides, are you sure this src version number is guaranteed to be
progressive towards higher numbers?

Decomposing it:

Firefox version  |   tb build ver |   tb build attempt
115.5.0esr       |   13.0-1       |   build4

FF version: always increases, but not necessarily in the same step as
torbrowser releases;

tb build version: usually remains the same throughout a major torbrowser
release series;

tb build attempt: varies with the release process and sometimes it
decreases.


> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri
> +        (string-append
> +         "https://archive.torproject.org/tor-package-archive/torbrowser/"
> +         (package-version torbrowser-assets)
> +         "/src-firefox-tor-browser-" version ".tar.xz"))
> +       (sha256
> +        (base32
> +         "0p0qsfc2l2bicqjr1kxciiij5qz7n8xqyvyn8f13fvk0wyg94c6v"))))
> +    (build-system mozilla-build-system)
> +    (arguments
> +     (substitute-keyword-arguments (package-arguments icecat-minimal)
> +       ((#:configure-flags flags '())
> +        #~(cons*
> +           "--without-relative-data-dir" ;store is read-only

Shouldn't we also set '--with-user-appdir=.torbrowser' ?

There is a comment on 'src/browser/config/mozconfigs/tor-browser' that
says we need to set this flag when the relative data dir is unset.

> +           "--disable-base-browser-update"
> +           "--enable-update-channel=release"

Does this mean that users get notified when there is a new torbrowser
release upstream? Shouldn't this flag be removed?

> +           "--with-branding=browser/branding/tb-release"
> +           (string-append "--prefix=" #$output)
> +           (string-append "--with-base-browser-version="
> +                          #$(package-version
> +                             (this-package-input "torbrowser-assets")))
> +           #$flags))
> +       ((#:phases phases)
> +        #~(modify-phases #$phases
> +            (add-before 'configure 'setenv
> +              (lambda _
> +                (setenv "CONFIG_SHELL" (which "bash"))
> +                ;; Install location is prefix/lib/$MOZ_APP_NAME.  Also
> +                ;; $MOZ_APP_NAME is the executable name.  Default is
> +                ;; "firefox".
> +                (setenv "MOZ_APP_NAME" "torbrowser")
> +                ;; Profile location (relative to "~/.").  Default is
> +                ;; lower($MOZ_APP_VENDOR/$MOZ_APP_BASENAME), which is:
> +                ;; ~/.tor project/firefox.
> +                (setenv "MOZ_APP_PROFILE" "torbrowser/browser")
> +                ;; WM_CLASS (default is "$MOZ_APP_NAME-$MOZ_UPDATE_CHANNEL").

This comment was unclear for me at first, probably due to my own
ignorance. To the benefit of others, this is in line with instructions
on 'src/browser/config/mozconfigs/tor-browser' as a hint to window
managers on GNU/Linux.

> +                (setenv "MOZ_APP_REMOTINGNAME" "Tor Browser")
> +                ;; Persistent state directory for the build system (default is
> +                ;; $HOME/.mozbuild).
> +                (setenv "MOZBUILD_STATE_PATH"
> +                        (in-vicinity (getcwd) ".mozbuild"))))

...

> +                    (lambda ()
> +                      (format #t "// first line must be a comment~%")
> +                      ;; Locking prevents these values being written to
> +                      ;; prefs.js, avoiding Store path capture.
> +                      (format #t "lockPref(~s, ~s);~%"
> +                              "extensions.torlauncher.torrc-defaults_path"
> +                              (in-vicinity
> +                               lib "TorBrowser/Data/Tor/torrc-defaults"))
> +                      (format #t "lockPref(~s, ~s);~%"
> +                              "extensions.torlauncher.tor_path"
> +                              (search-input-file inputs "bin/tor"))

This has the undesired side-effect of making impossible to run TorBrowser
with a shepherd tor instance. Is it really needed?

Besides the inefficiency of running two tor processes, using a single one
has the benefit of making eventual onion service auth keys available both
on the browser and to other user software on the same location.

> +                      ;; Required for Guix packaged extensions
> +                      ;; SCOPE_PROFILE=1, SCOPE_APPLICATION=4, SCOPE_SYSTEM=8
> +                      ;; Default is 5.

...

> +            (replace 'install-desktop-entry
> +              (lambda _
> +                (let ((apps (in-vicinity #$output "share/applications")))
> +                  (mkdir-p apps)
> +                  (make-desktop-entry-file
> +                   (in-vicinity apps "torbrowser.desktop")
> +                   #:name "Tor Browser"
> +                   #:exec
> +                   (format #f "~a %u" (in-vicinity #$output "bin/torbrowser"))

Why do away with the 'start-tor-browser.sh'? Part of the logic there is
redundant or not necessary on a system install, but not everything.

> +                   #:comment
> +                   "Tor Browser is +1 for privacy and -1 for mass surveillance"
> +                   #:categories '("Network" "WebBrowser" "Security")
> +                   #:startup-w-m-class "Tor Browser"
> +                   #:icon "tor-browser"))))
> +            (replace 'install-icons
> +              (lambda* (#:key inputs #:allow-other-keys)
> +                (for-each
> +                 (lambda (size)
> +                   (let ((oldpath (string-append
> +                                   "browser/branding/tb-release/default"
> +                                   size ".png"))
> +                         (newpath (string-append #$output
> +                                                 "/share/icons/hicolor/"
> +                                                 size "x" size "/apps")))
> +                     (mkdir-p newpath)
> +                     (copy-file oldpath
> +                                (in-vicinity newpath "tor-browser.png"))))
> +                 '("16" "22" "24" "32" "48" "64" "128" "256"))))))))
> +    (inputs
> +     (modify-inputs (package-inputs icecat-minimal)
> +       (append bash-minimal
> +               tor

Why not tor-client instead? I don't see a legitimate use case of running
relays on the torbrowser.

Also, shouldn't this be a propagated input so as to not be garbage
collected?

> +               torbrowser-assets)))
> +    (propagated-inputs
> +     (list noscript/icecat))

This appears to be insufficient. See comments above.

Thanks for your work on guix and cheers!




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser.
  2023-12-14 21:54   ` André Batista
@ 2023-12-15 17:04     ` André Batista
  2023-12-16  3:49     ` André Batista
  2023-12-19 18:19     ` Clément Lassieur
  2 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2023-12-15 17:04 UTC (permalink / raw)
  To: Clément Lassieur
  Cc: Raghav Gururajan, Ludovic Courtès, Maxime Devos,
	Efraim Flashner, Leo Famulari, 42380

Hi Clément,

qui 14 dez 2023 às 18:54:48 (1702590888), nandre@riseup.net enviou:
> 
> First and foremost:
> 
> The noscript addon seems to be missing from the browser. If one goes
> to the 'about:addons' tab, it is neither listed nor manageable there.
> This makes the security slider almost useless and also implies that
> as things stand we would lead guixen to run potentialy harmful and
> nonfree javascript code unknowingly and without a warning.
> 
> You can check that on https://coveryourtracks.eff.org for the
> difference between this browser fingerprint and the upstream one.

Please, disregard what I've said above: noscript is indeed listed on the
addons tab, manageable there and the browser security slider is also
working as expected.

I had just built and run from the store, without installing to a profile
so guix was rightfully not picking up any info on noscript. When properly
installed, it is picked up just fine.

Please accept my appologies for improperly reviewing it, I should've
known that the bug was between the chair and the keyboard.




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser.
  2023-12-14 21:54   ` André Batista
  2023-12-15 17:04     ` André Batista
@ 2023-12-16  3:49     ` André Batista
  2023-12-19 18:19     ` Clément Lassieur
  2 siblings, 0 replies; 56+ messages in thread
From: André Batista @ 2023-12-16  3:49 UTC (permalink / raw)
  To: Clément Lassieur
  Cc: Raghav Gururajan, Ludovic Courtès, Maxime Devos,
	Efraim Flashner, Leo Famulari, 42380

Hi again!

qui 14 dez 2023 às 18:54:48 (1702590888), nandre@riseup.net enviou:
> 
> Other than that, the current recipe is not deterministic. This is
> probably due to the 'BuildID' which is a timestamp.
> 
> See: (#$output)/lib/torbrowser/platform.ini

This was it. I've just set MOZ_BUILD_DATE environment variable to a
fixed timestamp (yyyymmddhhmmss) and now the build successfully checks.

It's not much, but it's honest computer work! :)

Now the question is: do we just set a fixed timestamp and forget it until
the sun burns out or do we change it each and everytime when updating the
browser so as to mimick the upstream one?

Even though it is a bit of a hassle, I'd vote for mimicking upstream.

> > +       ((#:phases phases)
> > +        #~(modify-phases #$phases
> > +            (add-before 'configure 'setenv
> > +              (lambda _
> > +                (setenv "CONFIG_SHELL" (which "bash"))
> > +                ;; Install location is prefix/lib/$MOZ_APP_NAME.  Also
> > +                ;; $MOZ_APP_NAME is the executable name.  Default is
> > +                ;; "firefox".
> > +                (setenv "MOZ_APP_NAME" "torbrowser")
> > +                ;; Profile location (relative to "~/.").  Default is
> > +                ;; lower($MOZ_APP_VENDOR/$MOZ_APP_BASENAME), which is:
> > +                ;; ~/.tor project/firefox.
> > +                (setenv "MOZ_APP_PROFILE" "torbrowser/browser")
> > +                ;; WM_CLASS (default is "$MOZ_APP_NAME-$MOZ_UPDATE_CHANNEL").




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH] gnu: Add torbrowser.
  2023-12-14 21:54   ` André Batista
  2023-12-15 17:04     ` André Batista
  2023-12-16  3:49     ` André Batista
@ 2023-12-19 18:19     ` Clément Lassieur
  2023-12-21 15:05       ` [bug#42380] [WIP] gnu: Add torbrowser-unbundle Clément Lassieur
  2 siblings, 1 reply; 56+ messages in thread
From: Clément Lassieur @ 2023-12-19 18:19 UTC (permalink / raw)
  To: André Batista; +Cc: 42380

Hi André!

On Thu, Dec 14 2023, André Batista wrote:

> The noscript addon seems to be missing from the browser. If one goes
> to the 'about:addons' tab, it is neither listed nor manageable there.
> This makes the security slider almost useless and also implies that
> as things stand we would lead guixen to run potentialy harmful and
> nonfree javascript code unknowingly and without a warning.
>
> You can check that on https://coveryourtracks.eff.org for the
> difference between this browser fingerprint and the upstream one.

[in an other mail]
> Please, disregard what I've said above: noscript is indeed listed on the
> addons tab, manageable there and the browser security slider is also
> working as expected.
> 
> I had just built and run from the store, without installing to a profile
> so guix was rightfully not picking up any info on noscript. When properly
> installed, it is picked up just fine.
> 
> Please accept my appologies for improperly reviewing it, I should've
> known that the bug was between the chair and the keyboard.

Well you've done the greatest review I've ever seen so no need to
apologize :)  Indeed NoScript is a propagated input, so it needs to be
installed.  You can also test it like this:

    guix shell --emulate-fhs --no-offload --no-cwd --preserve=DISPLAY
    --container --network torbrowser -- torbrowser

Or if you want to add ublock-origin:

    guix shell --emulate-fhs --no-offload --no-cwd --preserve=DISPLAY
    --container --network torbrowser ublock-origin-icecat -- torbrowser

(Note that you'll need either to allow ublock0 to run in private windows
or to not be in a private window.)

My tests with https://coveryourtracks.eff.org give exactly the same
results (between 8 and 9 depending on window size) as the official Tor
Browser.

> Other than that, the current recipe is not deterministic. This is
> probably due to the 'BuildID' which is a timestamp.

Indeed I had forgotten about this.  And Icecat does it well.

> See: (#$output)/lib/torbrowser/platform.ini
>
> Moreover, both upstream torbrowser and guix' icecat build an
> internationalized browser with several locales and the browser as is
> offers users on startup to change or set the browser locale even though
> we did not provide any other than en-US.
>
> I don't think the current en-US only is a show stopper, but let's make
> a note on internationalizing it later.

Yes, but I believe we can add the internationalization as an extension,
it would be nicer than doing what Icecat does: torbrowser-minimal and
torbrowser with internationalization.  When we do this we should
probably fix Icecat as well.  This is, in my opinion, for another patch.

>> A few notes:
>>  - HTTPS-everywhere extension is now built-in.
>
> In my understading, the extension got removed as the feature it provided
> is now part of firefox itself.

Exactly.

>>  - The name is "torbrowser" because it's obvious that we don't bundle anything
>>    in Guix, that's how other distros do and it's simpler.
>
> What { is || is not } obvious is highly subjective. Maybe to most people
> it is obvious that the distro version of some software is not the
> upstream one. On the other hand, maybe it's not obvious to many that,
> with regards to TorBrowser's goals, this is a significative difference
> as it potentialy implies a reduced anonymity set.

I agree that potentially there could be a reduced anonymity, but I've
not seen any footprint difference yet and when we see it I'm hopeful
we'll be able to fix it.

> 'torbrowser-unbundle' was a pun on the original torbrowser name ("Tor
> Browser Bundle") and it was intended as some kind of warning to users
> that the guix package cannot live up to a vital upstream goal, namely
> that all users are using an identical browser in order to avoid, best
> as possible, any leak which could be used to fingerprint/deanonymize
> users. It was also kind of an homage to upstream directives if you
> will.

Are there directives about it?  I haven't been able to find them.  Also
OpenBSD names it "torbrowser" and they build it from source too.

> However, even if some guix users may be unaware, this is an improvement
> to the current situation where people use icecat with tor which
> undeniably means a reduced anonymity set. Also, the hint may have been
> too weak to convey the intended warning. So I won't strongly oppose
> naming it simply 'torbrowser' if I'm the only one who sees a point on
> doing otherwise.

The main benefit of naming it "torbrowser" is, I believe, simplicity,
and the fact that it eases adoption.  People will know it's Tor Browser
and not some variant.

The only real difference with upstream is the fact that we don't store
the profile where the executable is (because our store is read-only).  I
believe this feature is for users who have Torbrowser on a USB dongle
that can be removed and then the system is still clean.  But that's not
really a use-case for us anyway.

>> +(define-public noscript/icecat
>> +  (make-icecat-extension noscript))
>
> As I understand it, we are not building noscript from source, but getting
> a previously built which has minified JS. I never got to build it from
> source and also don't think this makes it uncommitable (agains FSDG), but
> maybe we could have a note to re-work this definition later in order to
> have it built from source (the guix way!).

Does it have minified JS though?  I had a look at several files but
could not find any that is minified.  If it does have minified JS, I
agree we should fix it.  I actually tried to build it from source but
there are a ton of missing Node dependencies. :/

>> +(define-public torbrowser
>> +  (package
>> +    (inherit icecat-minimal)
>> +    (name "torbrowser")
>> +    ;; To find the last version, browse
>> +    ;; https://archive.torproject.org/tor-package-archive/torbrowser/<version>
>> +    ;; (<version> is the version of the `torbrowser-assets` package).  There
>> +    ;; should be only one archive that starts with "src-firefox-tor-browser-".
>> +    (version "115.5.0esr-13.0-1-build4")
>
> Is there any reason why you chose to use the 'src' version, instead of
> the TorBrowser release version (aka torbroser-assets one). At first I
> think it would be better if our version were the same as upstream as
> it would be clearer to both users and maintainers which version guix
> is offering without installing it.

I just wanted the source URL to only depend on the version, and not
anything else.  That makes it easier to maintain, and it reminds people
what it really is: a Firefox.

> Besides, are you sure this src version number is guaranteed to be
> progressive towards higher numbers?
>
> Decomposing it:
>
> Firefox version  |   tb build ver |   tb build attempt
> 115.5.0esr       |   13.0-1       |   build4
>
> FF version: always increases, but not necessarily in the same step as
> torbrowser releases;
>
> tb build version: usually remains the same throughout a major torbrowser
> release series;
>
> tb build attempt: varies with the release process and sometimes it
> decreases.

    base-browser-115.1.0esr-13.0-1-build1 Tagging build1 for 115.1esr-based alpha
    base-browser-115.1.0esr-13.0-1-build2 Tagging build2 for 115.1esr-based alpha
    base-browser-115.2.0esr-13.0-1-build1 Tagging build1 for 115.2.0esr-based Base Browser alpha
    base-browser-115.2.1esr-13.0-1-build1 Tagging build1 for 115.2.1esr-based Base Browser alpha
    base-browser-115.3.0esr-13.0-1-build1 Tagging build1 for 115.3.0esr-based alpha
    base-browser-115.3.1esr-13.0-1-build1 Tagging build1 for 115.3.1esr-based stable
    base-browser-115.4.0esr-13.0-1-build1 Tagging build1 for 115.4.0esr-based stable
    base-browser-115.4.0esr-13.0-1-build2 Tagging build2 for 115.4.0esr-based stable
    base-browser-115.4.0esr-13.5-1-build1 Tagging build1 for 115.4.0esr-based alpha
    base-browser-91.12.0esr-12.0-1-build1 Tagging build1 for 91.12esr-based alpha

Here are some refs I've found in the git repo.  We can see that for the
same "tb build version" (13.0-1) there are several base browser
versions: 115.1.0, 115.2.0, 115.2.1, etc.  build1 goes to build2 only
when both "base version" and "tb build version" don't change.

In this example we can see a 13.5-1, which means alpha, which we never
want.  So version string being monotonically increasing doesn't really
help: guix package --upgrade won't work anyway.

I think the version should describe fully what we are packaging, and in
this example, we can see that 13.0.1 isn't enough.  I might be wrong
though, what do you think?

>> +    (source
>> +     (origin
>> +       (method url-fetch)
>> +       (uri
>> +        (string-append
>> +         "https://archive.torproject.org/tor-package-archive/torbrowser/"
>> +         (package-version torbrowser-assets)
>> +         "/src-firefox-tor-browser-" version ".tar.xz"))
>> +       (sha256
>> +        (base32
>> +         "0p0qsfc2l2bicqjr1kxciiij5qz7n8xqyvyn8f13fvk0wyg94c6v"))))
>> +    (build-system mozilla-build-system)
>> +    (arguments
>> +     (substitute-keyword-arguments (package-arguments icecat-minimal)
>> +       ((#:configure-flags flags '())
>> +        #~(cons*
>> +           "--without-relative-data-dir" ;store is read-only
>
> Shouldn't we also set '--with-user-appdir=.torbrowser' ?
>
> There is a comment on 'src/browser/config/mozconfigs/tor-browser' that
> says we need to set this flag when the relative data dir is unset.

They say it indeed, but they don't use it in the code^^.

    set_define("MOZ_USER_DIR", user_appdir)

[...]

    #define DEFAULT_PRODUCT_DIR nsLiteralCString(MOZ_USER_DIR)

[...]

    #if !defined(TOR_BROWSER)
      rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
      if (NS_FAILED(rv)) {
        return rv;
      }
    #endif

But you are right, I'll add it anyway, we never know, they might change
the code later.

>> +           "--disable-base-browser-update"
>> +           "--enable-update-channel=release"
>
> Does this mean that users get notified when there is a new torbrowser
> release upstream? Shouldn't this flag be removed?

No, there is a channel anyway, we just change it from "default" to
"release".  Otherwise this code gets executed:

    @depends("--enable-update-channel")
    def tor_browser_nightly_build(channel):
        if channel and channel[0] in ["default", "nightly"]:
            return True

And we get warnings of instability because it thinks it's a nightly
while it's not.  I'll add a comment!

>> +                ;; WM_CLASS (default is "$MOZ_APP_NAME-$MOZ_UPDATE_CHANNEL").
>
> This comment was unclear for me at first, probably due to my own
> ignorance. To the benefit of others, this is in line with instructions
> on 'src/browser/config/mozconfigs/tor-browser' as a hint to window
> managers on GNU/Linux.

Yeah it's just a way for windows (e.g. in Gnome) to know to which
left-bar button they are associated.

>> +                      (format #t "// first line must be a comment~%")
>> +                      ;; Locking prevents these values being written to
>> +                      ;; prefs.js, avoiding Store path capture.
>> +                      (format #t "lockPref(~s, ~s);~%"
>> +                              "extensions.torlauncher.torrc-defaults_path"
>> +                              (in-vicinity
>> +                               lib "TorBrowser/Data/Tor/torrc-defaults"))
>> +                      (format #t "lockPref(~s, ~s);~%"
>> +                              "extensions.torlauncher.tor_path"
>> +                              (search-input-file inputs "bin/tor"))
>
> This has the undesired side-effect of making impossible to run TorBrowser
> with a shepherd tor instance. Is it really needed?

I don't think so, I'll change it.

> Besides the inefficiency of running two tor processes, using a single one
> has the benefit of making eventual onion service auth keys available both
> on the browser and to other user software on the same location.

Yeah I agree.

>> +            (replace 'install-desktop-entry
>> +              (lambda _
>> +                (let ((apps (in-vicinity #$output "share/applications")))
>> +                  (mkdir-p apps)
>> +                  (make-desktop-entry-file
>> +                   (in-vicinity apps "torbrowser.desktop")
>> +                   #:name "Tor Browser"
>> +                   #:exec
>> +                   (format #f "~a %u" (in-vicinity #$output "bin/torbrowser"))
>
> Why do away with the 'start-tor-browser.sh'? Part of the logic there is
> redundant or not necessary on a system install, but not everything.

The file is 384 lines long, and most of it is not compatible with having
a read-only store.  Patching it would require a huge patch for almost 0
gain, we would be better off with a small wrapper if really there are
things we need to wrap.  But are there things we need from this file?  I
haven't found any.

>> +    (inputs
>> +     (modify-inputs (package-inputs icecat-minimal)
>> +       (append bash-minimal
>> +               tor
>
> Why not tor-client instead? I don't see a legitimate use case of running
> relays on the torbrowser.

Indeed!

> Also, shouldn't this be a propagated input so as to not be garbage
> collected?
>
>> +               torbrowser-assets)))
>> +    (propagated-inputs
>> +     (list noscript/icecat))

I don't think being propagated would change anything regarding to
garbage collection.  Normal inputs are protected as well.  But your
point is good, I need to test that everything goes well when tor is
upgraded and the previous one garbage collected.  I believe worst case
scenario is we need to use "lockPref ... tor_path" instead of "pref
... tor_path" to prevent the store paths to go into the profile.

> Thanks for your work on guix and cheers!

I'll send an updated patch soon, and I'll test garbage collecting tor.

Also, I'm working on packaging Mullvad Browser too, which is almost the
same work as Tor Browser, so we'll have 2 browsers for the same price!
It's more-or-less a Tor Browser without the Tor network, that encourages
the use of a VPN.  (And WebRTC is enabled in Mullvadbrowser while it's
not yet enabled in Tor Browser).

Thank you again for this great review André :)

Clément




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [PATCH v2] gnu: Add torbrowser.
  2023-12-12 11:21 ` [bug#42380] [PATCH] gnu: Add torbrowser Clément Lassieur
  2023-12-14 21:54   ` André Batista
@ 2023-12-21 13:56   ` Clément Lassieur
  1 sibling, 0 replies; 56+ messages in thread
From: Clément Lassieur @ 2023-12-21 13:56 UTC (permalink / raw)
  To: 42380, André Batista
  Cc: Clément Lassieur, Clément Lassieur, Jonathan Brielmaier

* gnu/packages/tor.scm (torbrowser): New variable.
(torbrowser-assets): New variable.
* gnu/packages/browser-extensions.scm (noscript): New variable.
(noscript/icecat): New variable.

Change-Id: I73dc53905e4a028108bb34aae07e44256cf16c85
---
 gnu/packages/browser-extensions.scm |  26 +++
 gnu/packages/gnupg.scm              |   3 +-
 gnu/packages/tor.scm                | 285 ++++++++++++++++++++++++++++
 3 files changed, 312 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/browser-extensions.scm b/gnu/packages/browser-extensions.scm
index 2251011f849a..178bcaae6c90 100644
--- a/gnu/packages/browser-extensions.scm
+++ b/gnu/packages/browser-extensions.scm
@@ -21,6 +21,7 @@
 (define-module (gnu packages browser-extensions)
   #:use-module (guix gexp)
   #:use-module (guix packages)
+  #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
@@ -221,3 +222,28 @@ (define passff
 
 (define-public passff/icecat
   (make-icecat-extension passff))
+
+(define noscript
+  (package
+    (name "noscript")
+    (version "11.4.28")
+    (source (origin
+              (method url-fetch/zipbomb)
+              (uri (string-append
+                    "https://noscript.net/download/releases/noscript-" version
+                    ".xpi"))
+              (sha256
+               (base32
+                "051wawi0yjyramp743yjawqaz59g3m2gcivm24b44ibd4arpdl2l"))))
+    (build-system copy-build-system)
+    (properties '((addon-id . "{73a6fe31-595d-460b-a920-fcc0f8843232}")))
+    (arguments
+     `(#:install-plan '(("." ,(assq-ref properties 'addon-id)))))
+    (home-page "https://noscript.net")
+    (synopsis "Software providing extra protection for various browsers.")
+    (description "The NoScript Security Suite is a software providing extra
+protection for web browsers.")
+    (license license:gpl3+)))
+
+(define-public noscript/icecat
+  (make-icecat-extension noscript))
diff --git a/gnu/packages/gnupg.scm b/gnu/packages/gnupg.scm
index a5b8587a141c..bec74b3f3f49 100644
--- a/gnu/packages/gnupg.scm
+++ b/gnu/packages/gnupg.scm
@@ -70,7 +70,6 @@ (define-module (gnu packages gnupg)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages tor)
   #:use-module (gnu packages web)
   #:use-module (gnu packages xorg)
   #:use-module (gnu packages xdisorg)
@@ -1124,7 +1123,7 @@ (define-public parcimonie
            perl-try-tiny
            perl-type-tiny
            perl-types-path-tiny
-           torsocks))
+           (@ (gnu packages tor) torsocks))) ;avoid dependency loop
     (native-inputs
      (list perl-file-which
            perl-gnupg-interface
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index 71f32b3f4331..f5efcd25ef25 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -36,11 +36,15 @@ (define-module (gnu packages tor)
   #:use-module (guix utils)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system mozilla)
   #:use-module (guix build-system python)
   #:use-module (guix build-system pyproject)
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages browser-extensions)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages check)
@@ -48,6 +52,7 @@ (define-module (gnu packages tor)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages glib)
+  #:use-module (gnu packages gnuzilla)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-check)
@@ -483,3 +488,283 @@ (define-public tractor
 the onion proxy and sets up proxy in user session, so you don't have to mess
 up with TOR on your system anymore.")
     (license license:gpl3+)))
+
+(define torbrowser-assets
+  ;; This is a prebuilt Torbrowser from which we take the assets we need.
+  (package
+    (name "torbrowser-assets")
+    ;; To find the last version, look at https://www.torproject.org/download/.
+    (version "13.0.6")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append
+         "https://archive.torproject.org/tor-package-archive/torbrowser/"
+         version "/tor-browser-linux-x86_64-" version ".tar.xz"))
+       (sha256
+        (base32
+         "0d72jgcp9rbpfjivsh6vg6bgbppkhrlficwk4jz0f8h69cj8ygzd"))))
+    (arguments
+     (list
+      #:install-plan
+      ''(("Browser" "." #:include-regexp
+          ("^\\./TorBrowser/Data/Tor/torrc-defaults"
+           "^\\./fonts/"
+           "^\\./fontconfig/fonts.conf")))))
+    (build-system copy-build-system)
+    (home-page "https://www.torproject.org")
+    (synopsis "Tor Browser assets")
+    (description "This package contains fonts and configuration files for Tor
+Browser.")
+    (license license:silofl1.1)))
+
+;; Must be of the form YYYYMMDDhhmmss as in `date +%Y%m%d%H%M%S`.
+(define %moz-build-date "20231219173144")
+
+(define-public torbrowser
+  (package
+    (inherit icecat-minimal)
+    (name "torbrowser")
+    ;; To find the last version, browse
+    ;; https://archive.torproject.org/tor-package-archive/torbrowser/<version>
+    ;; (<version> is the version of the `torbrowser-assets` package).  There
+    ;; should be only one archive that starts with "src-firefox-tor-browser-".
+    (version "115.5.0esr-13.0-1-build4")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append
+         "https://archive.torproject.org/tor-package-archive/torbrowser/"
+         (package-version torbrowser-assets)
+         "/src-firefox-tor-browser-" version ".tar.xz"))
+       (sha256
+        (base32
+         "0p0qsfc2l2bicqjr1kxciiij5qz7n8xqyvyn8f13fvk0wyg94c6v"))))
+    (build-system mozilla-build-system)
+    (arguments
+     (substitute-keyword-arguments (package-arguments icecat-minimal)
+       ((#:configure-flags flags '())
+        #~(cons*
+           "--without-relative-data-dir" ;store is read-only
+           "--disable-base-browser-update"
+           ;; Default is "default", which is the same as "nightly".
+           "--enable-update-channel=release"
+           "--with-user-appdir=.torbrowser"
+           "--with-branding=browser/branding/tb-release"
+           (string-append "--prefix=" #$output)
+           (string-append "--with-base-browser-version="
+                          #$(package-version
+                             (this-package-input "torbrowser-assets")))
+           #$flags))
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            (add-before 'configure 'setenv
+              (lambda _
+                (setenv "CONFIG_SHELL" (which "bash"))
+                ;; Install location is prefix/lib/$MOZ_APP_NAME.  Also
+                ;; $MOZ_APP_NAME is the executable name.  Default is
+                ;; "firefox".
+                (setenv "MOZ_APP_NAME" "torbrowser")
+                ;; Profile location (relative to "~/.").  Default is
+                ;; lower($MOZ_APP_VENDOR/$MOZ_APP_BASENAME), which is:
+                ;; ~/.tor project/firefox.
+                (setenv "MOZ_APP_PROFILE" "torbrowser/browser")
+                ;; WM_CLASS (default is "$MOZ_APP_NAME-$MOZ_UPDATE_CHANNEL").
+                (setenv "MOZ_APP_REMOTINGNAME" "Tor Browser")
+                ;; Persistent state directory for the build system (default is
+                ;; $HOME/.mozbuild).
+                (setenv "MOZBUILD_STATE_PATH"
+                        (in-vicinity (getcwd) ".mozbuild"))
+                ;; Make build reproducible.
+                (setenv "MOZ_BUILD_DATE" #$%moz-build-date)))
+            (add-before 'configure 'mozconfig
+              (lambda* (#:key configure-flags #:allow-other-keys)
+                (with-output-to-file "mozconfig"
+                  (lambda ()
+                    (format #t ". $topsrcdir/mozconfig-linux-x86_64~%")
+                    (for-each (lambda (flag)
+                                (format #t "ac_add_options ~a~%" flag))
+                              configure-flags)))))
+            (replace 'configure
+              (lambda _
+                (invoke "make" "-C" "tools/torbrowser" "config")))
+            (add-before 'build 'fix-addons-placeholder
+              (lambda _
+                (substitute*
+                    "toolkit/locales/en-US/toolkit/about/aboutAddons.ftl"
+                  (("addons.mozilla.org") "gnuzilla.gnu.org"))))
+            (replace 'build
+              (lambda _
+                (invoke "make" "-C" "tools/torbrowser" "build")))
+            (add-after 'install 'deploy-assets
+              (lambda _
+                (let ((assets #$(this-package-input "torbrowser-assets"))
+                      (lib (in-vicinity #$output "lib/torbrowser"))
+                      (tor #$(this-package-input "tor-client")))
+                  ;; TorBrowser/Data/Tor/torrc-defaults
+                  (copy-recursively (in-vicinity assets "TorBrowser")
+                                    (in-vicinity lib "TorBrowser"))
+                  ;; The geoip and geoip6 files are in the same directory as
+                  ;; torrc-defaults.  (See TorProcess.sys.mjs.)
+                  (mkdir-p (in-vicinity lib "TorBrowser/Data/Tor"))
+                  (copy-file (in-vicinity tor "share/tor/geoip")
+                             (in-vicinity lib "TorBrowser/Data/Tor/geoip"))
+                  (copy-file (in-vicinity tor "share/tor/geoip6")
+                             (in-vicinity lib "TorBrowser/Data/Tor/geoip6"))
+                  ;; Fonts
+                  (copy-recursively (in-vicinity assets "fontconfig")
+                                    (in-vicinity lib "fontconfig"))
+                  (substitute* (in-vicinity lib "fontconfig/fonts.conf")
+                    (("<dir>fonts</dir>")
+                     (format #f "<dir>~a</dir>" (in-vicinity lib "fonts"))))
+                  (delete-file-recursively (in-vicinity lib "fonts"))
+                  (copy-recursively (in-vicinity assets "fonts")
+                                    (in-vicinity lib "fonts")))))
+            (replace 'build-sandbox-whitelist
+              (lambda* (#:key inputs #:allow-other-keys)
+                (define (runpath-of lib)
+                  (call-with-input-file lib
+                    (compose elf-dynamic-info-runpath
+                             elf-dynamic-info
+                             parse-elf
+                             get-bytevector-all)))
+                (define (runpaths-of-input label)
+                  (let* ((dir (string-append (assoc-ref inputs label) "/lib"))
+                         (libs (find-files dir "\\.so$")))
+                    (append-map runpath-of libs)))
+                ;; Populate the sandbox read-path whitelist as needed by ffmpeg.
+                (let* ((whitelist
+                        (map (cut string-append <> "/")
+                             (delete-duplicates
+                              `(,(string-append (assoc-ref inputs "shared-mime-info")
+                                                "/share/mime")
+                                ,@(append-map runpaths-of-input
+                                              '("mesa" "ffmpeg"))))))
+                       (whitelist-string (string-join whitelist ",")))
+                  (with-output-to-file "whitelist.txt"
+                    (lambda ()
+                      (display whitelist-string))))))
+            (add-after 'install 'autoconfig
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let ((lib (in-vicinity #$output "lib/torbrowser"))
+                      (config-file "tor-browser.cfg"))
+                  (with-output-to-file (in-vicinity
+                                        lib "defaults/pref/autoconfig.js")
+                    (lambda ()
+                      (format #t "// first line must be a comment~%")
+                      (format #t "pref(~s, ~s);~%"
+                              "general.config.filename" config-file)
+                      (format #t "pref(~s, ~a);~%"
+                              "general.config.obscure_value" "0")))
+                  (with-output-to-file (in-vicinity lib config-file)
+                    (lambda ()
+                      (format #t "// first line must be a comment~%")
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.torlauncher.torrc-defaults_path"
+                              (in-vicinity
+                               lib "TorBrowser/Data/Tor/torrc-defaults"))
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.torlauncher.tor_path"
+                              (search-input-file inputs "bin/tor"))
+                      ;; Required for Guix packaged extensions
+                      ;; SCOPE_PROFILE=1, SCOPE_APPLICATION=4, SCOPE_SYSTEM=8
+                      ;; Default is 5.
+                      (format #t "pref(~s, ~a);~%"
+                              "extensions.enabledScopes" "13")
+                      (format #t "pref(~s, ~s);~%"
+                              "security.sandbox.content.read_path_whitelist"
+                              (call-with-input-file "whitelist.txt"
+                                get-string-all))
+                      ;; Add-ons pannel (see settings.js in Icecat source).
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.getAddons.search.browseURL"
+                              "https://gnuzilla.gnu.org/mozzarella")
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.getAddons.get.url"
+                              "https://gnuzilla.gnu.org/mozzarella")
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.getAddons.link.url"
+                              "https://gnuzilla.gnu.org/mozzarella")
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.getAddons.discovery.api_url"
+                              "https://gnuzilla.gnu.org/mozzarella")
+                      (format #t "pref(~s, ~s);~%"
+                              "extensions.getAddons.langpacks.url"
+                              "https://gnuzilla.gnu.org/mozzarella")
+                      (format #t "pref(~s, ~s);~%"
+                              "lightweightThemes.getMoreURL"
+                              "https://gnuzilla.gnu.org/mozzarella"))))))
+            (replace 'wrap-program
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let* ((gtk #$(this-package-input "gtk+"))
+                       (gtk-share (string-append gtk "/share"))
+                       (fonts.conf (in-vicinity
+                                    #$output
+                                    "lib/torbrowser/fontconfig/fonts.conf"))
+                       (ld-libs '#$(cons
+                                    (file-append
+                                     (this-package-input "libcanberra")
+                                     "/lib/gtk-3.0/modules")
+                                    (map
+                                     (lambda (label)
+                                       (file-append
+                                        (this-package-input label) "/lib"))
+                                     '("libpng-apng"
+                                       "libxscrnsaver"
+                                       "mesa"
+                                       "pciutils"
+                                       "mit-krb5"
+                                       "eudev"
+                                       "pulseaudio"
+                                       "libnotify")))))
+                  (wrap-program
+                      (in-vicinity #$output "lib/torbrowser/torbrowser")
+                    `("XDG_DATA_DIRS" prefix (,gtk-share))
+                    `("LD_LIBRARY_PATH" prefix ,ld-libs)
+                    `("FONTCONFIG_FILE" prefix (,fonts.conf))))))
+            (replace 'install-desktop-entry
+              (lambda _
+                (let ((apps (in-vicinity #$output "share/applications")))
+                  (mkdir-p apps)
+                  (make-desktop-entry-file
+                   (in-vicinity apps "torbrowser.desktop")
+                   #:name "Tor Browser"
+                   #:exec
+                   (format #f "~a %u" (in-vicinity #$output "bin/torbrowser"))
+                   #:comment
+                   "Tor Browser is +1 for privacy and -1 for mass surveillance"
+                   #:categories '("Network" "WebBrowser" "Security")
+                   #:startup-w-m-class "Tor Browser"
+                   #:icon "tor-browser"))))
+            (replace 'install-icons
+              (lambda* (#:key inputs #:allow-other-keys)
+                (for-each
+                 (lambda (size)
+                   (let ((oldpath (string-append
+                                   "browser/branding/tb-release/default"
+                                   size ".png"))
+                         (newpath (string-append #$output
+                                                 "/share/icons/hicolor/"
+                                                 size "x" size "/apps")))
+                     (mkdir-p newpath)
+                     (copy-file oldpath
+                                (in-vicinity newpath "tor-browser.png"))))
+                 '("16" "22" "24" "32" "48" "64" "128" "256"))))))))
+    (inputs
+     (modify-inputs (package-inputs icecat-minimal)
+       (append bash-minimal
+               tor-client
+               torbrowser-assets)))
+    (propagated-inputs
+     (list noscript/icecat))
+    (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 the
+only recommended way to anonymously browse the web that is supported by the
+project.  It modifies Firefox in order to avoid many know application level
+attacks on the privacy of Tor users.")
+    (license license:mpl2.0)))       ;And others, see
+                                     ;toolkit/content/license.html

base-commit: bb3ab24a296ffa5273b2e82a02ed057e90c095f3
prerequisite-patch-id: 51e2c2aaf5262d0d9001b0b5c37836060291f55d
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [bug#42380] [WIP] gnu: Add torbrowser-unbundle.
  2023-12-19 18:19     ` Clément Lassieur
@ 2023-12-21 15:05       ` Clément Lassieur
  2023-12-22 14:54         ` André Batista
  0 siblings, 1 reply; 56+ messages in thread
From: Clément Lassieur @ 2023-12-21 15:05 UTC (permalink / raw)
  To: André Batista; +Cc: 42380

On Tue, Dec 19 2023, Clément Lassieur wrote:

> I'll send an updated patch soon, and I'll test garbage collecting tor.

So I sent an updated patch, and I can confirm that references to
non-existing tor binaries don't cause any issue, those references are
updated upon starting Tor Browser.

Cheers,
Clément




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [WIP] gnu: Add torbrowser-unbundle.
  2023-12-21 15:05       ` [bug#42380] [WIP] gnu: Add torbrowser-unbundle Clément Lassieur
@ 2023-12-22 14:54         ` André Batista
  2023-12-25 15:28           ` Clément Lassieur
  0 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2023-12-22 14:54 UTC (permalink / raw)
  To: Clément Lassieur; +Cc: 42380

qui 21 dez 2023 às 16:05:44 (1703185544), clement@lassieur.org enviou:
> On Tue, Dec 19 2023, Clément Lassieur wrote:
> 
> > I'll send an updated patch soon, and I'll test garbage collecting tor.
> 
> So I sent an updated patch, and I can confirm that references to
> non-existing tor binaries don't cause any issue, those references are
> updated upon starting Tor Browser.

Will you do the honors, then?

Didn't have the time to test it yet, but I suppose we are beyond testing
phase? I, for one, will be merging this to my local channel.

Thanks and do tell me if you need any more input, I'll reply to you
after my next guix pull.




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [WIP] gnu: Add torbrowser-unbundle.
  2023-12-22 14:54         ` André Batista
@ 2023-12-25 15:28           ` Clément Lassieur
  2023-12-27 10:03             ` André Batista
  0 siblings, 1 reply; 56+ messages in thread
From: Clément Lassieur @ 2023-12-25 15:28 UTC (permalink / raw)
  To: André Batista; +Cc: 42380

On Fri, Dec 22 2023, André Batista wrote:

> qui 21 dez 2023 às 16:05:44 (1703185544), clement@lassieur.org enviou:
>> On Tue, Dec 19 2023, Clément Lassieur wrote:
>> 
>> > I'll send an updated patch soon, and I'll test garbage collecting tor.
>> 
>> So I sent an updated patch, and I can confirm that references to
>> non-existing tor binaries don't cause any issue, those references are
>> updated upon starting Tor Browser.
>
> Will you do the honors, then?

Sure!  I thought it would make sense to add a mention like:

    Co-authored-by: André Batista <nandre@riseup.net>

given all the work you've done which was useful to me.  Does it sound
good to you?

> Didn't have the time to test it yet, but I suppose we are beyond testing
> phase? I, for one, will be merging this to my local channel.
>
> Thanks and do tell me if you need any more input, I'll reply to you
> after my next guix pull.




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [WIP] gnu: Add torbrowser-unbundle.
  2023-12-25 15:28           ` Clément Lassieur
@ 2023-12-27 10:03             ` André Batista
  2023-12-27 11:18               ` bug#42380: " Clément Lassieur
  0 siblings, 1 reply; 56+ messages in thread
From: André Batista @ 2023-12-27 10:03 UTC (permalink / raw)
  To: Clément Lassieur; +Cc: 42380

seg 25 dez 2023 às 16:28:00 (1703532480), clement@lassieur.org enviou:
> On Fri, Dec 22 2023, André Batista wrote:
> 
> > qui 21 dez 2023 às 16:05:44 (1703185544), clement@lassieur.org enviou:
> >> On Tue, Dec 19 2023, Clément Lassieur wrote:
> >> 
> >> > I'll send an updated patch soon, and I'll test garbage collecting tor.
> >> 
> >> So I sent an updated patch, and I can confirm that references to
> >> non-existing tor binaries don't cause any issue, those references are
> >> updated upon starting Tor Browser.
> >
> > Will you do the honors, then?
> 
> Sure!  I thought it would make sense to add a mention like:
> 
>     Co-authored-by: André Batista <nandre@riseup.net>
> 
> given all the work you've done which was useful to me.  Does it sound
> good to you?

That would be lovely, thank you!

I've included it to my local channel and did some minimal testing and
everything seem to be working as expected.

The only thing of note was that I couldn't find here the
prerequisite-patch-id that you've mentioned on the version 2. It built
and ran just fine over 5bd80ccd6, even though it did not apply cleanly.

Cheers!




^ permalink raw reply	[flat|nested] 56+ messages in thread

* bug#42380: [WIP] gnu: Add torbrowser-unbundle.
  2023-12-27 10:03             ` André Batista
@ 2023-12-27 11:18               ` Clément Lassieur
  0 siblings, 0 replies; 56+ messages in thread
From: Clément Lassieur @ 2023-12-27 11:18 UTC (permalink / raw)
  To: André Batista; +Cc: 42380-done

On Wed, Dec 27 2023, André Batista wrote:

> seg 25 dez 2023 às 16:28:00 (1703532480), clement@lassieur.org enviou:
>> On Fri, Dec 22 2023, André Batista wrote:
>> 
>> > qui 21 dez 2023 às 16:05:44 (1703185544), clement@lassieur.org enviou:
>> >> On Tue, Dec 19 2023, Clément Lassieur wrote:
>> >> 
>> >> > I'll send an updated patch soon, and I'll test garbage collecting tor.
>> >> 
>> >> So I sent an updated patch, and I can confirm that references to
>> >> non-existing tor binaries don't cause any issue, those references are
>> >> updated upon starting Tor Browser.
>> >
>> > Will you do the honors, then?
>> 
>> Sure!  I thought it would make sense to add a mention like:
>> 
>>     Co-authored-by: André Batista <nandre@riseup.net>
>> 
>> given all the work you've done which was useful to me.  Does it sound
>> good to you?
>
> That would be lovely, thank you!
>
> I've included it to my local channel and did some minimal testing and
> everything seem to be working as expected.
>
> The only thing of note was that I couldn't find here the
> prerequisite-patch-id that you've mentioned on the version 2. It built
> and ran just fine over 5bd80ccd6, even though it did not apply cleanly.

This was probably a local unrelated commit.

Pushed!  Thanks for testing :)

Clément




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [WIP] gnu: Add torbrowser-unbundle.
  2020-07-15 21:15 [bug#42380] [WIP] gnu: Add torbrowser-unbundle André Batista
                   ` (2 preceding siblings ...)
  2023-12-12 11:21 ` [bug#42380] [PATCH] gnu: Add torbrowser Clément Lassieur
@ 2023-12-27 21:22 ` Anonymousemail via Guix-patches via
  2023-12-28 16:03   ` Clément Lassieur
  2023-12-30  0:34   ` Clément Lassieur
  3 siblings, 2 replies; 56+ messages in thread
From: Anonymousemail via Guix-patches via @ 2023-12-27 21:22 UTC (permalink / raw)
  To: 42380

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]

Hi Clément

Thank you for the good hard work. I did some preliminary testing and WebGL seems to be enabled while in the original version it is disabled by default.

Also, some minor differences could be spotted via https://fingerprintjs.github.io/fingerprintjs/ in the "Duration" fields, although I can not pinpoint what is the trigger.
  Thanks,
  Andreas

[-- Attachment #2: Type: text/html, Size: 594 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [WIP] gnu: Add torbrowser-unbundle.
  2023-12-27 21:22 ` [bug#42380] [WIP] gnu: Add torbrowser-unbundle Anonymousemail via Guix-patches via
@ 2023-12-28 16:03   ` Clément Lassieur
  2023-12-30  0:34   ` Clément Lassieur
  1 sibling, 0 replies; 56+ messages in thread
From: Clément Lassieur @ 2023-12-28 16:03 UTC (permalink / raw)
  To: Anonymousemail; +Cc: 42380

Hello!

On Wed, Dec 27 2023, Anonymousemail wrote:

> Hi Clément Thank you for the good hard work. I did some preliminary
> testing and WebGL seems to be enabled while in the original version it
> is disabled by default.

I just tested on the official version and I can confirm WebGL was
enabled.  I tested with this site: https://get.webgl.org/, and I saw it
in about:support too.

> Also, some minor differences could be spotted via
> https://fingerprintjs.github.io/fingerprintjs/ in the "Duration"
> fields, although I can not pinpoint what is the trigger.

Indeed, I'll have a look at it.  Thanks for telling me!

Clément




^ permalink raw reply	[flat|nested] 56+ messages in thread

* [bug#42380] [WIP] gnu: Add torbrowser-unbundle.
  2023-12-27 21:22 ` [bug#42380] [WIP] gnu: Add torbrowser-unbundle Anonymousemail via Guix-patches via
  2023-12-28 16:03   ` Clément Lassieur
@ 2023-12-30  0:34   ` Clément Lassieur
  1 sibling, 0 replies; 56+ messages in thread
From: Clément Lassieur @ 2023-12-30  0:34 UTC (permalink / raw)
  To: Anonymousemail; +Cc: 42380

> Hi Clément Thank you for the good hard work. I did some preliminary testing and WebGL seems to be enabled while in the original version it is
> disabled by default. Also, some minor differences could be spotted via https://fingerprintjs.github.io/fingerprintjs/ in the "Duration" fields,
> although I can not pinpoint what is the trigger. Thanks, Andreas 

Hi, 

I don't think the Duration field matters, it changes all the time
anyway.  It's probably the time it took to get a reply.

What matters on this site is probably the "Visitor identifier" and I get
the same on both "guix packaged torbrowser" and "official torbrowser".

Cheers,
Clément




^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2023-12-30  0:35 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 21:15 [bug#42380] [WIP] gnu: Add torbrowser-unbundle André Batista
2020-07-25 14:49 ` [bug#42380] [PATCH] " André Batista
2020-08-03 12:55   ` André Batista
2020-09-07 14:13     ` Ludovic Courtès
2020-09-09  2:24       ` André Batista
2020-09-09  7:20         ` Ludovic Courtès
2020-09-09 10:59           ` Efraim Flashner
2020-09-15 14:21           ` [bug#42380] [PATCH 0/9] " André Batista
2020-09-15 15:01             ` [bug#42380] [PATCH 1/9] gnu: Add go-torproject-org-ptlib André Batista
2020-09-15 15:04             ` [bug#42380] [PATCH 2/9] gnu: Add go-github-com-agl-ed25519 André Batista
2020-09-15 22:50               ` [bug#42380] [PATCH 2v2/9] " André Batista
2020-09-15 15:06             ` [bug#42380] [PATCH 0/9] gnu: Add go-github-com-dchest-siphash André Batista
2020-09-15 22:53               ` [bug#42380] [PATCH 3/9] " André Batista
2020-09-15 15:08             ` [bug#42380] [PATCH 4/9] gnu: Add go-github-com-dchest-uniuri André Batista
2020-09-15 15:10             ` [bug#42380] [PATCH 5/9] gnu: Add go-github-com-dsnet-compress André Batista
2020-09-15 15:12             ` [bug#42380] [PATCH 6/9] gnu: Add go-schwanenlied-me-yawning-bsaes André Batista
2020-09-15 15:14             ` [bug#42380] [PATCH 7/9] gnu: Add go-gitlab-com-yawning-utls André Batista
2020-09-15 15:15             ` [bug#42380] [PATCH 8/9] gnu: obfs4 André Batista
2020-09-15 15:16             ` [bug#42380] [PATCH 9/9] gnu: Add torbrowser-unbundle André Batista
2020-09-24 23:18               ` [bug#42380] [PATCHv2 " André Batista
2020-10-07 15:51                 ` [bug#42380] [PATCHv3 " André Batista
2021-06-03  3:17                   ` [bug#42380] [PATCH v4 0/9] " André Batista
2021-06-03  3:17                     ` [bug#42380] [PATCH v4 1/9] gnu: Add go-torproject-org-ptlib André Batista
2021-06-03  3:17                     ` [bug#42380] [PATCH v4 2/9] gnu: Add go-github-com-agl-ed25519 André Batista
2021-06-03  3:17                     ` [bug#42380] [PATCH v4 3/9] gnu: Add go-github-com-dchest-siphash André Batista
2021-06-03  3:17                     ` [bug#42380] [PATCH v4 4/9] gnu: Add go-github-com-dchest-uniuri André Batista
2021-06-03  3:17                     ` [bug#42380] [PATCH v4 5/9] gnu: Add go-github-com-dsnet-compress André Batista
2021-06-03  3:17                     ` [bug#42380] [PATCH v4 6/9] gnu: Add go-schwanenlied-me-yawning-bsaes André Batista
2021-06-03  3:17                     ` [bug#42380] [PATCH v4 7/9] gnu: Add go-gitlab-com-yawning-utls André Batista
2021-06-03  3:17                     ` [bug#42380] [PATCH v4 8/9] gnu: Add obfs4 André Batista
2021-06-03  3:17                     ` [bug#42380] [PATCH v4 9/9] gnu: Add torbrowser-unbundle André Batista
2021-06-03  4:10                       ` [bug#42380] [PATCH v5 " André Batista
2021-06-03 21:07                         ` Maxime Devos
2021-07-10  3:10                           ` André Batista
2021-06-03 21:07                         ` Maxime Devos
2020-09-12 13:35 ` [bug#42380] Wow! Raghav Gururajan
2020-09-15 15:23   ` André Batista
2021-05-25 15:05     ` Xinglu Chen
2021-05-25 19:12       ` Leo Famulari
2021-05-25 21:24         ` Ludovic Courtès
2021-05-28  1:45           ` André Batista
2021-06-03 20:43             ` Ludovic Courtès
2023-12-12 11:21 ` [bug#42380] [PATCH] gnu: Add torbrowser Clément Lassieur
2023-12-14 21:54   ` André Batista
2023-12-15 17:04     ` André Batista
2023-12-16  3:49     ` André Batista
2023-12-19 18:19     ` Clément Lassieur
2023-12-21 15:05       ` [bug#42380] [WIP] gnu: Add torbrowser-unbundle Clément Lassieur
2023-12-22 14:54         ` André Batista
2023-12-25 15:28           ` Clément Lassieur
2023-12-27 10:03             ` André Batista
2023-12-27 11:18               ` bug#42380: " Clément Lassieur
2023-12-21 13:56   ` [bug#42380] [PATCH v2] gnu: Add torbrowser Clément Lassieur
2023-12-27 21:22 ` [bug#42380] [WIP] gnu: Add torbrowser-unbundle Anonymousemail via Guix-patches via
2023-12-28 16:03   ` Clément Lassieur
2023-12-30  0:34   ` Clément Lassieur

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).