From patchwork Tue Jul 31 22:20:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [bitbake-devel] fetch2: handle broken symlinks in local mirror handling Date: Tue, 31 Jul 2012 22:20:14 -0000 From: Christopher Larson X-Patchwork-Id: 33469 Message-Id: <1343773214-29621-1-git-send-email-kergoth@gmail.com> To: bitbake-devel@lists.openembedded.org Cc: Christopher Larson From: Christopher Larson 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 --- 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