summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2015-02-13 15:58:09 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-16 09:13:05 +0000
commit309d92efde484eb8747d40cd32330f5775fd9284 (patch)
tree958b2b0ecee2e8359a64758dd4bbb2cfde163d9a /bitbake
parentbed1b3f47ee1aeb93f38f2f48eca0573cb13581a (diff)
downloadpoky-309d92efde484eb8747d40cd32330f5775fd9284.tar.gz
bitbake: fetch2: wget latest_versionstring _check_latest_version improvments
In order to reduce code duplication now compile package_regex in _init_regexes instead of make this decision at _check_latest_version, (Bitbake rev: e7284e3ad0e7dd91ed59dfbf8450ef62e89c7e54) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/wget.py51
1 files changed, 25 insertions, 26 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index 04e2b33e12..96d895d6db 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -243,26 +243,21 @@ class Wget(FetchMethod):
243 def _check_latest_version(self, url, package, package_regex, current_version, ud, d): 243 def _check_latest_version(self, url, package, package_regex, current_version, ud, d):
244 """ 244 """
245 Return the latest version of a package inside a given directory path 245 Return the latest version of a package inside a given directory path
246 If error or no version, return None 246 If error or no version, return ""
247 """ 247 """
248 valid = 0 248 valid = 0
249 version = ('', '', '') 249 version = ['', '', '']
250 250
251 bb.debug(3, "VersionURL: %s" % (url)) 251 bb.debug(3, "VersionURL: %s" % (url))
252 soup = BeautifulSoup(self._fetch_index(url, ud, d)) 252 soup = BeautifulSoup(self._fetch_index(url, ud, d))
253 if not soup: 253 if not soup:
254 bb.debug(3, "*** %s NO SOUP" % (url)) 254 bb.debug(3, "*** %s NO SOUP" % (url))
255 return None 255 return ""
256 256
257 pn_regex = d.getVar('REGEX', True)
258 if pn_regex:
259 pn_regex = re.compile(pn_regex)
260 package_regex = pn_regex
261 bb.debug(3, "pn_regex = '%s'" % (pn_regex.pattern))
262
263 for line in soup.find_all('a', href=True): 257 for line in soup.find_all('a', href=True):
264 newver = None 258 bb.debug(3, "line = '%s'" % (str(line)))
265 bb.debug(3, "line = '%s'" % (line['href'])) 259 bb.debug(3, "line['href'] = '%s'" % (line['href']))
260
266 newver = self._parse_path(package_regex, line['href']) 261 newver = self._parse_path(package_regex, line['href'])
267 if not newver: 262 if not newver:
268 newver = self._parse_path(package_regex, str(line)) 263 newver = self._parse_path(package_regex, str(line))
@@ -279,12 +274,12 @@ class Wget(FetchMethod):
279 bb.debug(3, "*** %s -> UpstreamVersion = %s (CurrentVersion = %s)" % 274 bb.debug(3, "*** %s -> UpstreamVersion = %s (CurrentVersion = %s)" %
280 (package, version[1] or "N/A", current_version[1])) 275 (package, version[1] or "N/A", current_version[1]))
281 276
282 if valid and version: 277 if valid:
283 return re.sub('_', '.', version[1]) 278 return re.sub('_', '.', version[1])
284 279
285 return None 280 return ""
286 281
287 def _init_regexes(self, package): 282 def _init_regexes(self, package, ud, d):
288 """ 283 """
289 Match as many patterns as possible such as: 284 Match as many patterns as possible such as:
290 gnome-common-2.20.0.tar.gz (most common format) 285 gnome-common-2.20.0.tar.gz (most common format)
@@ -318,7 +313,7 @@ class Wget(FetchMethod):
318 psuffix_regex = "(tar\.gz|tgz|tar\.bz2|zip|xz|rpm|bz2|orig\.tar\.gz|tar\.xz|src\.tar\.gz|src\.tgz|svnr\d+\.tar\.bz2|stable\.tar\.gz|src\.rpm)" 313 psuffix_regex = "(tar\.gz|tgz|tar\.bz2|zip|xz|rpm|bz2|orig\.tar\.gz|tar\.xz|src\.tar\.gz|src\.tgz|svnr\d+\.tar\.bz2|stable\.tar\.gz|src\.rpm)"
319 314
320 # match name, version and archive type of a package 315 # match name, version and archive type of a package
321 self.package_regex_comp = re.compile("(?P<name>%s?)\.?v?(?P<pver>%s)(?P<arch>%s)?[\.\-](?P<type>%s$)" 316 package_regex_comp = re.compile("(?P<name>%s?)\.?v?(?P<pver>%s)(?P<arch>%s)?[\.\-](?P<type>%s$)"
322 % (pn_regex, pver_regex, parch_regex, psuffix_regex)) 317 % (pn_regex, pver_regex, parch_regex, psuffix_regex))
323 self.suffix_regex_comp = re.compile(psuffix_regex) 318 self.suffix_regex_comp = re.compile(psuffix_regex)
324 319
@@ -326,13 +321,18 @@ class Wget(FetchMethod):
326 # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz 321 # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz
327 self.dirver_regex_comp = re.compile("(?P<dirver>[^/]*(\d+\.)*\d+([\-_]r\d+)*)/") 322 self.dirver_regex_comp = re.compile("(?P<dirver>[^/]*(\d+\.)*\d+([\-_]r\d+)*)/")
328 323
329 # make custom regex for search in uri's 324 # compile regex, can be specific by package or generic regex
330 package_custom_regex_comp = None 325 pn_regex = d.getVar('REGEX', True)
331 version = self._parse_path(self.package_regex_comp, package) 326 if pn_regex:
332 if version: 327 package_custom_regex_comp = re.compile(pn_regex)
333 package_custom_regex_comp = re.compile( 328 else:
334 "(?P<name>%s)(?P<pver>%s)(?P<arch>%s)?[\.\-](?P<type>%s)$" % 329 version = self._parse_path(package_regex_comp, package)
335 (re.escape(version[0]), pver_regex, parch_regex, psuffix_regex)) 330 if version:
331 package_custom_regex_comp = re.compile(
332 "(?P<name>%s)(?P<pver>%s)(?P<arch>%s)?[\.\-](?P<type>%s)$" %
333 (re.escape(version[0]), pver_regex, parch_regex, psuffix_regex))
334 else:
335 package_custom_regex_comp = package_regex_comp
336 336
337 return package_custom_regex_comp 337 return package_custom_regex_comp
338 338
@@ -347,7 +347,7 @@ class Wget(FetchMethod):
347 newpath = regex_uri or ud.path 347 newpath = regex_uri or ud.path
348 pupver = "" 348 pupver = ""
349 349
350 package_custom_regex_comp = self._init_regexes(package) 350 package_regex = self._init_regexes(package, ud, d)
351 351
352 current_version = ('', d.getVar('PV', True), '') 352 current_version = ('', d.getVar('PV', True), '')
353 353
@@ -371,6 +371,5 @@ class Wget(FetchMethod):
371 else: 371 else:
372 newuri = newpath 372 newuri = newpath
373 373
374 return self._check_latest_version(newuri, package, 374 return self._check_latest_version(newuri, package, package_regex,
375 package_custom_regex_comp or package_regex_comp, 375 current_version, ud, d)
376 current_version, ud, d) or ""