summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2017-03-31 16:59:56 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-12-18 16:44:37 +0000
commite3ff03599e55fd2abcaa33e29779c388cdbed94e (patch)
treeecad0ac65fb50d3673133c4b94aac7e5a6451002 /bitbake
parent84fd0eb005d8130106496d9e1c360cb0d8625f12 (diff)
downloadpoky-e3ff03599e55fd2abcaa33e29779c388cdbed94e.tar.gz
bitbake: fetch2: Do not fail to create symbolic links if they already exist
When the fetcher retrieves file:// URLs, there is no lock file being used. This means that in case two separate tasks (typically from two concurrent invocations of bitbake) want to download the same file:// URL at the same time, there is a very small chance that they also end up wanting to create a symbolic link to the file at the same time. This would previously lead to one of the tasks failing as the other task would have created the link. (Bitbake rev: 5f5e13bacde95a93633f621ec6b94a022c476a58) Signed-off-by: Peter Kjellerstedt <pkj@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index cd7362c44a..f36f01a707 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -967,7 +967,14 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
967 open(ud.donestamp, 'w').close() 967 open(ud.donestamp, 'w').close()
968 dest = os.path.join(dldir, os.path.basename(ud.localpath)) 968 dest = os.path.join(dldir, os.path.basename(ud.localpath))
969 if not os.path.exists(dest): 969 if not os.path.exists(dest):
970 os.symlink(ud.localpath, dest) 970 # In case this is executing without any file locks held (as is
971 # the case for file:// URLs), two tasks may end up here at the
972 # same time, in which case we do not want the second task to
973 # fail when the link has already been created by the first task.
974 try:
975 os.symlink(ud.localpath, dest)
976 except FileExistsError:
977 pass
971 if not verify_donestamp(origud, ld) or origud.method.need_update(origud, ld): 978 if not verify_donestamp(origud, ld) or origud.method.need_update(origud, ld):
972 origud.method.download(origud, ld) 979 origud.method.download(origud, ld)
973 if hasattr(origud.method,"build_mirror_data"): 980 if hasattr(origud.method,"build_mirror_data"):
@@ -979,7 +986,11 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
979 # Broken symbolic link 986 # Broken symbolic link
980 os.unlink(origud.localpath) 987 os.unlink(origud.localpath)
981 988
982 os.symlink(ud.localpath, origud.localpath) 989 # As per above, in case two tasks end up here simultaneously.
990 try:
991 os.symlink(ud.localpath, origud.localpath)
992 except FileExistsError:
993 pass
983 update_stamp(origud, ld) 994 update_stamp(origud, ld)
984 return ud.localpath 995 return ud.localpath
985 996