Commits:
-
47aef959
by Beatriz Rizental at 2026-11-19T09:13:13-03:00
fixup! BB 43564: Modify ./mach bootstrap for Base Browser
Bug 45396: Fetch artifacts from our toolchains when
building artifact builds.
-
928c2e1e
by Beatriz Rizental at 2026-11-19T09:13:14-03:00
fixup! BB 43564: Modify ./mach bootstrap for Base Browser
Bug 45396: Remove not about bootstrap being experimental.
It's not anymore.
6 changed files:
Changes:
python/mozboot/mozboot/bootstrap.py
| ... |
... |
@@ -54,10 +54,6 @@ Tor Browser for Android frontends, or the GeckoView Java API. They are unsuitabl |
|
54
|
54
|
for those working on C++ code. For more information see:
|
|
55
|
55
|
https://firefox-source-docs.mozilla.org/contributing/build/artifact_builds.html.
|
|
56
|
56
|
|
|
57
|
|
-# Note to Tor Browser developers
|
|
58
|
|
-
|
|
59
|
|
-This is still highly experimental. Expect bugs!
|
|
60
|
|
-
|
|
61
|
57
|
Please choose the version of Tor Browser you want to build (see note above):
|
|
62
|
58
|
%s
|
|
63
|
59
|
Your choice: """
|
python/mozbuild/mozbuild/artifacts.py
| ... |
... |
@@ -60,6 +60,7 @@ from mozpack.files import FileFinder, JarFinder, TarFinder |
|
60
|
60
|
from mozpack.mozjar import JarReader, JarWriter
|
|
61
|
61
|
from mozpack.packager.unpack import UnpackFinder
|
|
62
|
62
|
|
|
|
63
|
+from mozbuild import tbbutils
|
|
63
|
64
|
from mozbuild.artifact_builds import JOB_CHOICES
|
|
64
|
65
|
from mozbuild.artifact_cache import ArtifactCache
|
|
65
|
66
|
from mozbuild.dirutils import ensureParentDir, mkdir
|
| ... |
... |
@@ -1795,6 +1796,23 @@ https://firefox-source-docs.mozilla.org/contributing/vcs/mercurial_bundles.html |
|
1795
|
1796
|
)
|
|
1796
|
1797
|
return 1
|
|
1797
|
1798
|
|
|
|
1799
|
+ def install_from_tor_project_artifacts(self, distdir):
|
|
|
1800
|
+ version = self._substs["MOZ_APP_VERSION"]
|
|
|
1801
|
+ urls = tbbutils.find_artifact_urls(self._job, version, self._artifact_job)
|
|
|
1802
|
+ if not urls:
|
|
|
1803
|
+ raise ValueError(f"Unable to fetch list of artifacts for job {self._job}")
|
|
|
1804
|
+ for url in urls:
|
|
|
1805
|
+ self.log(
|
|
|
1806
|
+ logging.INFO,
|
|
|
1807
|
+ "artifact",
|
|
|
1808
|
+ {"url": url},
|
|
|
1809
|
+ "Installing Tor Project artifact from {url}",
|
|
|
1810
|
+ )
|
|
|
1811
|
+ if self.install_from_url(url, distdir):
|
|
|
1812
|
+ return 1
|
|
|
1813
|
+
|
|
|
1814
|
+ return 0
|
|
|
1815
|
+
|
|
1798
|
1816
|
def install_from_recent(self, distdir):
|
|
1799
|
1817
|
hg_pushheads = self._find_pushheads()
|
|
1800
|
1818
|
return self._install_from_hg_pushheads(hg_pushheads, distdir)
|
| ... |
... |
@@ -1905,7 +1923,7 @@ https://firefox-source-docs.mozilla.org/contributing/vcs/mercurial_bundles.html |
|
1905
|
1923
|
if var in os.environ:
|
|
1906
|
1924
|
return self.install_from_task(os.environ[var], distdir)
|
|
1907
|
1925
|
|
|
1908
|
|
- return self.install_from_recent(distdir)
|
|
|
1926
|
+ return self.install_from_tor_project_artifacts(distdir)
|
|
1909
|
1927
|
|
|
1910
|
1928
|
def clear_cache(self):
|
|
1911
|
1929
|
self.log(logging.INFO, "artifact", {}, "Deleting cached artifacts and caches.")
|
python/mozbuild/mozbuild/tbbutils.py
| ... |
... |
@@ -14,7 +14,7 @@ def list_files_http(url): |
|
14
|
14
|
|
|
15
|
15
|
links = []
|
|
16
|
16
|
for href in re.findall(r'<a href="">"([^"]+)"', html):
|
|
17
|
|
- if href == "../":
|
|
|
17
|
+ if href == "../" or href.startswith(("?", "/")):
|
|
18
|
18
|
continue
|
|
19
|
19
|
|
|
20
|
20
|
if "tor-expert-bundle-aar" in href:
|
| ... |
... |
@@ -125,3 +125,45 @@ def get_artifact_path(url, artifact, target, prefix="", log=lambda *args, **kwar |
|
125
|
125
|
matches = filter_files(files_per_os, target.cpu)
|
|
126
|
126
|
|
|
127
|
127
|
return f"{url}/{artifact}/{matches[0]}" if matches else None
|
|
|
128
|
+
|
|
|
129
|
+
|
|
|
130
|
+TOR_PROJECT_TOOLCHAINS_URL = (
|
|
|
131
|
+ "https://nightlies.tbb.torproject.org/nightly-builds/toolchains"
|
|
|
132
|
+)
|
|
|
133
|
+TOR_PROJECT_BROWSER_PREFIX = "tb"
|
|
|
134
|
+
|
|
|
135
|
+# Mozilla job name prefix -> Tor Project toolchain target. Order matters: more
|
|
|
136
|
+# specific prefixes must come before the prefixes they start with.
|
|
|
137
|
+TOR_PROJECT_TOOLCHAIN_TARGETS = (
|
|
|
138
|
+ ("android-arm", "android-armeabi-v7a"),
|
|
|
139
|
+ ("android-aarch64", "android-arm64-v8a"),
|
|
|
140
|
+ ("android-x86_64", "android-x86_64"),
|
|
|
141
|
+ ("linux64-aarch64", "linux-aarch64"),
|
|
|
142
|
+ ("linux64", "linux-x86_64"),
|
|
|
143
|
+ ("macosx64-aarch64", "macos-aarch64"),
|
|
|
144
|
+ ("macosx64", "macos-x86_64"),
|
|
|
145
|
+ ("win32", "windows-i686"),
|
|
|
146
|
+ ("win64", "windows-x86_64"),
|
|
|
147
|
+)
|
|
|
148
|
+
|
|
|
149
|
+
|
|
|
150
|
+def get_artifacts_dir_url(job, version):
|
|
|
151
|
+ for prefix, target in TOR_PROJECT_TOOLCHAIN_TARGETS:
|
|
|
152
|
+ if job.startswith(prefix):
|
|
|
153
|
+ return f"{TOR_PROJECT_TOOLCHAINS_URL}/{TOR_PROJECT_BROWSER_PREFIX}-{version}/{target}"
|
|
|
154
|
+ raise ValueError(f"No Tor Project toolchain artifacts for {version}, {job}")
|
|
|
155
|
+
|
|
|
156
|
+
|
|
|
157
|
+def find_artifact_urls(job, version, artifact_job):
|
|
|
158
|
+ """
|
|
|
159
|
+ Return the URLs of the artifacts available for ``job`` that
|
|
|
160
|
+ ``artifact_job`` (a mozbuild.artifacts.ArtifactJob) wants to install.
|
|
|
161
|
+ """
|
|
|
162
|
+ url = get_artifacts_dir_url(job, version)
|
|
|
163
|
+ artifacts = [
|
|
|
164
|
+ {"name": f"public/build/{name}"} for name in list_files_http(f"{url}/")
|
|
|
165
|
+ ]
|
|
|
166
|
+ return [
|
|
|
167
|
+ f"{url}/{artifact.rsplit('/', 1)[-1]}"
|
|
|
168
|
+ for artifact in artifact_job.find_candidate_artifacts(artifacts)
|
|
|
169
|
+ ] |
python/mozbuild/mozbuild/test/python.toml
| ... |
... |
@@ -137,6 +137,9 @@ subsuite = "mozbuild" |
|
137
|
137
|
|
|
138
|
138
|
["test_site_dependency_extractor.py"]
|
|
139
|
139
|
|
|
|
140
|
+["test_tbb_artifacts.py"]
|
|
|
141
|
+subsuite = "base-browser"
|
|
|
142
|
+
|
|
140
|
143
|
["test_tbbutils.py"]
|
|
141
|
144
|
subsuite = "base-browser"
|
|
142
|
145
|
|
python/mozbuild/mozbuild/test/test_tbb_artifacts.py
|
|
1
|
+# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
2
|
+# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
3
|
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
4
|
+
|
|
|
5
|
+import tempfile
|
|
|
6
|
+from unittest import TestCase, mock
|
|
|
7
|
+
|
|
|
8
|
+import mozunit
|
|
|
9
|
+
|
|
|
10
|
+from mozbuild import tbbutils
|
|
|
11
|
+from mozbuild.artifacts import Artifacts
|
|
|
12
|
+from mozbuild.tbbutils import TOR_PROJECT_BROWSER_PREFIX, TOR_PROJECT_TOOLCHAINS_URL
|
|
|
13
|
+
|
|
|
14
|
+BASE_URL = (
|
|
|
15
|
+ f"{TOR_PROJECT_TOOLCHAINS_URL}/{TOR_PROJECT_BROWSER_PREFIX}-140.0/linux-x86_64"
|
|
|
16
|
+)
|
|
|
17
|
+
|
|
|
18
|
+
|
|
|
19
|
+class TestTorProjectArtifacts(TestCase):
|
|
|
20
|
+ def setUp(self):
|
|
|
21
|
+ self._tmpdir = tempfile.TemporaryDirectory()
|
|
|
22
|
+ self.addCleanup(self._tmpdir.cleanup)
|
|
|
23
|
+ self.log = mock.Mock()
|
|
|
24
|
+ self.artifacts = self._make_artifacts("linux64-opt")
|
|
|
25
|
+
|
|
|
26
|
+ def _make_artifacts(self, job):
|
|
|
27
|
+ return Artifacts(
|
|
|
28
|
+ tree=None,
|
|
|
29
|
+ substs={"MOZ_APP_VERSION": "140.0"},
|
|
|
30
|
+ defines={},
|
|
|
31
|
+ job=job,
|
|
|
32
|
+ log=self.log,
|
|
|
33
|
+ cache_dir=self._tmpdir.name,
|
|
|
34
|
+ git="git",
|
|
|
35
|
+ )
|
|
|
36
|
+
|
|
|
37
|
+ def test_install_from_tor_project_artifacts(self):
|
|
|
38
|
+ with mock.patch.object(
|
|
|
39
|
+ tbbutils,
|
|
|
40
|
+ "find_artifact_urls",
|
|
|
41
|
+ return_value=[f"{BASE_URL}/target.tar.xz", f"{BASE_URL}/target.zip"],
|
|
|
42
|
+ ), mock.patch.object(
|
|
|
43
|
+ self.artifacts, "install_from_url", return_value=0
|
|
|
44
|
+ ) as install_from_url:
|
|
|
45
|
+ self.assertEqual(
|
|
|
46
|
+ self.artifacts.install_from_tor_project_artifacts("dist"), 0
|
|
|
47
|
+ )
|
|
|
48
|
+
|
|
|
49
|
+ self.assertEqual(
|
|
|
50
|
+ install_from_url.call_args_list,
|
|
|
51
|
+ [
|
|
|
52
|
+ mock.call(f"{BASE_URL}/target.tar.xz", "dist"),
|
|
|
53
|
+ mock.call(f"{BASE_URL}/target.zip", "dist"),
|
|
|
54
|
+ ],
|
|
|
55
|
+ )
|
|
|
56
|
+
|
|
|
57
|
+ def test_install_from_tor_project_artifacts_stops_on_failure(self):
|
|
|
58
|
+ with mock.patch.object(
|
|
|
59
|
+ tbbutils,
|
|
|
60
|
+ "find_artifact_urls",
|
|
|
61
|
+ return_value=[f"{BASE_URL}/a.tar.xz", f"{BASE_URL}/b.tar.xz"],
|
|
|
62
|
+ ), mock.patch.object(
|
|
|
63
|
+ self.artifacts, "install_from_url", return_value=1
|
|
|
64
|
+ ) as install_from_url:
|
|
|
65
|
+ self.assertEqual(
|
|
|
66
|
+ self.artifacts.install_from_tor_project_artifacts("dist"), 1
|
|
|
67
|
+ )
|
|
|
68
|
+ self.assertEqual(install_from_url.call_count, 1)
|
|
|
69
|
+
|
|
|
70
|
+ def test_install_from_tor_project_artifacts_no_artifacts(self):
|
|
|
71
|
+ with mock.patch.object(
|
|
|
72
|
+ tbbutils, "find_artifact_urls", return_value=[]
|
|
|
73
|
+ ), mock.patch.object(self.artifacts, "install_from_url") as install_from_url:
|
|
|
74
|
+ with self.assertRaises(ValueError):
|
|
|
75
|
+ self.artifacts.install_from_tor_project_artifacts("dist")
|
|
|
76
|
+ install_from_url.assert_not_called()
|
|
|
77
|
+
|
|
|
78
|
+
|
|
|
79
|
+if __name__ == "__main__":
|
|
|
80
|
+ mozunit.main() |
python/mozbuild/mozbuild/test/test_tbbutils.py
| ... |
... |
@@ -4,9 +4,14 @@ from unittest.mock import MagicMock, patch |
|
4
|
4
|
|
|
5
|
5
|
import mozunit
|
|
6
|
6
|
|
|
|
7
|
+from mozbuild.artifacts import LinuxArtifactJob
|
|
7
|
8
|
from mozbuild.tbbutils import (
|
|
|
9
|
+ TOR_PROJECT_BROWSER_PREFIX,
|
|
|
10
|
+ TOR_PROJECT_TOOLCHAINS_URL,
|
|
|
11
|
+ find_artifact_urls,
|
|
8
|
12
|
get_artifact_index,
|
|
9
|
13
|
get_artifact_path,
|
|
|
14
|
+ get_artifacts_dir_url,
|
|
10
|
15
|
list_files_http,
|
|
11
|
16
|
)
|
|
12
|
17
|
|
| ... |
... |
@@ -140,6 +145,8 @@ class TestListFilesHttp(unittest.TestCase): |
|
140
|
145
|
html = b"""
|
|
141
|
146
|
<html><body>
|
|
142
|
147
|
<a href="">"../">Parent</a>
|
|
|
148
|
+ <a href="">"?C=N;O=D">Name</a>
|
|
|
149
|
+ <a href="">"/nightly-builds/toolchains/">Up</a>
|
|
143
|
150
|
<a href="">"file1.zip">file1</a>
|
|
144
|
151
|
<a href="">"file2.zip">file2</a>
|
|
145
|
152
|
</body></html>
|
| ... |
... |
@@ -173,5 +180,58 @@ class TestListFilesHttp(unittest.TestCase): |
|
173
|
180
|
)
|
|
174
|
181
|
|
|
175
|
182
|
|
|
|
183
|
+class TestTorProjectArtifacts(unittest.TestCase):
|
|
|
184
|
+ def test_get_artifacts_dir_url_for_each_job(self):
|
|
|
185
|
+ expected_targets = {
|
|
|
186
|
+ "android-arm-opt": "android-armeabi-v7a",
|
|
|
187
|
+ "android-aarch64-opt": "android-arm64-v8a",
|
|
|
188
|
+ "android-x86_64-debug": "android-x86_64",
|
|
|
189
|
+ "linux64-opt": "linux-x86_64",
|
|
|
190
|
+ "linux64-aarch64-opt": "linux-aarch64",
|
|
|
191
|
+ "macosx64-opt": "macos-x86_64",
|
|
|
192
|
+ "macosx64-aarch64-debug": "macos-aarch64",
|
|
|
193
|
+ "win32-opt": "windows-i686",
|
|
|
194
|
+ "win64-debug": "windows-x86_64",
|
|
|
195
|
+ }
|
|
|
196
|
+ for job, target in expected_targets.items():
|
|
|
197
|
+ with self.subTest(job=job):
|
|
|
198
|
+ self.assertEqual(
|
|
|
199
|
+ get_artifacts_dir_url(job, "140.0"),
|
|
|
200
|
+ f"{TOR_PROJECT_TOOLCHAINS_URL}/{TOR_PROJECT_BROWSER_PREFIX}-140.0/{target}",
|
|
|
201
|
+ )
|
|
|
202
|
+
|
|
|
203
|
+ def test_get_artifacts_dir_url_unknown_job(self):
|
|
|
204
|
+ with self.assertRaises(ValueError):
|
|
|
205
|
+ get_artifacts_dir_url("freebsd64-opt", "140.0")
|
|
|
206
|
+
|
|
|
207
|
+ @patch("mozbuild.tbbutils.list_files_http")
|
|
|
208
|
+ def test_find_artifact_urls(self, mock_list_files_http):
|
|
|
209
|
+ mock_list_files_http.return_value = [
|
|
|
210
|
+ "mozharness.zip",
|
|
|
211
|
+ "target.common.tests.tar.zst",
|
|
|
212
|
+ "target.mochitest.tests.tar.zst",
|
|
|
213
|
+ "target.tar.xz",
|
|
|
214
|
+ "target.xpt_artifacts.zip",
|
|
|
215
|
+ ]
|
|
|
216
|
+
|
|
|
217
|
+ urls = find_artifact_urls("linux64-opt", "140.0", LinuxArtifactJob())
|
|
|
218
|
+
|
|
|
219
|
+ base = f"{TOR_PROJECT_TOOLCHAINS_URL}/{TOR_PROJECT_BROWSER_PREFIX}-140.0/linux-x86_64"
|
|
|
220
|
+ mock_list_files_http.assert_called_once_with(f"{base}/")
|
|
|
221
|
+ self.assertEqual(
|
|
|
222
|
+ urls,
|
|
|
223
|
+ [
|
|
|
224
|
+ f"{base}/target.common.tests.tar.zst",
|
|
|
225
|
+ f"{base}/target.tar.xz",
|
|
|
226
|
+ f"{base}/target.xpt_artifacts.zip",
|
|
|
227
|
+ ],
|
|
|
228
|
+ )
|
|
|
229
|
+
|
|
|
230
|
+ @patch("mozbuild.tbbutils.list_files_http", return_value=["target.tar.xz"])
|
|
|
231
|
+ def test_find_artifact_urls_missing_tests(self, _):
|
|
|
232
|
+ with self.assertRaises(ValueError):
|
|
|
233
|
+ find_artifact_urls("linux64-opt", "140.0", LinuxArtifactJob())
|
|
|
234
|
+
|
|
|
235
|
+
|
|
176
|
236
|
if __name__ == "__main__":
|
|
177
|
237
|
mozunit.main() |
|