diff options
author | Aníbal Limón <anibal.limon@linux.intel.com> | 2014-11-27 19:12:03 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-11-28 14:03:01 +0000 |
commit | cd40af6b1d22fafeb2e3ee5d9c85b92011ba35a7 (patch) | |
tree | de53963be9f082c3f101464af250b1d11543a543 | |
parent | a7bdd0eb295f80b0f42750f6cfd32ae5757c12c9 (diff) | |
download | poky-cd40af6b1d22fafeb2e3ee5d9c85b92011ba35a7.tar.gz |
bitbake: fetch/wget: Improve REGEX_URI handling
Latest version string only try to find latest directory when REGEX_URI
isn't specified to avoid unnecessary processing and makes code easier
(Bitbake rev: afc33ec7cdb7d8ee3602a23fa973551ca5510ac4)
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/fetch2/wget.py | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py index b6b1339d8d..85485bfa22 100644 --- a/bitbake/lib/bb/fetch2/wget.py +++ b/bitbake/lib/bb/fetch2/wget.py | |||
@@ -197,7 +197,7 @@ class Wget(FetchMethod): | |||
197 | bb.debug(3, "DirURL: %s, %s" % (url, versionstring)) | 197 | bb.debug(3, "DirURL: %s, %s" % (url, versionstring)) |
198 | soup = BeautifulSoup(self._fetch_index(url, ud, d)) | 198 | soup = BeautifulSoup(self._fetch_index(url, ud, d)) |
199 | if not soup: | 199 | if not soup: |
200 | return "" | 200 | return None |
201 | 201 | ||
202 | valid = 0 | 202 | valid = 0 |
203 | prefix = '' | 203 | prefix = '' |
@@ -225,21 +225,21 @@ class Wget(FetchMethod): | |||
225 | return prefix+version[1] | 225 | return prefix+version[1] |
226 | else: | 226 | else: |
227 | bb.debug(3, "Not Valid") | 227 | bb.debug(3, "Not Valid") |
228 | return "" | 228 | return None |
229 | 229 | ||
230 | def _check_latest_version(self, url, packagename, ud, d): | 230 | def _check_latest_version(self, url, package, ud, d): |
231 | """ | 231 | """ |
232 | Return the latest version of a package inside a given directory path | 232 | Return the latest version of a package inside a given directory path |
233 | If error or no version, return "" | 233 | If error or no version, return "" |
234 | """ | 234 | """ |
235 | valid = 0 | 235 | valid = 0 |
236 | version = self._parse_path(self.package_regex_comp, packagename) | 236 | version = self._parse_path(self.package_regex_comp, package) |
237 | 237 | ||
238 | bb.debug(3, "VersionURL: %s" % (url)) | 238 | bb.debug(3, "VersionURL: %s" % (url)) |
239 | soup = BeautifulSoup(self._fetch_index(url, ud, d)) | 239 | soup = BeautifulSoup(self._fetch_index(url, ud, d)) |
240 | if not soup: | 240 | if not soup: |
241 | bb.debug(3, "*** %s NO SOUP" % (packagename)) | 241 | bb.debug(3, "*** %s NO SOUP" % (package)) |
242 | return "" | 242 | return None |
243 | 243 | ||
244 | pn_regex = d.getVar('REGEX', True) | 244 | pn_regex = d.getVar('REGEX', True) |
245 | if pn_regex: | 245 | if pn_regex: |
@@ -269,10 +269,12 @@ class Wget(FetchMethod): | |||
269 | version = ('', '', '') | 269 | version = ('', '', '') |
270 | if not pn_regex: | 270 | if not pn_regex: |
271 | testversion = ('', '', '') | 271 | testversion = ('', '', '') |
272 | bb.debug(3, "*** %s -> %s (TestVersion = %s)" % (packagename, version[1], testversion[1])) | 272 | bb.debug(3, "*** %s -> %s (TestVersion = %s)" % (package, version[1], testversion[1])) |
273 | if valid and version: | 273 | if valid and version: |
274 | return re.sub('_', '.', version[1]) | 274 | return re.sub('_', '.', version[1]) |
275 | 275 | ||
276 | return None | ||
277 | |||
276 | def _init_regexes(self): | 278 | def _init_regexes(self): |
277 | """ | 279 | """ |
278 | Match as many patterns as possible such as: | 280 | Match as many patterns as possible such as: |
@@ -321,36 +323,37 @@ class Wget(FetchMethod): | |||
321 | 323 | ||
322 | sanity check to ensure same name and type. | 324 | sanity check to ensure same name and type. |
323 | """ | 325 | """ |
326 | package = ud.path.split("/")[-1] | ||
324 | regex_uri = d.getVar("REGEX_URI", True) | 327 | regex_uri = d.getVar("REGEX_URI", True) |
325 | newpath = ud.path | 328 | newpath = regex_uri or ud.path |
326 | pupver = "" | 329 | pupver = "" |
327 | 330 | ||
328 | self._init_regexes() | 331 | self._init_regexes() |
329 | 332 | ||
330 | m = self.dirver_regex_comp.search(ud.path) | 333 | if not regex_uri: |
331 | bb.debug(3, "path = %s" % (ud.path)) | 334 | # generate the new uri with the appropriate latest directory |
332 | bb.debug(3, "Regex: %s" % (self.package_regex_comp.pattern)) | 335 | m = self.dirver_regex_comp.search(ud.path) |
333 | if m and not regex_uri: | 336 | if m: |
334 | dirver = m.group('dirver') | 337 | dirver = m.group('dirver') |
335 | # generate the new uri after removing version directory name | 338 | newuri = bb.fetch.encodeurl([ud.type, ud.host, |
336 | newuri = bb.fetch.encodeurl([ud.type, ud.host, ud.path.split(dirver)[0], ud.user, ud.pswd, {}]) | 339 | ud.path.split(dirver)[0], ud.user, ud.pswd, {}]) |
337 | newversion = self._check_latest_dir(newuri, dirver, ud, d) | 340 | new_dirver = self._check_latest_dir(newuri, dirver, ud, d) |
338 | if newversion and dirver != newversion: | 341 | if new_dirver and dirver != new_dirver: |
339 | newpath = ud.path.replace(dirver, newversion, True) | 342 | newpath = ud.path.replace(dirver, new_dirver, True) |
340 | 343 | ||
341 | # try to acquire all remote files in current directory | 344 | newpath = newpath.split(package)[0] or "/" # path to directory |
342 | packagename = newpath.split("/")[-1] # current package name | 345 | newuri = bb.fetch.encodeurl([ud.type, ud.host, newpath, ud.user, ud.pswd, {}]) |
343 | newpath = newpath.split(packagename)[0] or "/" # path to directory | 346 | else: |
347 | newuri = newpath | ||
344 | 348 | ||
345 | # generate the new uri with the appropriate latest directory | 349 | # generate the new uri with the appropriate latest directory |
346 | newuri = regex_uri or bb.fetch.encodeurl([ud.type, ud.host, newpath, ud.user, ud.pswd, {}]) | 350 | newuri = regex_uri or bb.fetch.encodeurl([ud.type, ud.host, newpath, ud.user, ud.pswd, {}]) |
347 | newversion = self._check_latest_version(newuri, packagename, ud, d) | 351 | newversion = self._check_latest_version(newuri, package, ud, d) |
348 | while not newversion: | 352 | while not newversion: |
349 | # maybe it's hiding in a download directory so try there | 353 | # maybe it's hiding in a download directory so try there |
350 | newuri = "/".join(newuri.split("/")[0:-2]) + "/download" | 354 | newuri = "/".join(newuri.split("/")[0:-2]) + "/download" |
351 | if newuri == "/download" or newuri == "http://download": | 355 | if newuri == "/download" or newuri == "http://download": |
352 | break | 356 | break |
353 | newversion = self._check_latest_version(newuri, packagename, ud, d) | 357 | newversion = self._check_latest_version(newuri, package, ud, d) |
354 | |||
355 | return newversion | ||
356 | 358 | ||
359 | return newversion or "" | ||