| ... |
... |
@@ -243,29 +243,42 @@ class BuildBackend(LoggingMixin): |
|
243
|
243
|
with open(mozpath.join(dir, ".purgecaches"), "w") as f:
|
|
244
|
244
|
f.write("\n")
|
|
245
|
245
|
|
|
246
|
|
- def _setup_tor_browser_environment(self, config):
|
|
|
246
|
+ def _create_or_replace_symlink(self, src, dst):
|
|
|
247
|
+ try:
|
|
|
248
|
+ os.symlink(src, dst)
|
|
|
249
|
+ except OSError as e:
|
|
|
250
|
+ if e.errno == errno.EEXIST:
|
|
|
251
|
+ # If the symlink already exists, remove it and try again.
|
|
|
252
|
+ os.remove(dst)
|
|
|
253
|
+ os.symlink(src, dst)
|
|
|
254
|
+ else:
|
|
|
255
|
+ return
|
|
|
256
|
+
|
|
|
257
|
+ def _setup_extension_symlink(self, location, target_filename, exts_path):
|
|
|
258
|
+ if not location:
|
|
|
259
|
+ return
|
|
|
260
|
+
|
|
|
261
|
+ target = exts_path / target_filename
|
|
|
262
|
+
|
|
|
263
|
+ self.log(
|
|
|
264
|
+ logging.INFO,
|
|
|
265
|
+ "_setup_extension_symlink",
|
|
|
266
|
+ {
|
|
|
267
|
+ "location": location,
|
|
|
268
|
+ "target": str(target),
|
|
|
269
|
+ },
|
|
|
270
|
+ "Creating symlink for extension from {location} to {target}",
|
|
|
271
|
+ )
|
|
|
272
|
+
|
|
|
273
|
+ exts_path.mkdir(parents=True, exist_ok=True)
|
|
|
274
|
+ self._create_or_replace_symlink(location, target)
|
|
|
275
|
+
|
|
|
276
|
+ def _setup_base_browser_environment(self, config):
|
|
247
|
277
|
app = config.substs["MOZ_BUILD_APP"]
|
|
248
|
278
|
|
|
249
|
279
|
noscript_target_filename = "{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
|
|
250
|
280
|
noscript_location = config.substs.get("NOSCRIPT")
|
|
251
|
281
|
|
|
252
|
|
- def _infallible_symlink(src, dst):
|
|
253
|
|
- try:
|
|
254
|
|
- os.symlink(src, dst)
|
|
255
|
|
- except OSError as e:
|
|
256
|
|
- if e.errno == errno.EEXIST:
|
|
257
|
|
- # If the symlink already exists, remove it and try again.
|
|
258
|
|
- os.remove(dst)
|
|
259
|
|
- os.symlink(src, dst)
|
|
260
|
|
- else:
|
|
261
|
|
- self.log(
|
|
262
|
|
- logging.ERROR,
|
|
263
|
|
- "_setup_tor_browser_environment",
|
|
264
|
|
- {},
|
|
265
|
|
- "Error creating symlink.",
|
|
266
|
|
- )
|
|
267
|
|
- return
|
|
268
|
|
-
|
|
269
|
282
|
if app == "mobile/android":
|
|
270
|
283
|
# Set up NoScript extension
|
|
271
|
284
|
# We put it in the srcdir... It will be moved to the APK in the gradle build.
|
| ... |
... |
@@ -312,7 +325,7 @@ class BuildBackend(LoggingMixin): |
|
312
|
325
|
if fonts_location:
|
|
313
|
326
|
self.log(
|
|
314
|
327
|
logging.INFO,
|
|
315
|
|
- "_setup_tor_browser_environment",
|
|
|
328
|
+ "_setup_base_browser_environment",
|
|
316
|
329
|
{
|
|
317
|
330
|
"fonts_location": fonts_location,
|
|
318
|
331
|
"fonts_target": str(paths["fonts"]),
|
| ... |
... |
@@ -322,23 +335,13 @@ class BuildBackend(LoggingMixin): |
|
322
|
335
|
|
|
323
|
336
|
for file in Path(fonts_location).iterdir():
|
|
324
|
337
|
target = paths["fonts"] / file.name
|
|
325
|
|
- _infallible_symlink(file, target)
|
|
|
338
|
+ self._create_or_replace_symlink(file, target)
|
|
326
|
339
|
|
|
327
|
|
- # Set up NoScript extension
|
|
328
|
|
- if noscript_location:
|
|
329
|
|
- noscript_target = paths["exts"] / noscript_target_filename
|
|
330
|
|
- self.log(
|
|
331
|
|
- logging.INFO,
|
|
332
|
|
- "_setup_tor_browser_environment",
|
|
333
|
|
- {
|
|
334
|
|
- "noscript_location": noscript_location,
|
|
335
|
|
- "noscript_target": str(noscript_target),
|
|
336
|
|
- },
|
|
337
|
|
- "Creating symlink for NoScript from {noscript_location} to {noscript_target}",
|
|
338
|
|
- )
|
|
339
|
|
-
|
|
340
|
|
- paths["exts"].mkdir(parents=True, exist_ok=True)
|
|
341
|
|
- _infallible_symlink(noscript_location, noscript_target)
|
|
|
340
|
+ self._setup_extension_symlink(
|
|
|
341
|
+ noscript_location,
|
|
|
342
|
+ noscript_target_filename,
|
|
|
343
|
+ paths["exts"],
|
|
|
344
|
+ )
|
|
342
|
345
|
|
|
343
|
346
|
expert_bundle_location = config.substs.get("TOR_EXPERT_BUNDLE")
|
|
344
|
347
|
if expert_bundle_location:
|
| ... |
... |
@@ -417,7 +420,7 @@ class BuildBackend(LoggingMixin): |
|
417
|
420
|
self._write_purgecaches(config)
|
|
418
|
421
|
|
|
419
|
422
|
if status == 0:
|
|
420
|
|
- self._setup_tor_browser_environment(config)
|
|
|
423
|
+ self._setup_base_browser_environment(config)
|
|
421
|
424
|
|
|
422
|
425
|
return status
|
|
423
|
426
|
|