aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-05-30 21:48:03 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2016-05-30 21:48:03 +0300
commitbeb68274138e6f6140c03709c59b57379a94a7c0 (patch)
treeff8f0443325772b411be97bfccf30dd32ad74712 /mesonbuild/scripts
parent144565fabff7c872b7c45970bb0e30235b2e9324 (diff)
downloadmeson-beb68274138e6f6140c03709c59b57379a94a7c0.zip
meson-beb68274138e6f6140c03709c59b57379a94a7c0.tar.gz
meson-beb68274138e6f6140c03709c59b57379a94a7c0.tar.bz2
Installing subdirs now merges with existing files in the target dir.
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/meson_install.py44
1 files changed, 32 insertions, 12 deletions
diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py
index 085dd69..1cba480 100644
--- a/mesonbuild/scripts/meson_install.py
+++ b/mesonbuild/scripts/meson_install.py
@@ -42,20 +42,40 @@ def do_install(datafilename):
install_data(d)
run_install_script(d)
-def install_subdirs(d):
- for (src_dir, dst_dir) in d.install_subdirs:
+def install_subdirs(data):
+ for (src_dir, inst_dir, dst_dir) in data.install_subdirs:
+ if src_dir.endswith('/'):
+ src_dir = src_dir[:-1]
+ src_prefix = os.path.join(src_dir, inst_dir)
+ print('Installing subdir %s to %s.' % (src_prefix, dst_dir))
if os.path.isabs(dst_dir):
- dst_dir = destdir_join(d.destdir, dst_dir)
+ dst_dir = destdir_join(data.destdir, dst_dir)
else:
- dst_dir = d.fullprefix + dst_dir
- # Python's copytree works in strange ways.
- last_level = os.path.split(src_dir)[-1]
- final_dst = os.path.join(dst_dir, last_level)
-# Don't do rmtree because final_dst might point to e.g. /var/www
-# We might need to revert to walking the directory tree by hand.
-# shutil.rmtree(final_dst, ignore_errors=True)
- shutil.copytree(src_dir, final_dst, symlinks=True)
- print('Installing subdir %s to %s.' % (src_dir, dst_dir))
+ dst_dir = data.fullprefix + dst_dir
+ if not os.path.exists(dst_dir):
+ os.makedirs(dst_dir)
+ for root, dirs, files in os.walk(src_prefix):
+ print(root)
+ for d in dirs:
+ abs_src = os.path.join(src_dir, root, d)
+ filepart = abs_src[len(src_dir)+1:]
+ abs_dst = os.path.join(dst_dir, filepart)
+ if os.path.isdir(abs_dst):
+ continue
+ if os.path.exists(abs_dst):
+ print('Tried to copy directory %s but a file of that name already exists.' % abs_dst)
+ sys.exit(1)
+ os.makedirs(abs_dst)
+ shutil.copystat(abs_src, abs_dst)
+ for f in files:
+ abs_src = os.path.join(src_dir, root, f)
+ filepart = abs_src[len(src_dir)+1:]
+ abs_dst = os.path.join(dst_dir, filepart)
+ if os.path.isdir(abs_dst):
+ print('Tried to copy file %s but a directory of that name already exists.' % abs_dst)
+ if os.path.exists(abs_dst):
+ os.unlink(abs_dst)
+ shutil.copy2(abs_src, abs_dst, follow_symlinks=False)
def install_data(d):
for i in d.data: