Now update_symlinks has more checks to prevent unwanted exception.
It returns False if the link is not created/updated, True otherwise.

Signed-off-by: Davide Gardenal <[email protected]>
---
 meta/lib/oe/cve_check.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/meta/lib/oe/cve_check.py b/meta/lib/oe/cve_check.py
index aa06497727..688693520e 100644
--- a/meta/lib/oe/cve_check.py
+++ b/meta/lib/oe/cve_check.py
@@ -169,7 +169,17 @@ def update_symlinks(target_path, link_path):
     Update a symbolic link link_path to point to target_path.
     Remove the link and recreate it if exist and is different.
     """
-    if link_path != target_path and os.path.exists(target_path):
-        if os.path.exists(os.path.realpath(link_path)):
-            os.remove(link_path)
-        os.symlink(os.path.basename(target_path), link_path)
+    import os
+
+    if target_path == link_path or \
+        target_path is None or \
+        link_path is None or \
+        not os.path.exists(target_path):
+
+        return False
+
+    if os.path.lexists(link_path):
+        os.remove(link_path)
+
+    os.symlink(target_path, link_path)
+    return True
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#167339): 
https://lists.openembedded.org/g/openembedded-core/message/167339
Mute This Topic: https://lists.openembedded.org/mt/92043888/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to