summaryrefslogtreecommitdiff
path: root/bin/bootstrap.py
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-01-08 11:01:24 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-04-10 16:07:46 +0200
commitfeb7bcad4fb64e243a57e09ab5ee751088d54f13 (patch)
treef220dc940a6f9e21c0c804ee745395d1a11faad8 /bin/bootstrap.py
parenta7c897a29fd8b65e110018e27186f6b7b6983f9c (diff)
downloadjustbuild-feb7bcad4fb64e243a57e09ab5ee751088d54f13.tar.gz
bootstrap: accept a build dir inside the source tree
While it is best practise to build outside the source tree, some package formats require that a build be carried out inside the source tree. As there are no principle obstacles, as long as a non-existing directory is requested as build dir, support it by ignoring the destination in the recursive copy. (cherry-picked from 264ba60e221231109201da1c6d336c642959a0c2)
Diffstat (limited to 'bin/bootstrap.py')
-rwxr-xr-xbin/bootstrap.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/bin/bootstrap.py b/bin/bootstrap.py
index 80d3dfb3..0901f771 100755
--- a/bin/bootstrap.py
+++ b/bin/bootstrap.py
@@ -313,6 +313,17 @@ def prune_config(*, repos_file, empty_dir):
with open(repos_file, "w") as f:
json.dump(repos, f, indent=2)
+def ignore_dst(dst):
+ def ignore_(path, names):
+ if os.path.normpath(path) == dst:
+ return names
+ for n in names:
+ if os.path.normpath(os.path.join(path, n)) == dst:
+ return[n]
+ return []
+ return ignore_
+
+
def copy_roots(*, repos_file, copy_dir):
with open(repos_file) as f:
repos = json.load(f)
@@ -324,10 +335,14 @@ def copy_roots(*, repos_file, copy_dir):
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)
+ dst = os.path.normpath(os.path.join(new_root, x))
+
if os.path.isdir(src):
- shutil.copytree(src, dst,
- symlinks=False, dirs_exist_ok=True)
+ shutil.copytree(src,
+ dst,
+ ignore=ignore_dst(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)
@@ -347,8 +362,8 @@ def bootstrap():
os.makedirs(WRKDIR, exist_ok=True)
with open(os.path.join(WRKDIR, "build-conf.json"), 'w') as f:
json.dump(CONF, f, indent=2)
- src_wrkdir = os.path.join(WRKDIR, "src")
- shutil.copytree(SRCDIR, src_wrkdir)
+ src_wrkdir = os.path.normpath(os.path.join(WRKDIR, "src"))
+ shutil.copytree(SRCDIR, src_wrkdir, ignore=ignore_dst(src_wrkdir))
if LOCAL_DEPS:
config_to_local(
repos_file =os.path.join(src_wrkdir, REPOS),