@@ -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
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 <davide.gardenal@huawei.com> --- meta/lib/oe/cve_check.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)