0
Fork 0
mirror of https://codeberg.org/librewolf/source.git synced 2024-12-22 05:33:03 -05:00
LibreWolf/patches/bootstrap-without-vcs.patch

164 lines
5.1 KiB
Diff
Raw Normal View History

2023-01-18 18:07:26 -05:00
# LibreWolf bootstrap-without-vcs.patch
#
# Author: Malte Jürgens <maltejur@dismail.de>
# Description: Allow mach bootstrapping without a VCS checkout
2023-03-15 05:41:39 -05:00
# Last Updated: 2023-03-15
2023-01-18 18:07:26 -05:00
# License: MPL 2.0
#
# This patch allows you to use `./mach bootstrap` without a VCS checkout.
# You can use that command to bootstrap a Firefox build environment.
# This patch works by adding a stub `LocalRepository`, which suprisingly
# is enough to make the bootstrapping process work. This may break other
# things in mach, but we don't use those.
2022-02-02 15:09:37 -05:00
--- a/python/mozboot/mozboot/bootstrap.py
+++ b/python/mozboot/mozboot/bootstrap.py
2023-03-15 05:41:39 -05:00
@@ -628,10 +628,7 @@ def current_firefox_checkout(env, hg: Optional[Path] = None):
2022-02-02 15:09:37 -05:00
break
path = path.parent
2022-02-02 15:09:37 -05:00
- raise UserError(
- "Could not identify the root directory of your checkout! "
- "Are you running `mach bootstrap` in an hg or git clone?"
- )
+ return ("local", Path.cwd())
2022-02-02 15:09:37 -05:00
def update_git_tools(git: Optional[Path], root_state_dir: Path):
2022-02-02 15:09:37 -05:00
--- a/python/mozversioncontrol/mozversioncontrol/__init__.py
+++ b/python/mozversioncontrol/mozversioncontrol/__init__.py
2023-03-15 05:41:39 -05:00
@@ -744,6 +744,29 @@ class GitRepository(Repository):
2022-02-02 15:09:37 -05:00
self._run("config", name, value)
+class LocalRepository(Repository):
+
+ def __init__(self, path):
+ super(LocalRepository, self).__init__(path, tool="true")
+
+ @property
+ def head_ref(self):
+ return ""
+
2022-02-11 13:49:05 -05:00
+ def get_outgoing_files(self):
+ return []
+
+ def get_changed_files(self):
+ return []
+
2022-02-02 15:09:37 -05:00
+ def get_tracked_files_finder(self):
2022-02-11 13:49:05 -05:00
+ files = [os.path.relpath(os.path.join(dp, f), self.path).replace("\\","/") for dp, dn, fn in os.walk(self.path) for f in fn]
2022-02-02 15:09:37 -05:00
+ files.sort()
+ return FileListFinder(files)
+
+
+
+
def get_repository_object(path: Optional[Union[str, Path]], hg="hg", git="git"):
2022-02-02 15:09:37 -05:00
"""Get a repository object for the repository at `path`.
If `path` is not a known VCS repository, raise an exception.
2023-03-15 05:41:39 -05:00
@@ -757,7 +780,7 @@ def get_repository_object(path: Optional[Union[str, Path]], hg="hg", git="git"):
elif (path / ".git").exists():
2022-02-02 15:09:37 -05:00
return GitRepository(path, git=git)
else:
- raise InvalidRepoPath(f"Unknown VCS, or not a source checkout: {path}")
2022-02-02 15:09:37 -05:00
+ return LocalRepository(path)
def get_repository_from_build_config(config):
2023-03-15 05:41:39 -05:00
@@ -781,6 +804,8 @@ def get_repository_from_build_config(config):
return HgRepository(Path(config.topsrcdir), hg=config.substs["HG"])
2022-02-02 15:09:37 -05:00
elif flavor == "git":
return GitRepository(Path(config.topsrcdir), git=config.substs["GIT"])
2022-02-02 15:09:37 -05:00
+ elif flavor == "local":
+ return LocalRepository(config.topsrcdir)
else:
raise MissingVCSInfo("unknown VCS_CHECKOUT_TYPE value: %s" % flavor)
2023-01-14 10:40:53 -05:00
--- a/third_party/python/mozilla_repo_urls/mozilla_repo_urls/parser.py
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/parser.py
2023-03-15 05:41:39 -05:00
@@ -9,7 +9,7 @@ for i, platform in enumerate(ADDITIONAL_PLATFORMS):
2023-01-14 10:40:53 -05:00
giturlparse.platforms.PLATFORMS.insert(i, platform)
2023-03-15 05:41:39 -05:00
-_SUPPORTED_PLATFORMS = ("hgmo", "github")
+_SUPPORTED_PLATFORMS = ("hgmo", "github", "gitlab")
2023-01-14 10:40:53 -05:00
2023-03-15 05:41:39 -05:00
SUPPORTED_HOSTS = tuple(
2022-04-10 09:08:21 -05:00
--- a/third_party/python/taskcluster_taskgraph/taskgraph/util/vcs.py
+++ b/third_party/python/taskcluster_taskgraph/taskgraph/util/vcs.py
2023-01-14 10:40:53 -05:00
@@ -495,6 +495,64 @@ class GitRepository(Repository):
2022-11-25 08:28:10 -05:00
raise
2022-04-10 09:08:21 -05:00
+class LocalRepository(Repository):
2023-01-14 10:40:53 -05:00
+ @property
+ def tool(self):
+ return "true"
2022-04-10 09:08:21 -05:00
+
+ @property
2023-01-14 10:40:53 -05:00
+ def head_rev(self) -> str:
2022-04-10 09:08:21 -05:00
+ return ""
+
2023-01-14 10:40:53 -05:00
+ @property
+ def base_rev(self):
+ return ""
2022-04-11 16:30:45 -05:00
+
2023-01-14 10:40:53 -05:00
+ @property
2022-04-11 16:30:45 -05:00
+ def branch(self):
2023-01-14 10:40:53 -05:00
+ return ""
2022-04-11 16:30:45 -05:00
+
2023-01-14 10:40:53 -05:00
+ @property
+ def all_remote_names(self):
+ return ""
2022-04-11 16:30:45 -05:00
+
2023-01-14 10:40:53 -05:00
+ @property
+ def default_remote_name(self):
2022-04-11 16:30:45 -05:00
+ return ""
+
2023-01-14 10:40:53 -05:00
+ @property
+ def remote_name(self):
+ return ""
2022-04-11 16:30:45 -05:00
+
2023-01-14 10:40:53 -05:00
+ @property
+ def default_branch(self):
+ return ""
2022-04-11 16:30:45 -05:00
+
2023-01-14 10:40:53 -05:00
+ def get_url(self, remote=None):
+ return ""
2023-01-11 16:36:55 -05:00
+
2023-01-14 10:40:53 -05:00
+ def get_commit_message(self, revision=None):
2023-01-11 16:36:55 -05:00
+ raise Exception("Unimplemented")
+
2023-01-14 10:40:53 -05:00
+ def get_changed_files(self, diff_filter, mode="unstaged", rev=None, base_rev=None):
2023-01-11 16:36:55 -05:00
+ raise Exception("Unimplemented")
+
2023-01-14 10:40:53 -05:00
+ def get_outgoing_files(self, diff_filter, upstream):
2023-01-11 16:36:55 -05:00
+ raise Exception("Unimplemented")
+
2023-01-14 10:40:53 -05:00
+ def working_directory_clean(self, untracked=False, ignored=False):
2023-01-11 16:36:55 -05:00
+ raise Exception("Unimplemented")
+
2023-01-14 10:40:53 -05:00
+ def update(self, ref):
2023-01-11 16:36:55 -05:00
+ raise Exception("Unimplemented")
+
2023-01-14 10:40:53 -05:00
+ def find_latest_common_revision(self, base_ref_or_rev, head_rev):
2023-01-11 16:36:55 -05:00
+ raise Exception("Unimplemented")
+
2023-01-14 10:40:53 -05:00
+ def does_revision_exist_locally(self, revision):
2023-01-11 16:36:55 -05:00
+ raise Exception("Unimplemented")
+
2022-04-10 09:08:21 -05:00
+
def get_repository(path):
"""Get a repository object for the repository at `path`.
If `path` is not a known VCS repository, raise an exception.
2023-01-14 10:40:53 -05:00
@@ -505,7 +563,7 @@ def get_repository(path):
2022-04-10 09:08:21 -05:00
elif os.path.exists(os.path.join(path, ".git")):
return GitRepository(path)
- raise RuntimeError("Current directory is neither a git or hg repository")
+ return LocalRepository(path)
def find_hg_revision_push_info(repository, revision):