| ... |
... |
@@ -243,23 +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
|
|
- return
|
|
262
|
|
-
|
|
263
|
282
|
if app == "browser":
|
|
264
|
283
|
tbdir = Path(config.topobjdir) / "dist" / "bin"
|
|
265
|
284
|
|
| ... |
... |
@@ -281,7 +300,7 @@ class BuildBackend(LoggingMixin): |
|
281
|
300
|
if fonts_location:
|
|
282
|
301
|
self.log(
|
|
283
|
302
|
logging.INFO,
|
|
284
|
|
- "_setup_tor_browser_environment",
|
|
|
303
|
+ "_setup_base_browser_environment",
|
|
285
|
304
|
{
|
|
286
|
305
|
"fonts_location": fonts_location,
|
|
287
|
306
|
"fonts_target": str(paths["fonts"]),
|
| ... |
... |
@@ -291,23 +310,13 @@ class BuildBackend(LoggingMixin): |
|
291
|
310
|
|
|
292
|
311
|
for file in Path(fonts_location).iterdir():
|
|
293
|
312
|
target = paths["fonts"] / file.name
|
|
294
|
|
- _infallible_symlink(file, target)
|
|
295
|
|
-
|
|
296
|
|
- # Set up NoScript extension
|
|
297
|
|
- if noscript_location:
|
|
298
|
|
- noscript_target = paths["exts"] / noscript_target_filename
|
|
299
|
|
- self.log(
|
|
300
|
|
- logging.INFO,
|
|
301
|
|
- "_setup_tor_browser_environment",
|
|
302
|
|
- {
|
|
303
|
|
- "noscript_location": noscript_location,
|
|
304
|
|
- "noscript_target": str(noscript_target),
|
|
305
|
|
- },
|
|
306
|
|
- "Creating symlink for NoScript from {noscript_location} to {noscript_target}",
|
|
307
|
|
- )
|
|
|
313
|
+ self._create_or_replace_symlink(file, target)
|
|
308
|
314
|
|
|
309
|
|
- paths["exts"].mkdir(parents=True, exist_ok=True)
|
|
310
|
|
- _infallible_symlink(noscript_location, noscript_target)
|
|
|
315
|
+ self._setup_extension_symlink(
|
|
|
316
|
+ noscript_location,
|
|
|
317
|
+ noscript_target_filename,
|
|
|
318
|
+ paths["exts"],
|
|
|
319
|
+ )
|
|
311
|
320
|
|
|
312
|
321
|
def post_build(self, config, output, jobs, verbose, status):
|
|
313
|
322
|
"""Called late during 'mach build' execution, after `build(...)` has finished.
|
| ... |
... |
@@ -328,7 +337,7 @@ class BuildBackend(LoggingMixin): |
|
328
|
337
|
self._write_purgecaches(config)
|
|
329
|
338
|
|
|
330
|
339
|
if status == 0:
|
|
331
|
|
- self._setup_tor_browser_environment(config)
|
|
|
340
|
+ self._setup_base_browser_environment(config)
|
|
332
|
341
|
|
|
333
|
342
|
return status
|
|
334
|
343
|
|