[bitbake-devel] [PATCH] fetch2: handle broken symlinks in local mirror handling

Christopher Larson kergoth at gmail.com
Tue Jul 31 22:20:14 UTC 2012


From: Christopher Larson <chris_larson at mentor.com>

If a file:// mirror is being used, the fetcher will create a symlink to the
local file. However, if the local file gets removed, that link will be dead,
and os.path.exists() returns False in that case, so it tries and fails to
recreate the link. Now we unlink such a dead link if it exists.

Signed-off-by: Christopher Larson <chris_larson at mentor.com>
---
 lib/bb/fetch2/__init__.py |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index fa963be..8f5b097 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -557,7 +557,11 @@ def try_mirror_url(newuri, origud, ud, ld, check = False):
             return None
         # Otherwise the result is a local file:// and we symlink to it
         if not os.path.exists(origud.localpath):
-             os.symlink(ud.localpath, origud.localpath)
+            if os.path.islink(origud.localpath):
+                # Broken symbolic link
+                os.unlink(origud.localpath)
+
+            os.symlink(ud.localpath, origud.localpath)
         update_stamp(newuri, origud, ld)
         return ud.localpath
 
-- 
1.7.9.5





More information about the bitbake-devel mailing list