Mesa (staging/18.1): meson, install_megadrivers: Also remove stale symlinks

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 8 16:22:17 UTC 2018


Module: Mesa
Branch: staging/18.1
Commit: 3e0dbfde912e73f68f83dc99c49654cd8b0efea8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3e0dbfde912e73f68f83dc99c49654cd8b0efea8

Author: Gert Wollny <gert.wollny at collabora.com>
Date:   Fri Aug  3 11:47:28 2018 +0200

meson, install_megadrivers: Also remove stale symlinks

os.path.exists doesn't return True for stale symlinks, but they are in
the way later, when a link/file with the same name is to be created.
For instance it is conceivable that the pointed to file is replaced by
a file with a new name, and then the symlink is dead.

To handle this check specifically for all existing symlinks to be
removed. (This bugged me for some time with a link libXvMCr600.so
always being in the way of installing this file)

v2: use only os.lexist and replace all instances of os.exist (Dylan Baker)

v3: handle directory check correctly (Eric Engestrom)

Fixes: f7f1b30f81e842db6057591470ce3cb6d4fb2795
       ("meson: extend install_megadrivers script to handle symmlinking")

Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>(v2 minus dir check)
Reviewed-by: Dylan Baker <dylan at pnwbakers.com>
Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
(cherry picked from commit 7a46b2d6418aa1adedf5621ad1a2a43676785851)
Conflicts resolved by Dylan

Conflicts:
	bin/install_megadrivers.py

---

 bin/install_megadrivers.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/bin/install_megadrivers.py b/bin/install_megadrivers.py
index c04a2a3eb3..4ee98d06e1 100755
--- a/bin/install_megadrivers.py
+++ b/bin/install_megadrivers.py
@@ -43,13 +43,15 @@ def main():
     master = os.path.join(to, os.path.basename(args.megadriver))
 
     if not os.path.exists(to):
+        if os.path.lexists(to):
+            os.unlink(to)
         os.makedirs(to)
     shutil.copy(args.megadriver, master)
 
     for each in args.drivers:
         driver = os.path.join(to, each)
 
-        if os.path.exists(driver):
+        if os.path.lexists(driver):
             os.unlink(driver)
         print('installing {} to {}'.format(args.megadriver, driver))
         os.link(master, driver)
@@ -60,7 +62,7 @@ def main():
 
             name, ext = os.path.splitext(each)
             while ext != '.so':
-                if os.path.exists(name):
+                if os.path.lexists(name):
                     os.unlink(name)
                 os.symlink(each, name)
                 name, ext = os.path.splitext(name)




More information about the mesa-commit mailing list