summaryrefslogtreecommitdiffstats
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-04-01 23:28:41 +0100
commit4077dcb565153340bb01f1794db6a7ff4415ca5d (patch)
treefe2594fb6fcaa2b449971eca4ec3e01dcf109a33
parent4aa21211a3051b95ef9a67c62646e016114eac30 (diff)
downloadpoky-4077dcb565153340bb01f1794db6a7ff4415ca5d.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: 58a03531c8183b165bb7dcad86d8559c92bc150d) Signed-off-by: Peter Kjellerstedt <pkj@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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 ea72025c22..136fc29c16 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -983,7 +983,14 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
983 open(ud.donestamp, 'w').close() 983 open(ud.donestamp, 'w').close()
984 dest = os.path.join(dldir, os.path.basename(ud.localpath)) 984 dest = os.path.join(dldir, os.path.basename(ud.localpath))
985 if not os.path.exists(dest): 985 if not os.path.exists(dest):
986 os.symlink(ud.localpath, dest) 986 # In case this is executing without any file locks held (as is
987 # the case for file:// URLs), two tasks may end up here at the
988 # same time, in which case we do not want the second task to
989 # fail when the link has already been created by the first task.
990 try:
991 os.symlink(ud.localpath, dest)
992 except FileExistsError:
993 pass
987 if not verify_donestamp(origud, ld) or origud.method.need_update(origud, ld): 994 if not verify_donestamp(origud, ld) or origud.method.need_update(origud, ld):
988 origud.method.download(origud, ld) 995 origud.method.download(origud, ld)
989 if hasattr(origud.method,"build_mirror_data"): 996 if hasattr(origud.method,"build_mirror_data"):
@@ -995,7 +1002,11 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
995 # Broken symbolic link 1002 # Broken symbolic link
996 os.unlink(origud.localpath) 1003 os.unlink(origud.localpath)
997 1004
998 os.symlink(ud.localpath, origud.localpath) 1005 # As per above, in case two tasks end up here simultaneously.
1006 try:
1007 os.symlink(ud.localpath, origud.localpath)
1008 except FileExistsError:
1009 pass
999 update_stamp(origud, ld) 1010 update_stamp(origud, ld)
1000 return ud.localpath 1011 return ud.localpath
1001 1012