meson already supports $DESTDIR natively, but in this case
we're using a custom script and so we have to do some extra
work ourselves.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
scripts/meson-install-web.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/scripts/meson-install-web.py b/scripts/meson-install-web.py
index fdf407ba33..e7456fa750 100755
--- a/scripts/meson-install-web.py
+++ b/scripts/meson-install-web.py
@@ -6,10 +6,23 @@ import sys
from pathlib import Path
+destdir = os.getenv('DESTDIR')
+if destdir:
+ destdir = Path(destdir)
+ if not destdir.is_absolute():
+ print('$DESTDIR must be an absolute path')
+ sys.exit(1)
+
for desc in sys.argv[1:]:
inst = desc.split(':')
src = Path(inst[0])
dst = Path(inst[1])
+ if destdir:
+ # Turn dst into a relative path by dropping its first component
+ # and append it to destdir to obtain the absolute destination
+ # path that respects the value $DESTDIR found in the environment
+ dst = Path(destdir, *dst.parts[1:])
+
dst.mkdir(parents=True, exist_ok=True)
shutil.copy(src, dst)
--
2.35.3