]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
scripts: Fix meson-install-symlink.py overwriting existing links
authorErik Skultety <eskultet@redhat.com>
Tue, 4 Aug 2020 15:27:21 +0000 (17:27 +0200)
committerErik Skultety <eskultet@redhat.com>
Wed, 5 Aug 2020 11:11:16 +0000 (13:11 +0200)
By default, symlink re-creation fails if the link already exists, more
specifically in case of meson-install-symlink.py:

Traceback (most recent call last):
  File "/<path_to_libvirt_repo>/scripts/meson-install-symlink.py",
    line 15, in <module>
        os.symlink(target, link)
FileExistsError: File exists: '../default.xml' -> 'default.xml'

Unfortunately, Python can't mimic "ln -sf", so we have to fix this
differently - remove the existing link first and then try re-creating
it.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
scripts/meson-install-symlink.py

index e38507072d934891c934ba97bbe5edcf908e18fb..d8817fb9be042e522b20c448cf8ab722efb1650c 100644 (file)
@@ -12,4 +12,8 @@ workdir = os.path.join(destdir, dirname.strip(os.sep))
 
 os.makedirs(workdir, exist_ok=True)
 os.chdir(workdir)
+
+if os.path.exists(link):
+    os.remove(link)
+
 os.symlink(target, link)