bitbake: fetch2: handle broken symlinks in local mirror handling

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.

(Bitbake rev: 229ed3857e826e3e215e843cb51f729c1e13ed37)

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Christopher Larson 2012-07-31 15:20:14 -07:00 committed by Richard Purdie
parent f1417a1349
commit 420891731f
1 changed files with 5 additions and 1 deletions

View File

@ -560,7 +560,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