<div dir="ltr"><div><div><div>Hi Richard,<br><br></div>I renamed function, probably name is a little bit long, but it fully displays what it does.<br><br></div>Regards,<br></div>Roman.<br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-09-27 13:22 GMT+03:00 Roman Savchenko <span dir="ltr"><<a href="mailto:gmstima@gmail.com" target="_blank">gmstima@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">From: Roman Savchenko <<a href="mailto:roman.savchenko@attocapital.com">roman.savchenko@attocapital.<wbr>com</a>><br>
<br>
When making new symlink in case when link name does not exist<br>
possible broken symlink behaviour should be taken into account.<br>
<br>
</span><span class="">Signed-off-by: Roman Savchenko <<a href="mailto:gmstima@gmail.com">gmstima@gmail.com</a>><br>
---<br>
bitbake/lib/bb/fetch2/__init__<wbr>.py | 21 +++++++++++++--------<br>
1 file changed, 13 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/bitbake/lib/bb/fetch2/__<wbr>init__.py b/bitbake/lib/bb/fetch2/__<wbr>init__.py<br>
</span>index 6ef0c6f..6638b34 100644<br>
<span class="">--- a/bitbake/lib/bb/fetch2/__<wbr>init__.py<br>
+++ b/bitbake/lib/bb/fetch2/__<wbr>init__.py<br>
@@ -925,6 +925,17 @@ def rename_bad_checksum(ud, suffix):<br>
bb.utils.movefile(ud.<wbr>localpath, new_localpath)<br>
<br>
<br>
</span>+def create_symlink_if_not_exist(<wbr>source, link_name):<br>
<span class="">+ """<br>
+ Tries to make link to passed source if link name does not<br>
</span>+ exist or it is the invalid symlink.<br>
<span class="">+ """<br>
+ if not os.path.exists(link_name):<br>
+ if os.path.islink(link_name):<br>
+ os.unlink(link_name)<br>
+<br>
+ os.symlink(source, link_name)<br>
+<br>
def try_mirror_url(fetch, origud, ud, ld, check = False):<br>
# Return of None or a value means we're finished<br>
# False means try another url<br>
@@ -962,20 +973,14 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):<br>
bb.utils.mkdirhier(os.path.<wbr>dirname(ud.donestamp))<br>
open(ud.donestamp, 'w').close()<br>
dest = os.path.join(dldir, os.path.basename(ud.localpath)<wbr>)<br>
- if not os.path.exists(dest):<br>
- os.symlink(ud.localpath, dest)<br>
</span>+ create_symlink_if_not_exist(<wbr>ud.localpath, dest)<br>
<span class=""> if not verify_donestamp(origud, ld) or origud.method.need_update(<wbr>origud, ld):<br>
origud.method.download(origud, ld)<br>
if hasattr(origud.method,"build_<wbr>mirror_data"):<br>
origud.method.build_mirror_<wbr>data(origud, ld)<br>
return origud.localpath<br>
# Otherwise the result is a local file:// and we symlink to it<br>
- if not os.path.exists(origud.<wbr>localpath):<br>
- if os.path.islink(origud.<wbr>localpath):<br>
- # Broken symbolic link<br>
- os.unlink(origud.localpath)<br>
-<br>
- os.symlink(ud.localpath, origud.localpath)<br>
</span>+ create_symlink_if_not_exist(<wbr>ud.localpath, origud.localpath)<br>
<div class="HOEnZb"><div class="h5"> update_stamp(origud, ld)<br>
return ud.localpath<br>
<br>
--<br>
2.7.4<br>
<br>
</div></div></blockquote></div><br></div>