Subject: [bug#68067] [PATCH 8/8] gnu: torbrowser: Add bridges.

From: Clément Lassieur <[email-masked]>
Date: Wed, 27 Dec 2023 22:12:14 +0100

* gnu/packages/tor.scm (torbrowser)[arguments]: Add an 'add-bridges' phase,
update the 'deploy-assets' phase so to fix the lyrebird path.
[inputs]: Add
go-gitlab-torproject-org-tpo-anti-censorship-pluggable-transports-lyrebird.

Change-Id: I17c85486ab44178be9eab31a078f6392857a044f
---
 gnu/packages/tor.scm | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index bbcc9e15d607..ad44b8f3a2e0 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -13,6 +13,7 @@
 ;;; Copyright © 2021-2023 Danial Behzadi <[email-masked]>
 ;;; Copyright © 2022 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2022 Jim Newsome <[email-masked]>
+;;; Copyright © 2023 Clément Lassieur <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -52,6 +53,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 golang)
   #:use-module (gnu packages gnuzilla)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -595,14 +597,27 @@ (define-public torbrowser
                 (substitute*
                     "toolkit/locales/en-US/toolkit/about/aboutAddons.ftl"
                   (("addons.mozilla.org") "gnuzilla.gnu.org"))))
-            (add-after 'install 'deploy-assets
+            (add-before 'build 'add-bridges ;see deploy.sh
               (lambda _
+                (let ((port (open-file
+                             "browser/app/profile/000-tor-browser.js" "a")))
+                  (display
+                   "#include ../../../tools/torbrowser/bridges.js" port)
+                  (newline port)
+                  (close port))))
+            (add-after 'install 'deploy-assets
+              (lambda* (#:key inputs #:allow-other-keys)
                 (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"))
+                  (substitute*
+                      (in-vicinity lib "TorBrowser/Data/Tor/torrc-defaults")
+                    (("exec ./TorBrowser/Tor/PluggableTransports/lyrebird")
+                     (string-append
+                      "exec " (search-input-file inputs "bin/lyrebird"))))
                   ;; 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"))
@@ -752,6 +767,7 @@ (define-public torbrowser
     (inputs
      (modify-inputs (package-inputs icecat-minimal)
        (append bash-minimal
+               go-gitlab-torproject-org-tpo-anti-censorship-pluggable-transports-lyrebird
                tor-client
                torbrowser-assets)))
     (propagated-inputs
-- 
2.41.0