Loading build/moz.configure/torbrowser-resources.configure +2 −25 Changes for build/moz.configure/torbrowser-resources.configure: 2 added lines, 25 removed lines. Original line number Diff line number Diff line Loading @@ -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", Loading Loading @@ -124,7 +105,6 @@ option( @depends( maven_local, "--with-application-services", mozbuild_state_path, bootstrap_path( Loading @@ -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: Loading @@ -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 Loading mobile/android/gradle.configure +5 −2 Changes for mobile/android/gradle.configure: 5 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -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 Loading python/mozbuild/mozbuild/tbbutils.py +0 −30 Changes for python/mozbuild/mozbuild/tbbutils.py: 0 added lines, 30 removed lines. Original line number Diff line number Diff line 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") Loading python/mozbuild/mozbuild/test/test_tbbutils.py +0 −84 Changes for python/mozbuild/mozbuild/test/test_tbbutils.py: 0 added lines, 84 removed lines. Original line number Diff line number Diff line import os import shutil import tempfile import unittest from pathlib import Path from types import SimpleNamespace from unittest.mock import MagicMock, patch Loading @@ -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" Loading Loading
build/moz.configure/torbrowser-resources.configure +2 −25 Changes for build/moz.configure/torbrowser-resources.configure: 2 added lines, 25 removed lines. Original line number Diff line number Diff line Loading @@ -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", Loading Loading @@ -124,7 +105,6 @@ option( @depends( maven_local, "--with-application-services", mozbuild_state_path, bootstrap_path( Loading @@ -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: Loading @@ -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 Loading
mobile/android/gradle.configure +5 −2 Changes for mobile/android/gradle.configure: 5 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -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 Loading
python/mozbuild/mozbuild/tbbutils.py +0 −30 Changes for python/mozbuild/mozbuild/tbbutils.py: 0 added lines, 30 removed lines. Original line number Diff line number Diff line 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") Loading
python/mozbuild/mozbuild/test/test_tbbutils.py +0 −84 Changes for python/mozbuild/mozbuild/test/test_tbbutils.py: 0 added lines, 84 removed lines. Original line number Diff line number Diff line import os import shutil import tempfile import unittest from pathlib import Path from types import SimpleNamespace from unittest.mock import MagicMock, patch Loading @@ -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" Loading