diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-02-13 17:27:37 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-02-14 14:24:08 +0100 |
commit | 34ae76b4bfc5d7c153f6c47f5257c2db515e70f1 (patch) | |
tree | 0c4d7ab05e764a2c810a9f6fbe42cfdc87b513a9 /bin | |
parent | 10af751026e15402cb8193163f2aa2d0d818a21a (diff) | |
download | justbuild-34ae76b4bfc5d7c153f6c47f5257c2db515e70f1.tar.gz |
Package bootstrapping: support copying the needed parts
... while following symbolic links. In this way, bootstrapping
is possible against preinstalled dependencies that symbolic links
or special files in their directories.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bootstrap.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bin/bootstrap.py b/bin/bootstrap.py index 331950e5..e8d938aa 100755 --- a/bin/bootstrap.py +++ b/bin/bootstrap.py @@ -272,6 +272,30 @@ def prune_config(*, repos_file, empty_dir): with open(repos_file, "w") as f: json.dump(repos, f, indent=2) +def copy_roots(*, repos_file, copy_dir): + with open(repos_file) as f: + repos = json.load(f) + for repo in repos["repositories"]: + desc = repos["repositories"][repo] + to_copy = desc.get("bootstrap", {}).get("copy") + if to_copy: + old_root = desc["repository"]["path"] + new_root = os.path.join(copy_dir, repo) + for x in to_copy: + src = os.path.join(old_root, x) + dst = os.path.join(new_root, x) + if os.path.isdir(src): + shutil.copytree(src, dst, + symlinks=False, dirs_exist_ok=True) + elif os.path.isfile(src): + os.makedirs(os.path.dirname(dst), exist_ok=True) + shutil.copyfile(src, dst, follow_symlinks=True) + shutil.copymode(src, dst, follow_symlinks=True) + desc["repository"]["path"] = new_root + os.unlink(repos_file) + with open(repos_file, "w") as f: + json.dump(repos, f, indent=2) + def bootstrap(): if LOCAL_DEPS: print("Bootstrap build in %r from sources %r against LOCALBASE %r" @@ -290,6 +314,8 @@ def bootstrap(): empty_dir = os.path.join(WRKDIR, "empty_directory") os.makedirs(empty_dir) prune_config(repos_file=os.path.join(src_wrkdir, REPOS), empty_dir=empty_dir) + copy_dir = os.path.join(WRKDIR, "copied_roots") + copy_roots(repos_file=os.path.join(src_wrkdir, REPOS), copy_dir=copy_dir) dep_flags = setup_deps(src_wrkdir) # handle proto flags = ["-I", src_wrkdir] + dep_flags["include"] + ["-I", os.path.join(LOCALBASE, "include")] |