brizental pushed to branch mullvad-browser-147.0a1-16.0-2 at The Tor Project / Applications / Mullvad Browser

Commits:

5 changed files:

Changes:

  • build/moz.configure/basebrowser-resources.configure
    ... ... @@ -27,7 +27,7 @@ option(
    27 27
             "noscript", no_unpack=True, when=depends("--with-noscript")(lambda x: not x)
    
    28 28
         ),
    
    29 29
     )
    
    30
    -@checking("for noscript")
    
    30
    +@checking("for noscript extension")
    
    31 31
     @imports(_from="pathlib", _import="Path")
    
    32 32
     def noscript(value, mozbuild_state_path, _bootstrapped):
    
    33 33
         if value:
    
    ... ... @@ -49,6 +49,84 @@ def noscript(value, mozbuild_state_path, _bootstrapped):
    49 49
     set_config("NOSCRIPT", noscript)
    
    50 50
     
    
    51 51
     
    
    52
    +option(
    
    53
    +    "--with-ublock",
    
    54
    +    env="UBLOCK",
    
    55
    +    nargs=1,
    
    56
    +    default=None,
    
    57
    +    help="Path to ublock .xpi extension archive.",
    
    58
    +)
    
    59
    +
    
    60
    +
    
    61
    +@depends(
    
    62
    +    "--with-ublock",
    
    63
    +    mozbuild_state_path,
    
    64
    +    bootstrap_path(
    
    65
    +        "ublock", no_unpack=True, when=depends("--with-ublock")(lambda x: not x)
    
    66
    +    ),
    
    67
    +)
    
    68
    +@checking("for ublock extension")
    
    69
    +@imports(_from="pathlib", _import="Path")
    
    70
    +def ublock(value, mozbuild_state_path, _bootstrapped):
    
    71
    +    if value:
    
    72
    +        path = Path(value[0])
    
    73
    +        if path.is_file() and path.suffix == ".xpi":
    
    74
    +            return value[0]
    
    75
    +        else:
    
    76
    +            die("--with-ublock must be an existing .xpi file")
    
    77
    +
    
    78
    +    bootstrapped_location = Path(mozbuild_state_path) / "browser"
    
    79
    +    for file in bootstrapped_location.glob(f"*.xpi"):
    
    80
    +        if "ublock" in file.name:
    
    81
    +            return str(bootstrapped_location / file)
    
    82
    +
    
    83
    +    # ublock is not required for building.
    
    84
    +    return None
    
    85
    +
    
    86
    +
    
    87
    +set_config("UBLOCK", ublock)
    
    88
    +
    
    89
    +
    
    90
    +option(
    
    91
    +    "--with-mullvad-extension",
    
    92
    +    env="MULLVAD_EXTENSION",
    
    93
    +    nargs=1,
    
    94
    +    default=None,
    
    95
    +    help="Path to mullvad extension .xpi extension archive.",
    
    96
    +)
    
    97
    +
    
    98
    +
    
    99
    +@depends(
    
    100
    +    "--with-mullvad-extension",
    
    101
    +    mozbuild_state_path,
    
    102
    +    bootstrap_path(
    
    103
    +        "mullvad-browser-extension",
    
    104
    +        no_unpack=True,
    
    105
    +        when=depends("--with-mullvad-extension")(lambda x: not x),
    
    106
    +    ),
    
    107
    +)
    
    108
    +@checking("for mullvad extension")
    
    109
    +@imports(_from="pathlib", _import="Path")
    
    110
    +def mullvad_extension(value, mozbuild_state_path, _bootstrapped):
    
    111
    +    if value:
    
    112
    +        path = Path(value[0])
    
    113
    +        if path.is_file() and path.suffix == ".xpi":
    
    114
    +            return value[0]
    
    115
    +        else:
    
    116
    +            die("--with-mullvad-extension must be an existing .xpi file")
    
    117
    +
    
    118
    +    bootstrapped_location = Path(mozbuild_state_path) / "browser"
    
    119
    +    for file in bootstrapped_location.glob(f"*.xpi"):
    
    120
    +        if "mullvad-browser-extension" in file.name:
    
    121
    +            return str(bootstrapped_location / file)
    
    122
    +
    
    123
    +    # mullvad extension is not required for building.
    
    124
    +    return None
    
    125
    +
    
    126
    +
    
    127
    +set_config("MULLVAD_EXTENSION", mullvad_extension)
    
    128
    +
    
    129
    +
    
    52 130
     option(
    
    53 131
         "--with-tor-browser-fonts",
    
    54 132
         env="TOR_BROWSER_FONTS",
    

  • build/moz.configure/bootstrap.configure
    ... ... @@ -197,8 +197,12 @@ def bootstrap_path(path, **kwargs):
    197 197
             if path_parts[0] == "clang-tools":
    
    198 198
                 path_prefix = path_parts.pop(0)
    
    199 199
     
    
    200
    -        # Small hack because noscript is inside the browser folder.
    
    201
    -        if path_parts[0] == "noscript":
    
    200
    +        # Small hack because extensions are inside the browser folder.
    
    201
    +        if path_parts[0] in (
    
    202
    +            "noscript",
    
    203
    +            "ublock",
    
    204
    +            "mullvad-browser-extension",
    
    205
    +        ):
    
    202 206
                 path_prefix = "browser"
    
    203 207
     
    
    204 208
             def try_tbb_bootstrap(exists):
    

  • python/mozboot/mozboot/bootstrap.py
    ... ... @@ -49,28 +49,28 @@ Note on Artifact Mode:
    49 49
     Artifact builds download prebuilt C++ components rather than building
    
    50 50
     them locally. Artifact builds are faster!
    
    51 51
     
    
    52
    -Artifact builds are recommended for people working on Tor Browser or
    
    52
    +Artifact builds are recommended for people working on Mullvad Browser or
    
    53 53
     Base Browser for Android frontends, or the GeckoView Java API. They are unsuitable
    
    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 Base Browser developers
    
    57
    +# Note to Mullvad Browser developers
    
    58 58
     
    
    59 59
     This is still highly experimental. Expect bugs!
    
    60 60
     
    
    61
    -Please choose the version of Base Browser you want to build (see note above):
    
    61
    +Please choose the version of Mullvad Browser you want to build (see note above):
    
    62 62
     %s
    
    63 63
     Your choice: """
    
    64 64
     
    
    65 65
     APPLICATIONS = OrderedDict(
    
    66 66
         [
    
    67
    -        ("Base Browser for Desktop Artifact Mode", "browser_artifact_mode"),
    
    68
    -        ("Base Browser for Desktop", "browser"),
    
    67
    +        ("Mullvad Browser for Desktop Artifact Mode", "browser_artifact_mode"),
    
    68
    +        ("Mullvad Browser for Desktop", "browser"),
    
    69 69
             (
    
    70
    -            "GeckoView/Base Browser for Android Artifact Mode",
    
    70
    +            "GeckoView/Mullvad Browser for Android Artifact Mode",
    
    71 71
                 "mobile_android_artifact_mode",
    
    72 72
             ),
    
    73
    -        ("GeckoView/Base Browser for Android", "mobile_android"),
    
    73
    +        ("GeckoView/Mullvad Browser for Android", "mobile_android"),
    
    74 74
             ("SpiderMonkey JavaScript engine", "js"),
    
    75 75
         ]
    
    76 76
     )
    

  • python/mozbuild/mozbuild/backend/base.py
    ... ... @@ -243,22 +243,47 @@ 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
    
    282
    +        ublock_target_filename = "uBlock0@raymondhill.net.xpi"
    
    283
    +        ublock_location = config.substs.get("UBLOCK")
    
    284
    +
    
    285
    +        mullvad_extension_target_filename = "{d19a89b9-76c1-4a61-bcd4-49e8de916403}.xpi"
    
    286
    +        mullvad_extension_location = config.substs.get("MULLVAD_EXTENSION")
    
    262 287
     
    
    263 288
             if app == "browser":
    
    264 289
                 tbdir = Path(config.topobjdir) / "dist" / "bin"
    
    ... ... @@ -281,7 +306,7 @@ class BuildBackend(LoggingMixin):
    281 306
                 if fonts_location:
    
    282 307
                     self.log(
    
    283 308
                         logging.INFO,
    
    284
    -                    "_setup_tor_browser_environment",
    
    309
    +                    "_setup_base_browser_environment",
    
    285 310
                         {
    
    286 311
                             "fonts_location": fonts_location,
    
    287 312
                             "fonts_target": str(paths["fonts"]),
    
    ... ... @@ -291,23 +316,25 @@ class BuildBackend(LoggingMixin):
    291 316
     
    
    292 317
                     for file in Path(fonts_location).iterdir():
    
    293 318
                         target = paths["fonts"] / file.name
    
    294
    -                    _infallible_symlink(file, target)
    
    319
    +                    self._create_or_replace_symlink(file, target)
    
    295 320
     
    
    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
    -                )
    
    321
    +            self._setup_extension_symlink(
    
    322
    +                noscript_location,
    
    323
    +                noscript_target_filename,
    
    324
    +                paths["exts"],
    
    325
    +            )
    
    308 326
     
    
    309
    -                paths["exts"].mkdir(parents=True, exist_ok=True)
    
    310
    -                _infallible_symlink(noscript_location, noscript_target)
    
    327
    +            self._setup_extension_symlink(
    
    328
    +                ublock_location,
    
    329
    +                ublock_target_filename,
    
    330
    +                paths["exts"],
    
    331
    +            )
    
    332
    +
    
    333
    +            self._setup_extension_symlink(
    
    334
    +                mullvad_extension_location,
    
    335
    +                mullvad_extension_target_filename,
    
    336
    +                paths["exts"],
    
    337
    +            )
    
    311 338
     
    
    312 339
         def post_build(self, config, output, jobs, verbose, status):
    
    313 340
             """Called late during 'mach build' execution, after `build(...)` has finished.
    
    ... ... @@ -328,7 +355,7 @@ class BuildBackend(LoggingMixin):
    328 355
             self._write_purgecaches(config)
    
    329 356
     
    
    330 357
             if status == 0:
    
    331
    -            self._setup_tor_browser_environment(config)
    
    358
    +            self._setup_base_browser_environment(config)
    
    332 359
     
    
    333 360
             return status
    
    334 361
     
    

  • python/mozbuild/mozbuild/tbbutils.py
    ... ... @@ -22,10 +22,12 @@ def list_files_http(url):
    22 22
         return links
    
    23 23
     
    
    24 24
     
    
    25
    -TOR_BROWSER_BUILD_ARTIFACTS = [
    
    26
    -    # Tor Browser Build-only artifacts, these artifacts are not common with Firefox.
    
    25
    +MULLVAD_BROWSER_BUILD_ARTIFACTS = [
    
    26
    +    # Mullvad Browser Build-only artifacts, these artifacts are not common with Firefox.
    
    27
    +    "mullvad-browser-extension",
    
    27 28
         "noscript",
    
    28 29
         "fonts",
    
    30
    +    "ublock",
    
    29 31
     ]
    
    30 32
     
    
    31 33
     # Mapping of artifacts from taskcluster to tor-browser-build.
    
    ... ... @@ -55,7 +57,7 @@ def get_artifact_index(artifact_path):
    55 57
     def get_artifact_name(original_artifact_name, host):
    
    56 58
         # These are not build artifacts, they are pre-built artifacts to be added to the final build,
    
    57 59
         # therefore this check can come before the host check.
    
    58
    -    if original_artifact_name in TOR_BROWSER_BUILD_ARTIFACTS:
    
    60
    +    if original_artifact_name in MULLVAD_BROWSER_BUILD_ARTIFACTS:
    
    59 61
             return original_artifact_name
    
    60 62
     
    
    61 63
         if host != "linux64":