summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2015-02-13 15:58:10 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-16 09:13:06 +0000
commit62e171b72180bc9aab0e5ffb70e2aa2919c0d132 (patch)
tree798a0ac53f15e95f473b03e8a63cdf783dd8eb01 /bitbake
parent309d92efde484eb8747d40cd32330f5775fd9284 (diff)
downloadpoky-62e171b72180bc9aab0e5ffb70e2aa2919c0d132.tar.gz
bitbake: fetch2: wget add _check_latest_version_by_dir
Add _check_latest_version_by_dir this function provides support for scan every directory newer than current dir in order to get latest_versionstring, example: http://somedoamin.com/project/v2.1/ http://somedoamin.com/project/v3.0/ Change return of _vercmp from True/False to -1/0/1 to provide test when current directory is equal to newer directory this helps to scan the same directory to get minor versions, example: http://somedoamin.com/project/v2.1/project-v2.1.2.tgz http://somedoamin.com/project/v2.1/project-v2.1.6.tgz (Bitbake rev: 5f7c5eb218a221165f59a0f4dd48d2d97f756193) 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.py52
1 files changed, 46 insertions, 6 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index 96d895d6db..c8b120cafd 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -179,10 +179,7 @@ class Wget(FetchMethod):
179 oldpv = self._modelate_version(oldpv) 179 oldpv = self._modelate_version(oldpv)
180 newpv = self._modelate_version(newpv) 180 newpv = self._modelate_version(newpv)
181 181
182 if bb.utils.vercmp(("0", oldpv, ""), ("0", newpv, "")) < 0: 182 return bb.utils.vercmp(("0", oldpv, ""), ("0", newpv, ""))
183 return True
184 else:
185 return False
186 183
187 def _fetch_index(self, uri, ud, d): 184 def _fetch_index(self, uri, ud, d):
188 """ 185 """
@@ -230,7 +227,7 @@ class Wget(FetchMethod):
230 m = regex.search(href['href'].strip("/")) 227 m = regex.search(href['href'].strip("/"))
231 if m: 228 if m:
232 thisversion = ('', m.group(2), '') 229 thisversion = ('', m.group(2), '')
233 if thisversion and self._vercmp(version, thisversion) == True: 230 if thisversion and self._vercmp(version, thisversion) < 0:
234 version = thisversion 231 version = thisversion
235 232
236 if valid: 233 if valid:
@@ -267,7 +264,7 @@ class Wget(FetchMethod):
267 if valid == 0: 264 if valid == 0:
268 version = newver 265 version = newver
269 valid = 1 266 valid = 1
270 elif self._vercmp(version, newver) == True: 267 elif self._vercmp(version, newver) < 0:
271 version = newver 268 version = newver
272 269
273 # check whether a valid package and version were found 270 # check whether a valid package and version were found
@@ -279,6 +276,49 @@ class Wget(FetchMethod):
279 276
280 return "" 277 return ""
281 278
279 def _check_latest_version_by_dir(self, dirver, package, package_regex,
280 current_version, ud, d):
281 """
282 Scan every directory in order to get upstream version.
283 """
284 version_dir = ['', '', '']
285 version = ['', '', '']
286
287 dirver_regex = re.compile("(\D*)((\d+[\.\-_])+(\d+))")
288 s = dirver_regex.search(dirver)
289 if s:
290 version_dir[1] = s.group(2)
291 else:
292 version_dir[1] = dirver
293
294 dirs_uri = bb.fetch.encodeurl([ud.type, ud.host,
295 ud.path.split(dirver)[0], ud.user, ud.pswd, {}])
296 bb.debug(3, "DirURL: %s, %s" % (dirs_uri, package))
297
298 soup = BeautifulSoup(self._fetch_index(dirs_uri, ud, d))
299 if not soup:
300 return version[1]
301
302 for line in soup.find_all('a', href=True):
303 s = dirver_regex.search(line['href'].strip("/"))
304 if s:
305 version_dir_new = ['', s.group(2), '']
306 if self._vercmp(version_dir, version_dir_new) <= 0:
307 dirver_new = s.group(1) + s.group(2)
308 path = ud.path.replace(dirver, dirver_new, True) \
309 .split(package)[0]
310 uri = bb.fetch.encodeurl([ud.type, ud.host, path,
311 ud.user, ud.pswd, {}])
312
313 pupver = self._check_latest_version(uri,
314 package, package_regex, current_version, ud, d)
315 if pupver:
316 version[1] = pupver
317
318 version_dir = version_dir_new
319
320 return version[1]
321
282 def _init_regexes(self, package, ud, d): 322 def _init_regexes(self, package, ud, d):
283 """ 323 """
284 Match as many patterns as possible such as: 324 Match as many patterns as possible such as: