diff options
Diffstat (limited to 'bitbake/lib/bb/fetch')
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index 229b28c19d..bbff516ffc 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py | |||
@@ -24,7 +24,7 @@ BitBake build tools. | |||
24 | # | 24 | # |
25 | # Based on functions from the base bb module, Copyright 2003 Holger Schurig | 25 | # Based on functions from the base bb module, Copyright 2003 Holger Schurig |
26 | 26 | ||
27 | import os, re | 27 | import os, re, fcntl |
28 | import bb | 28 | import bb |
29 | from bb import data | 29 | from bb import data |
30 | from bb import persist_data | 30 | from bb import persist_data |
@@ -140,9 +140,21 @@ def go(d): | |||
140 | # Touch md5 file to show activity | 140 | # Touch md5 file to show activity |
141 | os.utime(ud.md5, None) | 141 | os.utime(ud.md5, None) |
142 | continue | 142 | continue |
143 | lf = open(ud.lockfile, "a+") | ||
144 | fcntl.flock(lf.fileno(), fcntl.LOCK_EX) | ||
145 | if ud.localfile and not m.forcefetch(u, ud, d) and os.path.exists(ud.md5): | ||
146 | # If someone else fetched this before we got the lock, | ||
147 | # notice and don't try again | ||
148 | os.utime(ud.md5, None) | ||
149 | fcntl.flock(lf.fileno(), fcntl.LOCK_UN) | ||
150 | lf.close | ||
151 | continue | ||
143 | m.go(u, ud, d) | 152 | m.go(u, ud, d) |
144 | if ud.localfile and not m.forcefetch(u, ud, d): | 153 | if ud.localfile and not m.forcefetch(u, ud, d): |
145 | Fetch.write_md5sum(u, ud, d) | 154 | Fetch.write_md5sum(u, ud, d) |
155 | fcntl.flock(lf.fileno(), fcntl.LOCK_UN) | ||
156 | lf.close | ||
157 | |||
146 | 158 | ||
147 | def localpaths(d): | 159 | def localpaths(d): |
148 | """ | 160 | """ |
@@ -264,6 +276,7 @@ class FetchData(object): | |||
264 | else: | 276 | else: |
265 | self.localpath = self.method.localpath(self.url, self, d) | 277 | self.localpath = self.method.localpath(self.url, self, d) |
266 | self.md5 = self.localpath + '.md5' | 278 | self.md5 = self.localpath + '.md5' |
279 | self.lockfile = self.localpath + '.lock' | ||
267 | # if user sets localpath for file, use it instead. | 280 | # if user sets localpath for file, use it instead. |
268 | 281 | ||
269 | 282 | ||