Commit cd496985 authored by brizental's avatar brizental
Browse files

fixup! TB 43564: Modify ./mach bootstrap for Tor Browser

parent b6bca4e5
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -226,7 +226,9 @@ def bootstrap_path(path, **kwargs):
                log.info("no path found in tbb/out for %s", artifact)
                return False

            artifact_index = mozbuild.tbbutils.get_artifact_index(artifact_path)
            artifact_index = mozbuild.tbbutils.get_artifact_index(
                artifact_path, artifact
            )
            index_file = os.path.join(toolchains_base_dir, "indices", artifact)
            try:
                with open(index_file) as fh:
+1 −1
Original line number Diff line number Diff line
@@ -330,7 +330,7 @@ class BuildBackend(LoggingMixin):

                # Set up Tor configuration files
                paths["tor_config"].mkdir(parents=True, exist_ok=True)
                for file in ["geoip", "geoip6"]:
                for file in ["geoip", "geoip6", "torrc-defaults"]:
                    target = paths["tor_config"] / file
                    _infallible_symlink(expert_bundle_location / "data" / file, target)

+8 −3
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ def list_files_http(url):
            continue

        if "tor-expert-bundle" in href:
            href = f"{href}/tor-expert-bundle.tar.gz"
            href = f"{href.rstrip('/')}/tor-expert-bundle.tar.gz"

        links.append(href)

@@ -45,14 +45,19 @@ ARTIFACT_NAME_MAP = {
}


def get_artifact_index(artifact_path):
def get_artifact_index(artifact_path, artifact):
    """
    Return a unique identifier for the given artifact based on its path.

    In most cases, artifacts built by tor-browser-build include part of their
    SHA sum or version in the filename, so the file name itself serves as a unique
    identifier.
    identifier. However, some artifacts are stored within subfolders where the file
    name alone is not unique — in those cases, the name of the parent directory
    provides the unique identifier instead.
    """
    if artifact in ["tor-expert-bundle"]:
        return artifact_path.rsplit("/", 2)[-2]

    return artifact_path.rsplit("/", 1)[-1]


+8 −1
Original line number Diff line number Diff line
@@ -36,9 +36,16 @@ class TestGetArtifactName(unittest.TestCase):

class TestGetArtifactIndex(unittest.TestCase):
    def test_regular_artifact(self):
        artifact = "tor"
        path = "https://tb-build-06.torproject.org/~tb-builder/tor-browser-build/out/tor/tor-b1f9824464dc-linux-x86_64-b0ffe2.tar.gz"
        expected = "tor-b1f9824464dc-linux-x86_64-b0ffe2.tar.gz"
        self.assertEqual(get_artifact_index(path), expected)
        self.assertEqual(get_artifact_index(path, artifact), expected)

    def test_expert_bundle_artifact(self):
        artifact = "tor-expert-bundle"
        path = "https://tb-build-06.torproject.org/~tb-builder/tor-browser-build/out/tor-expert-bundle/tor-expert-bundle-linux-x86_64-tbb-nightly.2025.10.14-d9aa09/"
        expected = "tor-expert-bundle-linux-x86_64-tbb-nightly.2025.10.14-d9aa09"
        self.assertEqual(get_artifact_index(path, artifact), expected)


class TestGetArtifactPath(unittest.TestCase):