summaryrefslogtreecommitdiff
path: root/bin/bootstrap.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bootstrap.py')
-rwxr-xr-xbin/bootstrap.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/bin/bootstrap.py b/bin/bootstrap.py
index 12a97807..331950e5 100755
--- a/bin/bootstrap.py
+++ b/bin/bootstrap.py
@@ -83,6 +83,7 @@ SRCDIR = os.getcwd()
WRKDIR = None
DISTDIR = []
LOCALBASE = "/"
+NON_LOCAL_DEPS = []
# other global variables
@@ -185,7 +186,11 @@ def config_to_local(*, repos_file, link_targets_file):
with open(repos_file) as f:
repos = json.load(f)
global_link_dirs = set()
+ changed_file_roots = {}
+ backup_layers = {}
for repo in repos["repositories"]:
+ if repo in NON_LOCAL_DEPS:
+ continue
desc = repos["repositories"][repo]
repo_desc = desc.get("repository")
if not isinstance(repo_desc, dict):
@@ -211,6 +216,14 @@ def config_to_local(*, repos_file, link_targets_file):
del desc["local_bootstrap"]
if repo_desc.get("type") == "file":
local_bootstrap = desc.get("local_bootstrap", {})
+ if local_bootstrap.get("local_path") and NON_LOCAL_DEPS:
+ # local layer gets changed, keep a copy
+ backup_name = "ORIGINAL: " + repo
+ backup_layers[backup_name] = {
+ "repository": {"type": "file",
+ "path": repo_desc.get("path")
+ }}
+ changed_file_roots[repo] = backup_name
desc["repository"] = {
"type": "file",
"path": local_bootstrap.get("local_path", desc["repository"].get("path"))
@@ -219,6 +232,17 @@ def config_to_local(*, repos_file, link_targets_file):
if "local_bootstrap" in desc:
del desc["local_bootstrap"]
+ # For repos that we didn't change to local, make file roots point
+ # to the original version, so that, in particular, the original
+ # target root will be used.
+ for repo in NON_LOCAL_DEPS:
+ for layer in ["target_root", "rule_root", "expression_root"]:
+ layer_ref = repos["repositories"][repo].get(layer)
+ if layer_ref in changed_file_roots:
+ repos["repositories"][repo][layer] = changed_file_roots[layer_ref]
+
+ repos["repositories"] = dict(repos["repositories"], **backup_layers)
+
print("just-mr config rewritten to local:\n%s\n"
% (json.dumps(repos, indent=2)))
os.unlink(repos_file)
@@ -331,6 +355,7 @@ def main(args):
global DISTDIR
global LOCAL_DEPS
global LOCALBASE
+ global NON_LOCAL_DEPS
if len(args) > 1:
SRCDIR = os.path.abspath(args[1])
if len(args) > 2:
@@ -345,6 +370,7 @@ def main(args):
LOCAL_DEPS = "PACKAGE" in os.environ
LOCALBASE = os.environ.get("LOCALBASE", "/")
+ NON_LOCAL_DEPS = json.loads(os.environ.get("NON_LOCAL_DEPS", "[]"))
bootstrap()