tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit d6efccc3f5043ff720290bd624cab4a74df0b4b2
parent 4c932da4cb9d1210a2cd492d15069d66900db927
Author: Beatriz Rizental <bea@torproject.org>
Date:   Tue, 20 Jan 2026 12:48:37 -0300

fixup! BB 43564: Modify ./mach bootstrap for Base Browser

Generalize extension symlinking code.

Diffstat:
Mbuild/moz.configure/basebrowser-resources.configure | 2+-
Mbuild/moz.configure/bootstrap.configure | 4++--
Mpython/mozbuild/mozbuild/backend/base.py | 69+++++++++++++++++++++++++++++++++++++++------------------------------
3 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/build/moz.configure/basebrowser-resources.configure b/build/moz.configure/basebrowser-resources.configure @@ -27,7 +27,7 @@ option( "noscript", no_unpack=True, when=depends("--with-noscript")(lambda x: not x) ), ) -@checking("for noscript") +@checking("for noscript extension") @imports(_from="pathlib", _import="Path") def noscript(value, mozbuild_state_path, _bootstrapped): if value: diff --git a/build/moz.configure/bootstrap.configure b/build/moz.configure/bootstrap.configure @@ -197,8 +197,8 @@ def bootstrap_path(path, **kwargs): if path_parts[0] == "clang-tools": path_prefix = path_parts.pop(0) - # Small hack because noscript is inside the browser folder. - if path_parts[0] == "noscript": + # Small hack because extensions are inside the browser folder. + if path_parts[0] in ("noscript", ): path_prefix = "browser" def try_tbb_bootstrap(exists): diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py @@ -242,23 +242,42 @@ class BuildBackend(LoggingMixin): with open(mozpath.join(dir, ".purgecaches"), "w") as f: f.write("\n") - def _setup_tor_browser_environment(self, config): + def _create_or_replace_symlink(self, src, dst): + try: + os.symlink(src, dst) + except OSError as e: + if e.errno == errno.EEXIST: + # If the symlink already exists, remove it and try again. + os.remove(dst) + os.symlink(src, dst) + else: + return + + def _setup_extension_symlink(self, location, target_filename, exts_path): + if not location: + return + + target = exts_path / target_filename + + self.log( + logging.INFO, + "_setup_extension_symlink", + { + "location": location, + "target": str(target), + }, + "Creating symlink for extension from {location} to {target}", + ) + + exts_path.mkdir(parents=True, exist_ok=True) + self._create_or_replace_symlink(location, target) + + def _setup_base_browser_environment(self, config): app = config.substs["MOZ_BUILD_APP"] noscript_target_filename = "{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi" noscript_location = config.substs.get("NOSCRIPT") - def _infallible_symlink(src, dst): - try: - os.symlink(src, dst) - except OSError as e: - if e.errno == errno.EEXIST: - # If the symlink already exists, remove it and try again. - os.remove(dst) - os.symlink(src, dst) - else: - return - if app == "browser": tbdir = Path(config.topobjdir) / "dist" / "bin" @@ -280,7 +299,7 @@ class BuildBackend(LoggingMixin): if fonts_location: self.log( logging.INFO, - "_setup_tor_browser_environment", + "_setup_base_browser_environment", { "fonts_location": fonts_location, "fonts_target": str(paths["fonts"]), @@ -290,23 +309,13 @@ class BuildBackend(LoggingMixin): for file in Path(fonts_location).iterdir(): target = paths["fonts"] / file.name - _infallible_symlink(file, target) + self._create_or_replace_symlink(file, target) - # Set up NoScript extension - if noscript_location: - noscript_target = paths["exts"] / noscript_target_filename - self.log( - logging.INFO, - "_setup_tor_browser_environment", - { - "noscript_location": noscript_location, - "noscript_target": str(noscript_target), - }, - "Creating symlink for NoScript from {noscript_location} to {noscript_target}", - ) - - paths["exts"].mkdir(parents=True, exist_ok=True) - _infallible_symlink(noscript_location, noscript_target) + self._setup_extension_symlink( + noscript_location, + noscript_target_filename, + paths["exts"], + ) def post_build(self, config, output, jobs, verbose, status): """Called late during 'mach build' execution, after `build(...)` has finished. @@ -327,7 +336,7 @@ class BuildBackend(LoggingMixin): self._write_purgecaches(config) if status == 0: - self._setup_tor_browser_environment(config) + self._setup_base_browser_environment(config) return status