summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2015-02-13 15:58:08 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-16 09:13:05 +0000
commitbed1b3f47ee1aeb93f38f2f48eca0573cb13581a (patch)
tree269c08ce93a9cb42d5c9ef26c62dcf220147f5e5 /bitbake/lib/bb/fetch2
parentc4da9b949a09f6fcf4091f247a05cea78175571a (diff)
downloadpoky-bed1b3f47ee1aeb93f38f2f48eca0573cb13581a.tar.gz
bitbake: fetch2: wget latest_versionstring improve _parse_path
Add support for get group only if exist in regex, this enables to use this function in _check_latestversion regardless if the regex is generic or specified by REGEX_URI. (Bitbake rev: 1127af5b8c458929c4685b0326f86870ed09442e) 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/lib/bb/fetch2')
-rw-r--r--bitbake/lib/bb/fetch2/wget.py44
1 files changed, 24 insertions, 20 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index 9e4b443421..04e2b33e12 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -109,16 +109,30 @@ class Wget(FetchMethod):
109 109
110 return True 110 return True
111 111
112
113 def _parse_path(self, regex, s): 112 def _parse_path(self, regex, s):
114 """ 113 """
115 Find and group name, version and archive type in the given string s 114 Find and group name, version and archive type in the given string s
116 """ 115 """
117 bb.debug(3, "parse_path(%s, %s)" % (regex.pattern, s)) 116 bb.debug(3, "_parse_path(%s, %s)" % (regex.pattern, s))
117
118 m = regex.search(s) 118 m = regex.search(s)
119 if m: 119 if m:
120 bb.debug(3, "%s, %s, %s" % (m.group('name'), m.group('ver'), m.group('type'))) 120 pname = ''
121 return (m.group('name'), m.group('ver'), m.group('type')) 121 pver = ''
122 ptype = ''
123
124 mdict = m.groupdict()
125 if 'name' in mdict.keys():
126 pname = mdict['name']
127 if 'pver' in mdict.keys():
128 pver = mdict['pver']
129 if 'type' in mdict.keys():
130 ptype = mdict['type']
131
132 bb.debug(3, "_parse_path: %s, %s, %s" % (pname, pver, ptype))
133
134 return (pname, pver, ptype)
135
122 return None 136 return None
123 137
124 def _modelate_version(self, version): 138 def _modelate_version(self, version):
@@ -243,25 +257,15 @@ class Wget(FetchMethod):
243 pn_regex = d.getVar('REGEX', True) 257 pn_regex = d.getVar('REGEX', True)
244 if pn_regex: 258 if pn_regex:
245 pn_regex = re.compile(pn_regex) 259 pn_regex = re.compile(pn_regex)
260 package_regex = pn_regex
246 bb.debug(3, "pn_regex = '%s'" % (pn_regex.pattern)) 261 bb.debug(3, "pn_regex = '%s'" % (pn_regex.pattern))
247 262
248 for line in soup.find_all('a', href=True): 263 for line in soup.find_all('a', href=True):
249 newver = None 264 newver = None
250 bb.debug(3, "line = '%s'" % (line['href'])) 265 bb.debug(3, "line = '%s'" % (line['href']))
251 if pn_regex: 266 newver = self._parse_path(package_regex, line['href'])
252 m = pn_regex.search(line['href']) 267 if not newver:
253 if m: 268 newver = self._parse_path(package_regex, str(line))
254 bb.debug(3, "Pver = '%s'" % (m.group('pver')))
255 newver = ('', m.group('pver'), '')
256 else:
257 m = pn_regex.search(str(line))
258 if m:
259 bb.debug(3, "Pver = '%s'" % (m.group('pver')))
260 newver = ('', m.group('pver'), '')
261 else:
262 newver = self._parse_path(package_regex, line['href'])
263 if not newver:
264 newver = self._parse_path(package_regex, str(line))
265 269
266 if newver: 270 if newver:
267 bb.debug(3, "Upstream version found: %s" % newver[1]) 271 bb.debug(3, "Upstream version found: %s" % newver[1])
@@ -314,7 +318,7 @@ class Wget(FetchMethod):
314 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)" 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)"
315 319
316 # match name, version and archive type of a package 320 # match name, version and archive type of a package
317 self.package_regex_comp = re.compile("(?P<name>%s?)\.?v?(?P<ver>%s)(?P<arch>%s)?[\.\-](?P<type>%s$)" 321 self.package_regex_comp = re.compile("(?P<name>%s?)\.?v?(?P<pver>%s)(?P<arch>%s)?[\.\-](?P<type>%s$)"
318 % (pn_regex, pver_regex, parch_regex, psuffix_regex)) 322 % (pn_regex, pver_regex, parch_regex, psuffix_regex))
319 self.suffix_regex_comp = re.compile(psuffix_regex) 323 self.suffix_regex_comp = re.compile(psuffix_regex)
320 324
@@ -327,7 +331,7 @@ class Wget(FetchMethod):
327 version = self._parse_path(self.package_regex_comp, package) 331 version = self._parse_path(self.package_regex_comp, package)
328 if version: 332 if version:
329 package_custom_regex_comp = re.compile( 333 package_custom_regex_comp = re.compile(
330 "(?P<name>%s)(?P<ver>%s)(?P<arch>%s)?[\.\-](?P<type>%s)$" % 334 "(?P<name>%s)(?P<pver>%s)(?P<arch>%s)?[\.\-](?P<type>%s)$" %
331 (re.escape(version[0]), pver_regex, parch_regex, psuffix_regex)) 335 (re.escape(version[0]), pver_regex, parch_regex, psuffix_regex))
332 336
333 return package_custom_regex_comp 337 return package_custom_regex_comp