| ... |
... |
@@ -6,6 +6,7 @@ import time |
|
6
|
6
|
import urllib.request
|
|
7
|
7
|
import zipfile
|
|
8
|
8
|
from pathlib import Path
|
|
|
9
|
+import re
|
|
9
|
10
|
|
|
10
|
11
|
SPECULATIVE_DOWNLOAD_RETRY_ATTEMPTS = 3
|
|
11
|
12
|
SPECULATIVE_DOWNLOAD_RETRY_DELAY = 300 # 5min
|
| ... |
... |
@@ -14,6 +15,10 @@ SPECULATIVE_DOWNLOAD_RETRY_DELAY = 300 # 5min |
|
14
|
15
|
# expects the emulator to have a this exact android version.
|
|
15
|
16
|
EMULATOR_ANDROID_VERSION = 34
|
|
16
|
17
|
|
|
|
18
|
+TOR_BROWSER_BUILD_OUT = (
|
|
|
19
|
+ "https://tb-build-06.torproject.org/~tb-builder/tor-browser-build/out"
|
|
|
20
|
+)
|
|
|
21
|
+
|
|
17
|
22
|
|
|
18
|
23
|
def download_file(url: str, dest: Path, sha256: str = "") -> None:
|
|
19
|
24
|
print(f"Downloading {url} -> {dest}")
|
| ... |
... |
@@ -77,15 +82,27 @@ def download_minidump_stackwalk( |
|
77
|
82
|
print(f"Extracted minidump-stackwalk -> {dest_dir}")
|
|
78
|
83
|
|
|
79
|
84
|
|
|
80
|
|
-def setup_android_sdk(
|
|
81
|
|
- moz_fetches_dir: str,
|
|
82
|
|
- android_sdk_repack_url: str,
|
|
83
|
|
-) -> None:
|
|
|
85
|
+def get_android_sdk_repack_url():
|
|
|
86
|
+ url = f"{TOR_BROWSER_BUILD_OUT}/android-sdk?C=M;O=D"
|
|
|
87
|
+ req = urllib.request.Request(url, method="GET")
|
|
|
88
|
+ with urllib.request.urlopen(req) as response:
|
|
|
89
|
+ html = response.read().decode()
|
|
|
90
|
+ found = re.search(
|
|
|
91
|
+ r'<a href="">"(android-sdk-[^"]+\.tar\.zst)"',
|
|
|
92
|
+ html,
|
|
|
93
|
+ )
|
|
|
94
|
+ if not found:
|
|
|
95
|
+ raise RuntimeError(f"Could not find android-sdk tarball URL in {url}")
|
|
|
96
|
+
|
|
|
97
|
+ return f"{url}/{found.group(1)}"
|
|
|
98
|
+
|
|
|
99
|
+
|
|
|
100
|
+def setup_android_sdk(moz_fetches_dir: str) -> None:
|
|
84
|
101
|
android_sdk_dir = Path(moz_fetches_dir) / "android-sdk-linux"
|
|
85
|
102
|
android_sdk_dir.mkdir(parents=True, exist_ok=True)
|
|
86
|
103
|
|
|
87
|
104
|
tar_zst_path = Path("android-sdk.tar.zst")
|
|
88
|
|
- download_file(android_sdk_repack_url, tar_zst_path)
|
|
|
105
|
+ download_file(get_android_sdk_repack_url(), tar_zst_path)
|
|
89
|
106
|
extract_tar(tar_zst_path, android_sdk_dir)
|
|
90
|
107
|
|
|
91
|
108
|
# Remove fake emulator binary added by tor-browser-build
|
| ... |
... |
@@ -139,7 +156,7 @@ def before_script( |
|
139
|
156
|
minidump_stackwalk_sha256: str,
|
|
140
|
157
|
moz_fetches_dir: str,
|
|
141
|
158
|
sha256sums_url: str = "",
|
|
142
|
|
- android_sdk_repack_url: str = "",
|
|
|
159
|
+ setup_android: bool = False,
|
|
143
|
160
|
) -> None:
|
|
144
|
161
|
check_sha256sums_url(sha256sums_url)
|
|
145
|
162
|
download_mozharness(mozharness_url)
|
| ... |
... |
@@ -147,11 +164,8 @@ def before_script( |
|
147
|
164
|
minidump_stackwalk_url, moz_fetches_dir, minidump_stackwalk_sha256
|
|
148
|
165
|
)
|
|
149
|
166
|
|
|
150
|
|
- if android_sdk_repack_url:
|
|
151
|
|
- setup_android_sdk(
|
|
152
|
|
- moz_fetches_dir,
|
|
153
|
|
- android_sdk_repack_url,
|
|
154
|
|
- )
|
|
|
167
|
+ if setup_android:
|
|
|
168
|
+ setup_android_sdk(moz_fetches_dir)
|
|
155
|
169
|
|
|
156
|
170
|
|
|
157
|
171
|
if __name__ == "__main__":
|
| ... |
... |
@@ -161,6 +175,5 @@ if __name__ == "__main__": |
|
161
|
175
|
minidump_stackwalk_sha256=os.environ.get("MINIDUMP_STACKWALK_SHA256", ""),
|
|
162
|
176
|
moz_fetches_dir=os.environ["MOZ_FETCHES_DIR"],
|
|
163
|
177
|
sha256sums_url=os.environ.get("SHA256SUMS_URL", ""),
|
|
164
|
|
- # Android-only stuff.
|
|
165
|
|
- android_sdk_repack_url=os.environ.get("ANDROID_SDK_REPACK_URL", ""),
|
|
|
178
|
+ setup_android="SETUP_ANDROID_SDK" in os.environ,
|
|
166
|
179
|
) |