| ... |
... |
@@ -12,6 +12,7 @@ import sys |
|
12
|
12
|
import xml.etree.ElementTree as ET
|
|
13
|
13
|
|
|
14
|
14
|
from git import Repo
|
|
|
15
|
+from git.exc import GitCommandError
|
|
15
|
16
|
import requests
|
|
16
|
17
|
import ruamel.yaml
|
|
17
|
18
|
|
| ... |
... |
@@ -154,8 +155,12 @@ class ReleasePreparation: |
|
154
|
155
|
break
|
|
155
|
156
|
if remote is None:
|
|
156
|
157
|
raise RuntimeError("Cannot find the tpo/applications remote.")
|
|
157
|
|
- remote.fetch()
|
|
158
|
|
- remote.fetch(tags=True)
|
|
|
158
|
+
|
|
|
159
|
+ try:
|
|
|
160
|
+ remote.fetch()
|
|
|
161
|
+ remote.fetch(tags=True)
|
|
|
162
|
+ except GitCommandError:
|
|
|
163
|
+ logger.warning(f"Cannot fetch tags from {rem.url}, skipping.")
|
|
159
|
164
|
|
|
160
|
165
|
branch_name = (
|
|
161
|
166
|
"main" if self.version.is_alpha else f"maint-{self.version.major}"
|
| ... |
... |
@@ -165,7 +170,7 @@ class ReleasePreparation: |
|
165
|
170
|
if base != branch.commit:
|
|
166
|
171
|
raise RuntimeError(
|
|
167
|
172
|
"You are not working on a branch descending from "
|
|
168
|
|
- f"f{branch_name}. "
|
|
|
173
|
+ f"{branch_name}. "
|
|
169
|
174
|
"Please checkout the correct branch, or pull/rebase."
|
|
170
|
175
|
)
|
|
171
|
176
|
logger.debug("Sanity check succeeded.")
|
| ... |
... |
@@ -294,9 +299,7 @@ class ReleasePreparation: |
|
294
|
299
|
tag_info = None
|
|
295
|
300
|
for t in tags:
|
|
296
|
301
|
logger.debug("tag: %s", t.tag)
|
|
297
|
|
- m = re.match(
|
|
298
|
|
- rf"v{branch}-build(\d+)", t.tag
|
|
299
|
|
- )
|
|
|
302
|
+ m = re.match(rf"v{branch}-build(\d+)", t.tag)
|
|
300
|
303
|
if m:
|
|
301
|
304
|
logger.debug("Matched tag %s", t.tag)
|
|
302
|
305
|
tag_info = [int(m.group(1))]
|
| ... |
... |
@@ -336,51 +339,58 @@ class ReleasePreparation: |
|
336
|
339
|
logger.info("Updating addons")
|
|
337
|
340
|
config = self.load_config("browser")
|
|
338
|
341
|
|
|
339
|
|
- logger.debug("Updating NoScript")
|
|
340
|
|
- self.update_addon_amo(
|
|
|
342
|
+ self.update_addon_tpo(
|
|
341
|
343
|
config, "noscript", "{73a6fe31-595d-460b-a920-fcc0f8843232}"
|
|
342
|
344
|
)
|
|
343
|
345
|
if self.mullvad_browser:
|
|
344
|
|
- logger.debug("Updating uBlock Origin")
|
|
345
|
346
|
self.update_addon_amo(
|
|
346
|
347
|
config, "ublock-origin", "uBlock0@raymondhill.net"
|
|
347
|
348
|
)
|
|
348
|
|
- logger.debug("Updating the Mullvad Browser extension")
|
|
349
|
|
- self.update_mullvad_addon(config)
|
|
|
349
|
+ self.update_addon_any(
|
|
|
350
|
+ config,
|
|
|
351
|
+ "mullvad-extension",
|
|
|
352
|
+ "{d19a89b9-76c1-4a61-bcd4-49e8de916403}",
|
|
|
353
|
+ "https://cdn.mullvad.net/browser-extension/updates.json",
|
|
|
354
|
+ )
|
|
350
|
355
|
|
|
351
|
356
|
self.save_config("browser", config)
|
|
352
|
357
|
|
|
353
|
358
|
def update_addon_amo(self, config, name, addon_id):
|
|
354
|
|
- logger.debug("Checking updates for %s", name)
|
|
355
|
|
- r = requests.get(
|
|
356
|
|
- f"https://services.addons.mozilla.org/api/v4/addons/addon/{addon_id}"
|
|
|
359
|
+ self.update_addon_any(
|
|
|
360
|
+ config,
|
|
|
361
|
+ name,
|
|
|
362
|
+ addon_id,
|
|
|
363
|
+ f"https://services.addons.mozilla.org/api/v4/addons/addon/{addon_id}",
|
|
357
|
364
|
)
|
|
358
|
|
- r.raise_for_status()
|
|
359
|
|
- amo_data = r.json()
|
|
360
|
|
- addon = amo_data["current_version"]["files"][0]
|
|
361
|
|
- assert addon["hash"].startswith("sha256:")
|
|
362
|
|
- addon_input = self.find_input(config, name)
|
|
363
|
|
- addon_input["URL"] = addon["url"]
|
|
364
|
|
- addon_input["sha256sum"] = addon["hash"][7:]
|
|
365
|
|
-
|
|
366
|
|
- def update_mullvad_addon(self, config):
|
|
367
|
|
- logger.debug("Checking updates for the Mullvad addon")
|
|
368
|
|
- input_ = self.find_input(config, "mullvad-extension")
|
|
369
|
|
- r = requests.get(
|
|
370
|
|
- "https://cdn.mullvad.net/browser-extension/updates.json"
|
|
|
365
|
+
|
|
|
366
|
+ def update_addon_tpo(self, config, name, addon_id):
|
|
|
367
|
+ channel = "pre" if self.version.is_alpha else "stable"
|
|
|
368
|
+ self.update_addon_any(
|
|
|
369
|
+ config,
|
|
|
370
|
+ name,
|
|
|
371
|
+ addon_id,
|
|
|
372
|
+ f"https://dist.torproject.org/torbrowser/{name}/update-{channel}.json",
|
|
371
|
373
|
)
|
|
372
|
|
- r.raise_for_status()
|
|
373
|
374
|
|
|
|
375
|
+ def update_addon_any(self, config, name, addon_id, updates_url):
|
|
|
376
|
+ logger.debug("Checking updates for addon %s", name)
|
|
|
377
|
+ r = requests.get(updates_url)
|
|
|
378
|
+ r.raise_for_status()
|
|
374
|
379
|
data = r.json()
|
|
375
|
|
- updates = data["addons"]["{d19a89b9-76c1-4a61-bcd4-49e8de916403}"][
|
|
376
|
|
- "updates"
|
|
377
|
|
- ]
|
|
378
|
|
- url = updates[-1]["update_link"]
|
|
|
380
|
+ input_ = self.find_input(config, name)
|
|
|
381
|
+ if "current_version" in data:
|
|
|
382
|
+ # AMO matadata
|
|
|
383
|
+ addon = data["current_version"]["files"][0]
|
|
|
384
|
+ assert addon["hash"].startswith("sha256:")
|
|
|
385
|
+ input_["URL"] = addon["url"]
|
|
|
386
|
+ input_["sha256sum"] = addon["hash"][7:]
|
|
|
387
|
+ return
|
|
|
388
|
+ # self-hosted standalone updates.json
|
|
|
389
|
+ url = data["addons"][addon_id]["updates"][-1]["update_link"]
|
|
379
|
390
|
if input_["URL"] == url:
|
|
380
|
|
- logger.debug("No need to update the Mullvad extension.")
|
|
|
391
|
+ logger.debug("No need to update the %s extension.", name)
|
|
381
|
392
|
return
|
|
382
|
393
|
input_["URL"] = url
|
|
383
|
|
-
|
|
384
|
394
|
path = self.base_path / "out/browser" / url.split("/")[-1]
|
|
385
|
395
|
# The extension should be small enough to easily fit in memory :)
|
|
386
|
396
|
if not path.exists():
|
| ... |
... |
@@ -390,7 +400,7 @@ class ReleasePreparation: |
|
390
|
400
|
f.write(r.content)
|
|
391
|
401
|
with path.open("rb") as f:
|
|
392
|
402
|
input_["sha256sum"] = sha256(f.read()).hexdigest()
|
|
393
|
|
- logger.debug("Mullvad extension downloaded and updated")
|
|
|
403
|
+ logger.debug("%s extension downloaded and updated.", name)
|
|
394
|
404
|
|
|
395
|
405
|
def update_tor(self):
|
|
396
|
406
|
logger.info("Updating Tor")
|