[PATCH] meson: src: Fix DESTDIR handling while creating dirs

Jan Kiszka jan.kiszka at web.de
Mon Sep 7 21:25:34 UTC 2020


From: Jan Kiszka <jan.kiszka at siemens.com>

If the target path contains a link with an absolute path (e.g.
/var/run -> /run), makedirs will target the wrong location. Resolve the
path first, then append DESTDIR again if needed.

Signed-off-by: Jan Kiszka <jan.kiszka at siemens.com>
---
 scripts/meson-install-dirs.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/meson-install-dirs.py b/scripts/meson-install-dirs.py
index 14ec6b93e8..e762e44712 100644
--- a/scripts/meson-install-dirs.py
+++ b/scripts/meson-install-dirs.py
@@ -6,4 +6,7 @@ import sys
 destdir = os.environ.get('DESTDIR', os.sep)

 for dirname in sys.argv[1:]:
-    os.makedirs(os.path.join(destdir, dirname.strip(os.sep)), exist_ok=True)
+    realdir = os.path.realpath(os.path.join(destdir, dirname.strip(os.sep)))
+    if not realdir.startswith(destdir):
+        realdir = os.path.join(destdir, realdir.strip(os.sep))
+    os.makedirs(realdir, exist_ok=True)
--
2.26.2





More information about the libvir-list mailing list