diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index cb2f325a83..9aea08b387 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -1018,16 +1018,7 @@ def try_mirror_url(fetch, origud, ud, ld, check = False): | |||
1018 | origud.method.build_mirror_data(origud, ld) | 1018 | origud.method.build_mirror_data(origud, ld) |
1019 | return origud.localpath | 1019 | return origud.localpath |
1020 | # Otherwise the result is a local file:// and we symlink to it | 1020 | # Otherwise the result is a local file:// and we symlink to it |
1021 | if not os.path.exists(origud.localpath): | 1021 | ensure_symlink(ud.localpath, origud.localpath) |
1022 | if os.path.islink(origud.localpath): | ||
1023 | # Broken symbolic link | ||
1024 | os.unlink(origud.localpath) | ||
1025 | |||
1026 | # As per above, in case two tasks end up here simultaneously. | ||
1027 | try: | ||
1028 | os.symlink(ud.localpath, origud.localpath) | ||
1029 | except FileExistsError: | ||
1030 | pass | ||
1031 | update_stamp(origud, ld) | 1022 | update_stamp(origud, ld) |
1032 | return ud.localpath | 1023 | return ud.localpath |
1033 | 1024 | ||
@@ -1061,6 +1052,22 @@ def try_mirror_url(fetch, origud, ud, ld, check = False): | |||
1061 | bb.utils.unlockfile(lf) | 1052 | bb.utils.unlockfile(lf) |
1062 | 1053 | ||
1063 | 1054 | ||
1055 | def ensure_symlink(target, link_name): | ||
1056 | if not os.path.exists(link_name): | ||
1057 | if os.path.islink(link_name): | ||
1058 | # Broken symbolic link | ||
1059 | os.unlink(link_name) | ||
1060 | |||
1061 | # In case this is executing without any file locks held (as is | ||
1062 | # the case for file:// URLs), two tasks may end up here at the | ||
1063 | # same time, in which case we do not want the second task to | ||
1064 | # fail when the link has already been created by the first task. | ||
1065 | try: | ||
1066 | os.symlink(target, link_name) | ||
1067 | except FileExistsError: | ||
1068 | pass | ||
1069 | |||
1070 | |||
1064 | def try_mirrors(fetch, d, origud, mirrors, check = False): | 1071 | def try_mirrors(fetch, d, origud, mirrors, check = False): |
1065 | """ | 1072 | """ |
1066 | Try to use a mirrored version of the sources. | 1073 | Try to use a mirrored version of the sources. |