brizental pushed to branch tor-browser-146.0a1-16.0-1 at The Tor Project / Applications / Tor Browser Commits: df582a9e by Beatriz Rizental at 2025-12-08T15:15:48-03:00 fixup! TB 43564: Modify ./mach bootstrap for Tor Browser - - - - - 4 changed files: - build/moz.configure/torbrowser-resources.configure - mobile/android/gradle.configure - python/mozbuild/mozbuild/tbbutils.py - python/mozbuild/mozbuild/test/test_tbbutils.py Changes: ===================================== build/moz.configure/torbrowser-resources.configure ===================================== @@ -50,25 +50,6 @@ def is_android_build(build_project): return build_project == "mobile/android" -@imports(_from="pathlib", _import="Path") -def maven_local_default(): - return str(Path.home() / ".m2/repository") - - -option( - "--with-maven-local", - nargs=1, - default=maven_local_default(), - help="Path the maven local directory. Defaults to $HOME/.m2/repository", -) - - -@depends("--with-maven-local") -def maven_local(value): - if value: - return value[0] - - option( "--with-tor-expert-bundle-aar", env="TOR_EXPERT_BUNDLE_AAR", @@ -124,7 +105,6 @@ option( @depends( - maven_local, "--with-application-services", mozbuild_state_path, bootstrap_path( @@ -138,7 +118,7 @@ option( @checking("for application-services") @imports(_from="pathlib", _import="Path") @imports("mozbuild.tbbutils") -def application_services(maven_local, value, mozbuild_state_path, _bootstrapped): +def application_services(value, mozbuild_state_path, _bootstrapped): as_location = None if value: @@ -153,14 +133,11 @@ def application_services(maven_local, value, mozbuild_state_path, _bootstrapped) as_location = bootstrapped_location if not as_location: - # application-services is not required for building. + # application-services is required for building. die( "application-services not found. Either enable bootstrap, or provide a path with --with-application-services." ) - # Symlink a-s in the maven local repository. - # Note that this _overwrites_ whatever is already in there. - mozbuild.tbbutils.symlink_tree(as_location, maven_local) return as_location ===================================== mobile/android/gradle.configure ===================================== @@ -740,13 +740,16 @@ set_config( ) -@depends("GRADLE_MAVEN_REPOSITORIES") +@depends(application_services, "GRADLE_MAVEN_REPOSITORIES") @imports(_from="os.path", _import="isdir") -def gradle_maven_repositories(values): +def gradle_maven_repositories(app_services_location, values): if not values: die("GRADLE_MAVEN_REPOSITORIES must not be empty") if not all(values): die("GRADLE_MAVEN_REPOSITORIES entries must not be empty") + + # Prepend the location of the custom a-s location + values = (f"file://{app_services_location}",) + values return values ===================================== python/mozbuild/mozbuild/tbbutils.py ===================================== @@ -1,37 +1,7 @@ -import os import re -from pathlib import Path from urllib.request import Request, urlopen -def symlink_tree(src_dir, target_dir): - """ - Recursively mirror the directory tree from `src_dir` into `target_dir` - using symbolic links. - - Equivalent to: `cp -rs src_dir/* target_dir` - - Notes: - - If a file or symlink already exists in the destination, it overwritten. - - The symlinks created here use absolute paths i.e. not relocatable. - """ - src = Path(src_dir) - target = Path(target_dir) - - target.mkdir(parents=True, exist_ok=True) - - for root, _, files in os.walk(src): - target_path = target / Path(root).relative_to(src) - target_path.mkdir(parents=True, exist_ok=True) - - for file in files: - src_file = Path(root) / file - target_file = target_path / file - if target_file.exists() or target_file.is_symlink(): - target_file.unlink() - os.symlink(src_file, target_file) - - def list_files_http(url): try: req = Request(url, method="GET") ===================================== python/mozbuild/mozbuild/test/test_tbbutils.py ===================================== @@ -1,8 +1,4 @@ -import os -import shutil -import tempfile import unittest -from pathlib import Path from types import SimpleNamespace from unittest.mock import MagicMock, patch @@ -12,89 +8,9 @@ from mozbuild.tbbutils import ( get_artifact_index, get_artifact_path, list_files_http, - symlink_tree, ) -class TestSymlinkTree(unittest.TestCase): - def _create_sample_tree(self, base: Path): - (base / "subdir").mkdir() - (base / "file1.txt").write_text("content1") - (base / "subdir" / "file2.txt").write_text("content2") - - def setUp(self): - self.tmpdir = tempfile.mkdtemp() - self.src = Path(self.tmpdir) / "src" - self.dst = Path(self.tmpdir) / "dst" - self.src.mkdir() - self.dst.mkdir() - - def tearDown(self): - shutil.rmtree(self.tmpdir) - - def test_symlinks_created_correctly(self): - self._create_sample_tree(self.src) - - symlink_tree(self.src, self.dst) - - self.assertTrue((self.dst / "file1.txt").is_symlink()) - self.assertTrue((self.dst / "subdir" / "file2.txt").is_symlink()) - - self.assertEqual( - os.readlink(self.dst / "file1.txt"), - str(self.src / "file1.txt"), - ) - self.assertEqual( - os.readlink(self.dst / "subdir" / "file2.txt"), - str(self.src / "subdir" / "file2.txt"), - ) - - def test_overwrites_existing_files(self): - self._create_sample_tree(self.src) - - # Create a conflicting file in destination - (self.dst / "file1.txt").write_text("old") - - symlink_tree(self.src, self.dst) - - self.assertTrue((self.dst / "file1.txt").is_symlink()) - self.assertEqual( - os.readlink(self.dst / "file1.txt"), - str(self.src / "file1.txt"), - ) - - def test_nested_directories_are_mirrored(self): - (self.src / "a" / "b" / "c").mkdir(parents=True) - (self.src / "a" / "b" / "c" / "deep.txt").write_text("deep content") - - symlink_tree(self.src, self.dst) - - deep_link = self.dst / "a" / "b" / "c" / "deep.txt" - self.assertTrue(deep_link.is_symlink()) - self.assertEqual( - os.readlink(deep_link), - str(self.src / "a" / "b" / "c" / "deep.txt"), - ) - - def test_idempotence(self): - self._create_sample_tree(self.src) - - symlink_tree(self.src, self.dst) - symlink_tree(self.src, self.dst) # Run again - - self.assertTrue((self.dst / "file1.txt").is_symlink()) - self.assertTrue((self.dst / "subdir" / "file2.txt").is_symlink()) - - def test_symlinks_use_absolute_paths(self): - (self.src / "file.txt").write_text("absolute") - - symlink_tree(self.src, self.dst) - - link_target = os.readlink(self.dst / "file.txt") - self.assertTrue(Path(link_target).is_absolute()) - self.assertEqual(Path(link_target), self.src / "file.txt") - - class TestGetArtifactName(unittest.TestCase): def setUp(self): self.artifact = "artifact" View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/df582a9e... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/df582a9e... You're receiving this email because of your account on gitlab.torproject.org.
participants (1)
-
brizental (@brizental)