From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id yAZBJ3yyqWVewwAAqHPOHw:P1 (envelope-from ) for ; Fri, 19 Jan 2024 00:21:32 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id yAZBJ3yyqWVewwAAqHPOHw (envelope-from ) for ; Fri, 19 Jan 2024 00:21:32 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lassieur.org header.s=fm2 header.b=F4KCjvxd; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm3 header.b="N oY9DGL"; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1705620092; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Jon2v1hfG2GRtzMf3TEREbq+eqj57MTo3DAV8ZzUQHM=; b=PFcgO+FjwtBN2dXmxvf5w8u9h/XEmYZCa9Z+JIXCExSIW1ESNimRWeu1qOWuGe79mO6hQe cJkgS+f4AlDqaTLZJjxBM5KmKa0QcdG/dpyf2yDgnnESxHsC5+fVCNPhoj2fmS7IH1domb wzoERWFZkPxphXfWQFTNV+aXZZEbD8gXfvjkAY3fYIzTHFlYBvLB4RtRY4I1n5Rclf2Szr DQQ+wJ3oTmz6b/B+vsCw3V7iJfu/qbBXEzqx5Il98pklt9rgaUg1VadQBPdosN16VPZQZm 5Y2Jl76lozX2ft8LcM1H5nWsM4rQAISkwnGAuOMZTS/I4oT7j8/H+dTS55AKFA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lassieur.org header.s=fm2 header.b=F4KCjvxd; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm3 header.b="N oY9DGL"; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1705620092; a=rsa-sha256; cv=none; b=fvVZV+c8K6irvTTDKgIQqM5z+uuYPJSaCDxGMlh3L+uzsFneu968D25e4rLQPvQhfuyVi7 mrPj38RiBL3ShVNyZLsGKwdNcQNm0SSgCj1AtchqpTL7zLeqW1SpqZDx6aiKQpL/9su4sd zH/5bXWvwh2bqxrYLeLaw6GxdTKW8z1ZJ9YpPw1s1baNPYAMKy/LMOFvuIZHXuqlHMVTgW C4dk6lXyJVL6sKE9FIqW9/m8FZqx8MaNBhnbRtgxJ0z2vZJ6JnkbQq8BWWrjYPLQ6WBxe3 p1qWrSLs19g/yCie1jGXCgxJOEnhF8uYEJn9UM/QTVABu8cVa4fR3NiTrvmLVQ== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7D51E5A640 for ; Fri, 19 Jan 2024 00:21:31 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQbh3-0003re-1s; Thu, 18 Jan 2024 18:21:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQbh1-0003r0-GO for guix-patches@gnu.org; Thu, 18 Jan 2024 18:21:03 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQbh1-0007RE-7N for guix-patches@gnu.org; Thu, 18 Jan 2024 18:21:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rQbgz-0006e9-P8; Thu, 18 Jan 2024 18:21:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68577] [PATCH 1/2] gnu: icecat: Improve inheritance. Resent-From: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur Original-Sender: "Debbugs-submit" Resent-CC: mhw@netris.org, nandre@riseup.net, jonathan.brielmaier@web.de, ian@retrospec.tv, guix-patches@gnu.org Resent-Date: Thu, 18 Jan 2024 23:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68577 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68577@debbugs.gnu.org Cc: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur , Mark H Weaver , =?UTF-8?Q?Andr=C3=A9?= Batista , Jonathan Brielmaier , Ian Eure X-Debbugs-Original-Xcc: Mark H Weaver , =?UTF-8?Q?Andr=C3=A9?= Batista , Jonathan Brielmaier , Ian Eure Received: via spool by 68577-submit@debbugs.gnu.org id=B68577.170562004525506 (code B ref 68577); Thu, 18 Jan 2024 23:21:01 +0000 Received: (at 68577) by debbugs.gnu.org; 18 Jan 2024 23:20:45 +0000 Received: from localhost ([127.0.0.1]:56963 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rQbgi-0006dI-Mk for submit@debbugs.gnu.org; Thu, 18 Jan 2024 18:20:45 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:42843) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rQbgg-0006d5-8f for 68577@debbugs.gnu.org; Thu, 18 Jan 2024 18:20:43 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 393BF5C004E; Thu, 18 Jan 2024 18:20:35 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 18 Jan 2024 18:20:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lassieur.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1705620035; x=1705706435; bh=Jon2v1hfG2GRtzMf3TEREbq+eqj57MTo3DAV8ZzUQHM=; b= F4KCjvxdXQnAPUUSa5f3VRIVkkb1MR8HQqYPFkljkA+5vf013okCg1T6lRRw7Erm 5fl1DP6NKBY/WrI35mNEJSMueyyKxNCYVFQFsYGMLJ/U5ym5RR5/21YtjvNG0ZdC zSY6g3tCUpinUcJg3HqfYRKrJu3fIZVxVmCgJwigwOzKVWDP6VBFgkg2+Kk2HYmW M9yIaH9q3kl5yZY1LIuUv7yOo6amanmY6jk20t+DbvKtoeZ3K4CL48knCpA5XzBT 7Av2sL/CqgeC9J1gyBCcbbNeihHxhdNKcoAA54qNNbwIbEALbPzyq9PS1sPUvok5 Tqt/E7e5RRs5DAaP2yqBVQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1705620035; x= 1705706435; bh=Jon2v1hfG2GRtzMf3TEREbq+eqj57MTo3DAV8ZzUQHM=; b=N oY9DGLJ1TYnjRkrpQdIukXjhBCcmjXxQj1yb6tprJ+OD5D6g1VYfLE5OflTMMg/j e6fP6mNh0u5DWCEKaKnjiewAV3AVuTLBCnRythnTWZmrG/JvK/QcV3xg691s6UrJ jKhQVUiI878ds06hkCx3fpQObBNuWo45HdN19Om+aFIx8lBIOPtuzPeia1sBpBP5 1bxSVyTAreuQpNfPUiXVV5RPXcPkNhOiWKhS0G8Zh5Bs5B18whHhbAhvvxgV5QZQ 9EuDdti8GZhxNAf0hmHwPnZQ0DE3w1QZJ6YeJr0Q9DJGBQF6hV5zxdiB9Xkyq4+P Fp799G4QyPQ7Vsk5rdMfQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdejledguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfgggtgfesth ekredtredtjeenucfhrhhomhepvehlrohmvghnthcunfgrshhsihgvuhhruceotghlvghm vghntheslhgrshhsihgvuhhrrdhorhhgqeenucggtffrrghtthgvrhhnpeeuleettdejge ejheetveehlefghfefgeegjeeufeejveffudfffefghfevvddvueenucffohhmrghinhep ghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegtlhgvmhgvnhhtsehlrghsshhivghurhdrohhrgh X-ME-Proxy: Feedback-ID: i4c21472a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Jan 2024 18:20:33 -0500 (EST) From: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur Date: Fri, 19 Jan 2024 00:19:58 +0100 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -1.78 X-Migadu-Queue-Id: 7D51E5A640 X-Spam-Score: -1.78 X-Migadu-Scanner: mx11.migadu.com X-TUID: ggcJ76PTqeTy * gnu/packages/gnuzilla.scm (make-icecat-minimal): New procedure, export it. [arguments]: Split the ‘configure’ phase into several phases: ‘setenv’, ‘mozconfig’ and ‘configure’. In the ‘wrap-program’ and ‘install-icons’ phases, replace "icecat", "browser/branding/official" with ‘#$moz-app-name’ and ‘#$branding-directory’. Clean the ‘install-icons’ phase to help inheritance. (icecat-minimal): Call the ‘make-icecat-minimal’ procedure. * gnu/packages/tor.scm (make-torbrowser): New procedure. [base]: New variable corresponding to an ‘icecat-minimal’ with correct inheritance values. [arguments]: Replace ‘icecat-minimal’ with ‘base’. Change "torbrowser", "Tor Browser", "tb-release", ‘#$version’, ‘#$torbrowser-assets’, ‘#$%torbrowser-locales’ with ‘#$moz-app-name’, ‘#$moz-app-remotingname’, ‘#$branding-directory’, ‘#$base-browser-version’, ‘#$assets’ and ‘#$locales’. Adapt phases with regard to the ‘icecat-minimal’ changes. Split the ‘deploy-assets’ and the ‘autoconfig’ phases so to make inheritance easier. [inputs]: Inherit ‘base’ inputs instead of ‘icecat-minimal’. (torbrowser): Call the ‘make-torbrowser’ procedure. Change-Id: I5fcf73e53fe4481a18e13cdeb3515c3dc4430090 --- gnu/packages/gnuzilla.scm | 66 ++++++++------- gnu/packages/tor.scm | 171 ++++++++++++++++++-------------------- 2 files changed, 116 insertions(+), 121 deletions(-) diff --git a/gnu/packages/gnuzilla.scm b/gnu/packages/gnuzilla.scm index e3bc625bc0f5..71bf9ca99bbd 100644 --- a/gnu/packages/gnuzilla.scm +++ b/gnu/packages/gnuzilla.scm @@ -99,7 +99,8 @@ (define-module (gnu packages gnuzilla) #:use-module (gnu packages readline) #:use-module (gnu packages sqlite) #:autoload (json parser) (json->scm) - #:export (all-mozilla-locales)) + #:export (all-mozilla-locales + make-icecat-minimal)) (define-public mozjs (package @@ -720,7 +721,9 @@ (define icecat-source "--sort=name" icecat-dir))))))))) -(define-public icecat-minimal +(define* (make-icecat-minimal #:key + moz-app-name + branding-directory) (package (name "icecat-minimal") (version %icecat-version) @@ -1013,16 +1016,11 @@ (define-public icecat-minimal (substitute* "build/RunCbindgen.py" (("\"--frozen\",") "")))) (delete 'bootstrap) - (replace 'configure + (add-before 'configure 'setenv ;; configure does not work followed by both "SHELL=..." and ;; "CONFIG_SHELL=..."; set environment variables instead - (lambda* (#:key outputs configure-flags #:allow-other-keys) - (let* ((bash (which "bash")) - (abs-srcdir (getcwd)) - (flags `(,(string-append "--prefix=" #$output) - ,(string-append "--with-l10n-base=" - abs-srcdir "/l10n") - ,@configure-flags))) + (lambda* (#:key outputs #:allow-other-keys) + (let ((bash (which "bash"))) (setenv "SHELL" bash) (setenv "CONFIG_SHELL" bash) @@ -1048,16 +1046,23 @@ (define-public icecat-minimal (setenv "MOZBUILD_STATE_PATH" (string-append (getcwd) "/.mozbuild")) - (format #t "build directory: ~s~%" (getcwd)) + (format #t "build directory: ~s~%" (getcwd))))) + (add-before 'configure 'mozconfig + (lambda* (#:key configure-flags #:allow-other-keys) + (let ((flags `(,(string-append "--prefix=" #$output) + ,(string-append "--with-l10n-base=" + (getcwd) "/l10n") + ,@configure-flags))) (format #t "configure flags: ~s~%" flags) (call-with-output-file "mozconfig" (lambda (port) (for-each (lambda (flag) (format port "ac_add_options ~a\n" flag)) - flags))) - - (invoke "./mach" "configure")))) + flags)))))) + (replace 'configure + (lambda _ + (invoke "./mach" "configure"))) (replace 'build (lambda* (#:key (make-flags '()) (parallel-build? #t) #:allow-other-keys) @@ -1093,8 +1098,7 @@ (define-public icecat-minimal (string-append #$output "/bin")))) (add-after 'install 'wrap-program (lambda* (#:key inputs #:allow-other-keys) - (let* ((lib (string-append #$output "/lib")) - (gtk #$(this-package-input "gtk+")) + (let* ((gtk #$(this-package-input "gtk+")) (gtk-share (string-append gtk "/share")) (ld-libs '#$(cons (file-append @@ -1112,7 +1116,8 @@ (define-public icecat-minimal ;; For the integration of native notifications ;; (same reason as icedove) "libnotify"))))) - (wrap-program (car (find-files lib "^icecat$")) + (wrap-program (format #f "~a/lib/~a/~a" + #$output #$moz-app-name #$moz-app-name) `("XDG_DATA_DIRS" prefix (,gtk-share)) ;; The following line is commented out because the icecat ;; package on guix has been observed to be unstable when @@ -1134,18 +1139,17 @@ (define-public icecat-minimal "StartupNotify=true\nStartupWMClass=Icecat")) (install-file desktop-file applications)))) (add-after 'install-desktop-entry 'install-icons - (lambda _ - (with-directory-excursion "browser/branding/official" - (for-each - (lambda (file) - (let* ((size (string-filter char-numeric? file)) - (icons (string-append #$output "/share/icons/hicolor/" - size "x" size "/apps"))) - (mkdir-p icons) - (copy-file file (string-append icons "/icecat.png")))) - '("default16.png" "default22.png" "default24.png" - "default32.png" "default48.png" "content/icon64.png" - "mozicon128.png" "default256.png")))))))) + (lambda* (#:key inputs #:allow-other-keys) + (for-each + (lambda (size) + (let ((oldpath (string-append + #$branding-directory "/default" size ".png")) + (newpath (string-append + #$output "/share/icons/hicolor/" size "x" + size "/apps/" #$moz-app-name ".png"))) + (mkdir-p (dirname newpath)) + (copy-file oldpath newpath))) + '("16" "22" "24" "32" "48" "64" "128" "256"))))))) (native-search-paths (list (search-path-specification (variable "ICECAT_SYSTEM_DIR") @@ -1169,6 +1173,10 @@ (define-public icecat-minimal (cpe-name . "firefox_esr") (cpe-version . ,(first (string-split version #\-))))))) +(define-public icecat-minimal + (make-icecat-minimal #:moz-app-name "icecat" + #:branding-directory "browser/branding/official")) + (define %icecat-locales '("ach" "af" "an" "ar" "ast" "az" "be" "bg" "bn" "br" "bs" "ca" "cak" "ca-valencia" "cs" "cy" "da" "de" "dsb" "el" "en-CA" "en-GB" "eo" "es-AR" diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm index 604be621157c..6eb0c7609f0b 100644 --- a/gnu/packages/tor.scm +++ b/gnu/packages/tor.scm @@ -562,9 +562,18 @@ (define torbrowser-assets Browser.") (license license:silofl1.1))) -(define-public torbrowser +(define* (make-torbrowser #:key + moz-app-name + moz-app-remotingname + branding-directory + assets + locales + base-browser-version) + (define base (make-icecat-minimal + #:moz-app-name moz-app-name + #:branding-directory branding-directory)) (package - (inherit icecat-minimal) + (inherit base) (name "torbrowser") (version %torbrowser-version) (source @@ -580,42 +589,45 @@ (define-public torbrowser "1c0p8aya7sh7nmawngkyzx2r02mvl9nd53hx2bl0jwvsj1vxxhca")))) (build-system mozilla-build-system) (arguments - (substitute-keyword-arguments (package-arguments icecat-minimal) + (substitute-keyword-arguments (package-arguments base) ((#: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" + ;; This is useless right now but it might be used in the future. + ;; (See nsAppFileLocationProvider.cpp.) + (string-append "--with-user-appdir=." #$moz-app-name) + (string-append "--with-branding=" #$branding-directory) (string-append "--prefix=" #$output) - (string-append "--with-base-browser-version=" #$version) + (string-append "--with-base-browser-version=" + #$base-browser-version) #$flags)) ((#:phases phases) #~(modify-phases #$phases - (add-before 'configure 'setenv + (replace '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") + (setenv "MOZ_APP_NAME" #$moz-app-name) ;; Profile location (relative to "~/."). Default is ;; lower($MOZ_APP_VENDOR/$MOZ_APP_BASENAME), which is: ;; ~/.tor project/firefox. - (setenv "MOZ_APP_PROFILE" "torbrowser/browser") + (setenv "MOZ_APP_PROFILE" #$(in-vicinity + moz-app-name "browser")) ;; WM_CLASS (default is "$MOZ_APP_NAME-$MOZ_UPDATE_CHANNEL"). - (setenv "MOZ_APP_REMOTINGNAME" "Tor Browser") + (setenv "MOZ_APP_REMOTINGNAME" #$moz-app-remotingname) ;; Persistent state directory for the build system (default is ;; $HOME/.mozbuild). (setenv "MOZBUILD_STATE_PATH" (in-vicinity (getcwd) ".mozbuild")) - (setenv "MOZ_CHROME_MULTILOCALE" - (string-join '#$%torbrowser-locales)) + (setenv "MOZ_CHROME_MULTILOCALE" (string-join '#$locales)) ;; Make build reproducible. (setenv "MOZ_BUILD_DATE" #$%moz-build-date))) - (add-before 'configure 'mozconfig + (replace 'mozconfig (lambda* (#:key configure-flags #:allow-other-keys) (with-output-to-file "mozconfig" (lambda () @@ -623,9 +635,6 @@ (define-public torbrowser (for-each (lambda (flag) (format #t "ac_add_options ~a~%" flag)) configure-flags))))) - (replace 'configure - (lambda _ - (invoke "./mach" "configure"))) ;; See tor-browser-build/projects/firefox/build. (add-before 'configure 'copy-firefox-locales (lambda _ @@ -637,7 +646,7 @@ (define-public torbrowser (string-suffix? lang path)) '#$all-mozilla-locales) (in-vicinity l10ncentral lang))) - '#$%torbrowser-locales)))) + '#$locales)))) (add-after 'copy-firefox-locales 'copy-basebrowser-locales (lambda _ (let ((l10ncentral ".mozbuild/l10n-central")) @@ -661,7 +670,7 @@ (define-public torbrowser "translation-base-browser/~a/*" "~a/~a/browser/chrome/browser/")) lang l10ncentral lang))) - '#$%torbrowser-locales)))) + '#$locales)))) (add-after 'copy-basebrowser-locales 'copy-torbrowser-locales (lambda _ (let ((l10ncentral ".mozbuild/l10n-central")) @@ -698,7 +707,7 @@ (define-public torbrowser (format port " locale/~a/ (chrome/locale/~a/*)~%" lang lang) (close port))) - '#$%torbrowser-locales)))) + '#$locales)))) (add-before 'build 'fix-addons-placeholder (lambda _ (substitute* @@ -717,13 +726,24 @@ (define-public torbrowser (lambda _ (system (string-join '("./mach package-multi-locale --locales" "en-US $MOZ_CHROME_MULTILOCALE"))))) - (add-after 'install 'deploy-assets + (add-after 'install 'deploy-fonts + (lambda* (#:key inputs #:allow-other-keys) + (let ((lib (string-append #$output "/lib/" #$moz-app-name))) + ;; Fonts + (copy-recursively (in-vicinity #$assets "fontconfig") + (in-vicinity lib "fontconfig")) + (substitute* (in-vicinity lib "fontconfig/fonts.conf") + (("fonts") + (format #f "~a" (in-vicinity lib "fonts")))) + (delete-file-recursively (in-vicinity lib "fonts")) + (copy-recursively (in-vicinity #$assets "fonts") + (in-vicinity lib "fonts"))))) + (add-after 'deploy-fonts 'deploy-tor-assets (lambda* (#:key inputs #:allow-other-keys) (let ((lib (in-vicinity #$output "lib/torbrowser")) (tor #$(this-package-input "tor-client"))) ;; TorBrowser/Data/Tor/torrc-defaults - (copy-recursively (in-vicinity - #$torbrowser-assets "TorBrowser") + (copy-recursively (in-vicinity #$assets "TorBrowser") (in-vicinity lib "TorBrowser")) (substitute* (in-vicinity lib "TorBrowser/Data/Tor/torrc-defaults") @@ -733,20 +753,10 @@ (define-public 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 - #$torbrowser-assets "fontconfig") - (in-vicinity lib "fontconfig")) - (substitute* (in-vicinity lib "fontconfig/fonts.conf") - (("fonts") - (format #f "~a" (in-vicinity lib "fonts")))) - (delete-file-recursively (in-vicinity lib "fonts")) - (copy-recursively (in-vicinity #$torbrowser-assets "fonts") - (in-vicinity lib "fonts"))))) + (copy-file (in-vicinity tor "share/tor/geoip") + (in-vicinity lib "TorBrowser/Data/Tor/geoip"))))) (replace 'build-sandbox-whitelist (lambda* (#:key inputs #:allow-other-keys) (define (runpath-of lib) @@ -773,8 +783,8 @@ (define-public torbrowser (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")) + (let ((lib (string-append #$output "/lib/" #$moz-app-name)) + (config-file (string-append #$moz-app-name ".cfg"))) (with-output-to-file (in-vicinity lib "defaults/pref/autoconfig.js") (lambda () @@ -786,13 +796,6 @@ (define-public torbrowser (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. @@ -821,64 +824,40 @@ (define-public torbrowser (format #t "pref(~s, ~s);~%" "lightweightThemes.getMoreURL" "https://gnuzilla.gnu.org/mozzarella")))))) - (replace 'wrap-program + (add-after 'autoconfig 'autoconfig-tor (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) + (let ((lib (in-vicinity #$output "lib/torbrowser")) + (config-file (string-append #$moz-app-name ".cfg"))) + (let ((port (open-file (in-vicinity lib config-file) "a"))) + (format port "pref(~s, ~s);~%" + "extensions.torlauncher.torrc-defaults_path" + (in-vicinity + lib "TorBrowser/Data/Tor/torrc-defaults")) + (format port "pref(~s, ~s);~%" + "extensions.torlauncher.tor_path" + (search-input-file inputs "bin/tor")) + (close port))))) + (add-after 'wrap-program 'wrap-fonts + (lambda _ + (let ((fonts.conf (format #f "~a/lib/~a/fontconfig/fonts.conf" + #$output #$moz-app-name))) + (wrap-program (format #f "~a/lib/~a/~a" + #$output + #$moz-app-name #$moz-app-name) `("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" + (string-append apps #$moz-app-name ".desktop") + #:name #$moz-app-remotingname + #:exec (format #f "~a/bin/~a %u" #$output #$moz-app-name) #: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")))))))) + #:startup-w-m-class #$moz-app-remotingname + #:icon #$moz-app-name)))))))) (inputs - (modify-inputs (package-inputs icecat-minimal) + (modify-inputs (package-inputs base) (append go-gitlab-torproject-org-tpo-anti-censorship-pluggable-transports-lyrebird tor-client))) (propagated-inputs @@ -892,3 +871,11 @@ (define-public torbrowser attacks on the privacy of Tor users.") (license license:mpl2.0))) ;And others, see ;toolkit/content/license.html + +(define-public torbrowser + (make-torbrowser #:moz-app-name "torbrowser" + #:moz-app-remotingname "Tor Browser" + #:branding-directory "browser/branding/tb-release" + #:assets torbrowser-assets + #:locales %torbrowser-locales + #:base-browser-version %torbrowser-version)) -- 2.41.0