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>
This commit is contained in:
Aníbal Limón 2015-02-13 15:58:10 -06:00 committed by Richard Purdie
parent 309d92efde
commit 62e171b721
1 changed files with 46 additions and 6 deletions

View File

@ -179,10 +179,7 @@ class Wget(FetchMethod):
oldpv = self._modelate_version(oldpv)
newpv = self._modelate_version(newpv)
if bb.utils.vercmp(("0", oldpv, ""), ("0", newpv, "")) < 0:
return True
else:
return False
return bb.utils.vercmp(("0", oldpv, ""), ("0", newpv, ""))
def _fetch_index(self, uri, ud, d):
"""
@ -230,7 +227,7 @@ class Wget(FetchMethod):
m = regex.search(href['href'].strip("/"))
if m:
thisversion = ('', m.group(2), '')
if thisversion and self._vercmp(version, thisversion) == True:
if thisversion and self._vercmp(version, thisversion) < 0:
version = thisversion
if valid:
@ -267,7 +264,7 @@ class Wget(FetchMethod):
if valid == 0:
version = newver
valid = 1
elif self._vercmp(version, newver) == True:
elif self._vercmp(version, newver) < 0:
version = newver
# check whether a valid package and version were found
@ -279,6 +276,49 @@ class Wget(FetchMethod):
return ""
def _check_latest_version_by_dir(self, dirver, package, package_regex,
current_version, ud, d):
"""
Scan every directory in order to get upstream version.
"""
version_dir = ['', '', '']
version = ['', '', '']
dirver_regex = re.compile("(\D*)((\d+[\.\-_])+(\d+))")
s = dirver_regex.search(dirver)
if s:
version_dir[1] = s.group(2)
else:
version_dir[1] = dirver
dirs_uri = bb.fetch.encodeurl([ud.type, ud.host,
ud.path.split(dirver)[0], ud.user, ud.pswd, {}])
bb.debug(3, "DirURL: %s, %s" % (dirs_uri, package))
soup = BeautifulSoup(self._fetch_index(dirs_uri, ud, d))
if not soup:
return version[1]
for line in soup.find_all('a', href=True):
s = dirver_regex.search(line['href'].strip("/"))
if s:
version_dir_new = ['', s.group(2), '']
if self._vercmp(version_dir, version_dir_new) <= 0:
dirver_new = s.group(1) + s.group(2)
path = ud.path.replace(dirver, dirver_new, True) \
.split(package)[0]
uri = bb.fetch.encodeurl([ud.type, ud.host, path,
ud.user, ud.pswd, {}])
pupver = self._check_latest_version(uri,
package, package_regex, current_version, ud, d)
if pupver:
version[1] = pupver
version_dir = version_dir_new
return version[1]
def _init_regexes(self, package, ud, d):
"""
Match as many patterns as possible such as: