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
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:
| ... | ... | @@ -50,25 +50,6 @@ def is_android_build(build_project): |
| 50 | 50 | return build_project == "mobile/android"
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | -@imports(_from="pathlib", _import="Path")
|
|
| 54 | -def maven_local_default():
|
|
| 55 | - return str(Path.home() / ".m2/repository")
|
|
| 56 | - |
|
| 57 | - |
|
| 58 | -option(
|
|
| 59 | - "--with-maven-local",
|
|
| 60 | - nargs=1,
|
|
| 61 | - default=maven_local_default(),
|
|
| 62 | - help="Path the maven local directory. Defaults to $HOME/.m2/repository",
|
|
| 63 | -)
|
|
| 64 | - |
|
| 65 | - |
|
| 66 | -@depends("--with-maven-local")
|
|
| 67 | -def maven_local(value):
|
|
| 68 | - if value:
|
|
| 69 | - return value[0]
|
|
| 70 | - |
|
| 71 | - |
|
| 72 | 53 | option(
|
| 73 | 54 | "--with-tor-expert-bundle-aar",
|
| 74 | 55 | env="TOR_EXPERT_BUNDLE_AAR",
|
| ... | ... | @@ -124,7 +105,6 @@ option( |
| 124 | 105 | |
| 125 | 106 | |
| 126 | 107 | @depends(
|
| 127 | - maven_local,
|
|
| 128 | 108 | "--with-application-services",
|
| 129 | 109 | mozbuild_state_path,
|
| 130 | 110 | bootstrap_path(
|
| ... | ... | @@ -138,7 +118,7 @@ option( |
| 138 | 118 | @checking("for application-services")
|
| 139 | 119 | @imports(_from="pathlib", _import="Path")
|
| 140 | 120 | @imports("mozbuild.tbbutils")
|
| 141 | -def application_services(maven_local, value, mozbuild_state_path, _bootstrapped):
|
|
| 121 | +def application_services(value, mozbuild_state_path, _bootstrapped):
|
|
| 142 | 122 | as_location = None
|
| 143 | 123 | |
| 144 | 124 | if value:
|
| ... | ... | @@ -153,14 +133,11 @@ def application_services(maven_local, value, mozbuild_state_path, _bootstrapped) |
| 153 | 133 | as_location = bootstrapped_location
|
| 154 | 134 | |
| 155 | 135 | if not as_location:
|
| 156 | - # application-services is not required for building.
|
|
| 136 | + # application-services is required for building.
|
|
| 157 | 137 | die(
|
| 158 | 138 | "application-services not found. Either enable bootstrap, or provide a path with --with-application-services."
|
| 159 | 139 | )
|
| 160 | 140 | |
| 161 | - # Symlink a-s in the maven local repository.
|
|
| 162 | - # Note that this _overwrites_ whatever is already in there.
|
|
| 163 | - mozbuild.tbbutils.symlink_tree(as_location, maven_local)
|
|
| 164 | 141 | return as_location
|
| 165 | 142 | |
| 166 | 143 |
| ... | ... | @@ -740,13 +740,16 @@ set_config( |
| 740 | 740 | )
|
| 741 | 741 | |
| 742 | 742 | |
| 743 | -@depends("GRADLE_MAVEN_REPOSITORIES")
|
|
| 743 | +@depends(application_services, "GRADLE_MAVEN_REPOSITORIES")
|
|
| 744 | 744 | @imports(_from="os.path", _import="isdir")
|
| 745 | -def gradle_maven_repositories(values):
|
|
| 745 | +def gradle_maven_repositories(app_services_location, values):
|
|
| 746 | 746 | if not values:
|
| 747 | 747 | die("GRADLE_MAVEN_REPOSITORIES must not be empty")
|
| 748 | 748 | if not all(values):
|
| 749 | 749 | die("GRADLE_MAVEN_REPOSITORIES entries must not be empty")
|
| 750 | + |
|
| 751 | + # Prepend the location of the custom a-s location
|
|
| 752 | + values = (f"file://{app_services_location}",) + values
|
|
| 750 | 753 | return values
|
| 751 | 754 | |
| 752 | 755 |
| 1 | -import os
|
|
| 2 | 1 | import re
|
| 3 | -from pathlib import Path
|
|
| 4 | 2 | from urllib.request import Request, urlopen
|
| 5 | 3 | |
| 6 | 4 | |
| 7 | -def symlink_tree(src_dir, target_dir):
|
|
| 8 | - """
|
|
| 9 | - Recursively mirror the directory tree from `src_dir` into `target_dir`
|
|
| 10 | - using symbolic links.
|
|
| 11 | - |
|
| 12 | - Equivalent to: `cp -rs src_dir/* target_dir`
|
|
| 13 | - |
|
| 14 | - Notes:
|
|
| 15 | - - If a file or symlink already exists in the destination, it overwritten.
|
|
| 16 | - - The symlinks created here use absolute paths i.e. not relocatable.
|
|
| 17 | - """
|
|
| 18 | - src = Path(src_dir)
|
|
| 19 | - target = Path(target_dir)
|
|
| 20 | - |
|
| 21 | - target.mkdir(parents=True, exist_ok=True)
|
|
| 22 | - |
|
| 23 | - for root, _, files in os.walk(src):
|
|
| 24 | - target_path = target / Path(root).relative_to(src)
|
|
| 25 | - target_path.mkdir(parents=True, exist_ok=True)
|
|
| 26 | - |
|
| 27 | - for file in files:
|
|
| 28 | - src_file = Path(root) / file
|
|
| 29 | - target_file = target_path / file
|
|
| 30 | - if target_file.exists() or target_file.is_symlink():
|
|
| 31 | - target_file.unlink()
|
|
| 32 | - os.symlink(src_file, target_file)
|
|
| 33 | - |
|
| 34 | - |
|
| 35 | 5 | def list_files_http(url):
|
| 36 | 6 | try:
|
| 37 | 7 | req = Request(url, method="GET")
|
| 1 | -import os
|
|
| 2 | -import shutil
|
|
| 3 | -import tempfile
|
|
| 4 | 1 | import unittest
|
| 5 | -from pathlib import Path
|
|
| 6 | 2 | from types import SimpleNamespace
|
| 7 | 3 | from unittest.mock import MagicMock, patch
|
| 8 | 4 | |
| ... | ... | @@ -12,89 +8,9 @@ from mozbuild.tbbutils import ( |
| 12 | 8 | get_artifact_index,
|
| 13 | 9 | get_artifact_path,
|
| 14 | 10 | list_files_http,
|
| 15 | - symlink_tree,
|
|
| 16 | 11 | )
|
| 17 | 12 | |
| 18 | 13 | |
| 19 | -class TestSymlinkTree(unittest.TestCase):
|
|
| 20 | - def _create_sample_tree(self, base: Path):
|
|
| 21 | - (base / "subdir").mkdir()
|
|
| 22 | - (base / "file1.txt").write_text("content1")
|
|
| 23 | - (base / "subdir" / "file2.txt").write_text("content2")
|
|
| 24 | - |
|
| 25 | - def setUp(self):
|
|
| 26 | - self.tmpdir = tempfile.mkdtemp()
|
|
| 27 | - self.src = Path(self.tmpdir) / "src"
|
|
| 28 | - self.dst = Path(self.tmpdir) / "dst"
|
|
| 29 | - self.src.mkdir()
|
|
| 30 | - self.dst.mkdir()
|
|
| 31 | - |
|
| 32 | - def tearDown(self):
|
|
| 33 | - shutil.rmtree(self.tmpdir)
|
|
| 34 | - |
|
| 35 | - def test_symlinks_created_correctly(self):
|
|
| 36 | - self._create_sample_tree(self.src)
|
|
| 37 | - |
|
| 38 | - symlink_tree(self.src, self.dst)
|
|
| 39 | - |
|
| 40 | - self.assertTrue((self.dst / "file1.txt").is_symlink())
|
|
| 41 | - self.assertTrue((self.dst / "subdir" / "file2.txt").is_symlink())
|
|
| 42 | - |
|
| 43 | - self.assertEqual(
|
|
| 44 | - os.readlink(self.dst / "file1.txt"),
|
|
| 45 | - str(self.src / "file1.txt"),
|
|
| 46 | - )
|
|
| 47 | - self.assertEqual(
|
|
| 48 | - os.readlink(self.dst / "subdir" / "file2.txt"),
|
|
| 49 | - str(self.src / "subdir" / "file2.txt"),
|
|
| 50 | - )
|
|
| 51 | - |
|
| 52 | - def test_overwrites_existing_files(self):
|
|
| 53 | - self._create_sample_tree(self.src)
|
|
| 54 | - |
|
| 55 | - # Create a conflicting file in destination
|
|
| 56 | - (self.dst / "file1.txt").write_text("old")
|
|
| 57 | - |
|
| 58 | - symlink_tree(self.src, self.dst)
|
|
| 59 | - |
|
| 60 | - self.assertTrue((self.dst / "file1.txt").is_symlink())
|
|
| 61 | - self.assertEqual(
|
|
| 62 | - os.readlink(self.dst / "file1.txt"),
|
|
| 63 | - str(self.src / "file1.txt"),
|
|
| 64 | - )
|
|
| 65 | - |
|
| 66 | - def test_nested_directories_are_mirrored(self):
|
|
| 67 | - (self.src / "a" / "b" / "c").mkdir(parents=True)
|
|
| 68 | - (self.src / "a" / "b" / "c" / "deep.txt").write_text("deep content")
|
|
| 69 | - |
|
| 70 | - symlink_tree(self.src, self.dst)
|
|
| 71 | - |
|
| 72 | - deep_link = self.dst / "a" / "b" / "c" / "deep.txt"
|
|
| 73 | - self.assertTrue(deep_link.is_symlink())
|
|
| 74 | - self.assertEqual(
|
|
| 75 | - os.readlink(deep_link),
|
|
| 76 | - str(self.src / "a" / "b" / "c" / "deep.txt"),
|
|
| 77 | - )
|
|
| 78 | - |
|
| 79 | - def test_idempotence(self):
|
|
| 80 | - self._create_sample_tree(self.src)
|
|
| 81 | - |
|
| 82 | - symlink_tree(self.src, self.dst)
|
|
| 83 | - symlink_tree(self.src, self.dst) # Run again
|
|
| 84 | - |
|
| 85 | - self.assertTrue((self.dst / "file1.txt").is_symlink())
|
|
| 86 | - self.assertTrue((self.dst / "subdir" / "file2.txt").is_symlink())
|
|
| 87 | - |
|
| 88 | - def test_symlinks_use_absolute_paths(self):
|
|
| 89 | - (self.src / "file.txt").write_text("absolute")
|
|
| 90 | - |
|
| 91 | - symlink_tree(self.src, self.dst)
|
|
| 92 | - |
|
| 93 | - link_target = os.readlink(self.dst / "file.txt")
|
|
| 94 | - self.assertTrue(Path(link_target).is_absolute())
|
|
| 95 | - self.assertEqual(Path(link_target), self.src / "file.txt")
|
|
| 96 | - |
|
| 97 | - |
|
| 98 | 14 | class TestGetArtifactName(unittest.TestCase):
|
| 99 | 15 | def setUp(self):
|
| 100 | 16 | self.artifact = "artifact"
|