diff options
author | Gert Wollny <[email protected]> | 2018-08-03 11:47:28 +0200 |
---|---|---|
committer | Andres Gomez <[email protected]> | 2018-08-07 20:55:56 +0300 |
commit | 3c3589a0ba899d175cdea1e059afad86259ace74 (patch) | |
tree | 622fcb5218f564fdf163c1b1e14713da5ba72cfa | |
parent | 37fa81f631b10ebfa9b7158b102236ae2a28d054 (diff) |
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 <[email protected]>(v2 minus dir check)
Reviewed-by: Dylan Baker <[email protected]>
Signed-off-by: Gert Wollny <[email protected]>
(cherry picked from commit 7a46b2d6418aa1adedf5621ad1a2a43676785851)
-rwxr-xr-x | bin/install_megadrivers.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/install_megadrivers.py b/bin/install_megadrivers.py index 8d9ed9c6dce..551e385d1a5 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 driver in args.drivers: abs_driver = os.path.join(to, driver) - if os.path.exists(abs_driver): + if os.path.lexists(abs_driver): os.unlink(abs_driver) print('installing {} to {}'.format(args.megadriver, abs_driver)) os.link(master, abs_driver) @@ -60,7 +62,7 @@ def main(): name, ext = os.path.splitext(driver) while ext != '.so': - if os.path.exists(name): + if os.path.lexists(name): os.unlink(name) os.symlink(driver, name) name, ext = os.path.splitext(name) |