1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-31 00:39:46 +00:00

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>
This commit is contained in:
Aníbal Limón
2014-11-27 19:12:03 -06:00
committed by Richard Purdie
parent a7bdd0eb29
commit cd40af6b1d
+28 -25
View File
@@ -197,7 +197,7 @@ class Wget(FetchMethod):
bb.debug(3, "DirURL: %s, %s" % (url, versionstring)) bb.debug(3, "DirURL: %s, %s" % (url, versionstring))
soup = BeautifulSoup(self._fetch_index(url, ud, d)) soup = BeautifulSoup(self._fetch_index(url, ud, d))
if not soup: if not soup:
return "" return None
valid = 0 valid = 0
prefix = '' prefix = ''
@@ -225,21 +225,21 @@ class Wget(FetchMethod):
return prefix+version[1] return prefix+version[1]
else: else:
bb.debug(3, "Not Valid") bb.debug(3, "Not Valid")
return "" return None
def _check_latest_version(self, url, packagename, ud, d): def _check_latest_version(self, url, package, ud, d):
""" """
Return the latest version of a package inside a given directory path Return the latest version of a package inside a given directory path
If error or no version, return "" If error or no version, return ""
""" """
valid = 0 valid = 0
version = self._parse_path(self.package_regex_comp, packagename) version = self._parse_path(self.package_regex_comp, package)
bb.debug(3, "VersionURL: %s" % (url)) bb.debug(3, "VersionURL: %s" % (url))
soup = BeautifulSoup(self._fetch_index(url, ud, d)) soup = BeautifulSoup(self._fetch_index(url, ud, d))
if not soup: if not soup:
bb.debug(3, "*** %s NO SOUP" % (packagename)) bb.debug(3, "*** %s NO SOUP" % (package))
return "" return None
pn_regex = d.getVar('REGEX', True) pn_regex = d.getVar('REGEX', True)
if pn_regex: if pn_regex:
@@ -269,10 +269,12 @@ class Wget(FetchMethod):
version = ('', '', '') version = ('', '', '')
if not pn_regex: if not pn_regex:
testversion = ('', '', '') testversion = ('', '', '')
bb.debug(3, "*** %s -> %s (TestVersion = %s)" % (packagename, version[1], testversion[1])) bb.debug(3, "*** %s -> %s (TestVersion = %s)" % (package, version[1], testversion[1]))
if valid and version: if valid and version:
return re.sub('_', '.', version[1]) return re.sub('_', '.', version[1])
return None
def _init_regexes(self): def _init_regexes(self):
""" """
Match as many patterns as possible such as: Match as many patterns as possible such as:
@@ -321,36 +323,37 @@ class Wget(FetchMethod):
sanity check to ensure same name and type. sanity check to ensure same name and type.
""" """
package = ud.path.split("/")[-1]
regex_uri = d.getVar("REGEX_URI", True) regex_uri = d.getVar("REGEX_URI", True)
newpath = ud.path newpath = regex_uri or ud.path
pupver = "" pupver = ""
self._init_regexes() self._init_regexes()
m = self.dirver_regex_comp.search(ud.path) if not regex_uri:
bb.debug(3, "path = %s" % (ud.path)) # generate the new uri with the appropriate latest directory
bb.debug(3, "Regex: %s" % (self.package_regex_comp.pattern)) m = self.dirver_regex_comp.search(ud.path)
if m and not regex_uri: if m:
dirver = m.group('dirver') dirver = m.group('dirver')
# generate the new uri after removing version directory name newuri = bb.fetch.encodeurl([ud.type, ud.host,
newuri = bb.fetch.encodeurl([ud.type, ud.host, ud.path.split(dirver)[0], ud.user, ud.pswd, {}]) ud.path.split(dirver)[0], ud.user, ud.pswd, {}])
newversion = self._check_latest_dir(newuri, dirver, ud, d) new_dirver = self._check_latest_dir(newuri, dirver, ud, d)
if newversion and dirver != newversion: if new_dirver and dirver != new_dirver:
newpath = ud.path.replace(dirver, newversion, True) newpath = ud.path.replace(dirver, new_dirver, True)
# try to acquire all remote files in current directory newpath = newpath.split(package)[0] or "/" # path to directory
packagename = newpath.split("/")[-1] # current package name newuri = bb.fetch.encodeurl([ud.type, ud.host, newpath, ud.user, ud.pswd, {}])
newpath = newpath.split(packagename)[0] or "/" # path to directory else:
newuri = newpath
# generate the new uri with the appropriate latest directory # generate the new uri with the appropriate latest directory
newuri = regex_uri or bb.fetch.encodeurl([ud.type, ud.host, newpath, ud.user, ud.pswd, {}]) newuri = regex_uri or bb.fetch.encodeurl([ud.type, ud.host, newpath, ud.user, ud.pswd, {}])
newversion = self._check_latest_version(newuri, packagename, ud, d) newversion = self._check_latest_version(newuri, package, ud, d)
while not newversion: while not newversion:
# maybe it's hiding in a download directory so try there # maybe it's hiding in a download directory so try there
newuri = "/".join(newuri.split("/")[0:-2]) + "/download" newuri = "/".join(newuri.split("/")[0:-2]) + "/download"
if newuri == "/download" or newuri == "http://download": if newuri == "/download" or newuri == "http://download":
break break
newversion = self._check_latest_version(newuri, packagename, ud, d) newversion = self._check_latest_version(newuri, package, ud, d)
return newversion
return newversion or ""