wget.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. # ex:ts=4:sw=4:sts=4:et
  2. # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
  3. """
  4. BitBake 'Fetch' implementations
  5. Classes for obtaining upstream sources for the
  6. BitBake build tools.
  7. """
  8. # Copyright (C) 2003, 2004 Chris Larson
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License version 2 as
  12. # published by the Free Software Foundation.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License along
  20. # with this program; if not, write to the Free Software Foundation, Inc.,
  21. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. #
  23. # Based on functions from the base bb module, Copyright 2003 Holger Schurig
  24. import re
  25. import tempfile
  26. import subprocess
  27. import os
  28. import logging
  29. import bb
  30. import bb.progress
  31. import urllib.request, urllib.parse, urllib.error
  32. from bb import data
  33. from bb.fetch2 import FetchMethod
  34. from bb.fetch2 import FetchError
  35. from bb.fetch2 import logger
  36. from bb.fetch2 import runfetchcmd
  37. from bb.utils import export_proxies
  38. from bs4 import BeautifulSoup
  39. from bs4 import SoupStrainer
  40. class WgetProgressHandler(bb.progress.LineFilterProgressHandler):
  41. """
  42. Extract progress information from wget output.
  43. Note: relies on --progress=dot (with -v or without -q/-nv) being
  44. specified on the wget command line.
  45. """
  46. def __init__(self, d):
  47. super(WgetProgressHandler, self).__init__(d)
  48. # Send an initial progress event so the bar gets shown
  49. self._fire_progress(0)
  50. def writeline(self, line):
  51. percs = re.findall(r'(\d+)%\s+([\d.]+[A-Z])', line)
  52. if percs:
  53. progress = int(percs[-1][0])
  54. rate = percs[-1][1] + '/s'
  55. self.update(progress, rate)
  56. return False
  57. return True
  58. class Wget(FetchMethod):
  59. """Class to fetch urls via 'wget'"""
  60. def supports(self, ud, d):
  61. """
  62. Check to see if a given url can be fetched with wget.
  63. """
  64. return ud.type in ['http', 'https', 'ftp']
  65. def recommends_checksum(self, urldata):
  66. return True
  67. def urldata_init(self, ud, d):
  68. if 'protocol' in ud.parm:
  69. if ud.parm['protocol'] == 'git':
  70. raise bb.fetch2.ParameterError("Invalid protocol - if you wish to fetch from a git repository using http, you need to instead use the git:// prefix with protocol=http", ud.url)
  71. if 'downloadfilename' in ud.parm:
  72. ud.basename = ud.parm['downloadfilename']
  73. else:
  74. ud.basename = os.path.basename(ud.path)
  75. ud.localfile = data.expand(urllib.parse.unquote(ud.basename), d)
  76. if not ud.localfile:
  77. ud.localfile = data.expand(urllib.parse.unquote(ud.host + ud.path).replace("/", "."), d)
  78. self.basecmd = d.getVar("FETCHCMD_wget") or "/usr/bin/env wget -t 2 -T 30 --passive-ftp --no-check-certificate"
  79. def _runwget(self, ud, d, command, quiet):
  80. progresshandler = WgetProgressHandler(d)
  81. logger.debug(2, "Fetching %s using command '%s'" % (ud.url, command))
  82. bb.fetch2.check_network_access(d, command)
  83. runfetchcmd(command + ' --progress=dot -v', d, quiet, log=progresshandler)
  84. def download(self, ud, d):
  85. """Fetch urls"""
  86. fetchcmd = self.basecmd
  87. if 'downloadfilename' in ud.parm:
  88. dldir = d.getVar("DL_DIR")
  89. bb.utils.mkdirhier(os.path.dirname(dldir + os.sep + ud.localfile))
  90. fetchcmd += " -O " + dldir + os.sep + ud.localfile
  91. if ud.user:
  92. up = ud.user.split(":")
  93. fetchcmd += " --user=%s --password=%s --auth-no-challenge" % (up[0],up[1])
  94. uri = ud.url.split(";")[0]
  95. if os.path.exists(ud.localpath):
  96. # file exists, but we didnt complete it.. trying again..
  97. fetchcmd += d.expand(" -c -P ${DL_DIR} '%s'" % uri)
  98. else:
  99. fetchcmd += d.expand(" -P ${DL_DIR} '%s'" % uri)
  100. self._runwget(ud, d, fetchcmd, False)
  101. # Sanity check since wget can pretend it succeed when it didn't
  102. # Also, this used to happen if sourceforge sent us to the mirror page
  103. if not os.path.exists(ud.localpath):
  104. raise FetchError("The fetch command returned success for url %s but %s doesn't exist?!" % (uri, ud.localpath), uri)
  105. if os.path.getsize(ud.localpath) == 0:
  106. os.remove(ud.localpath)
  107. raise FetchError("The fetch of %s resulted in a zero size file?! Deleting and failing since this isn't right." % (uri), uri)
  108. return True
  109. def checkstatus(self, fetch, ud, d, try_again=True):
  110. import urllib.request, urllib.error, urllib.parse, socket, http.client
  111. from urllib.response import addinfourl
  112. from bb.fetch2 import FetchConnectionCache
  113. class HTTPConnectionCache(http.client.HTTPConnection):
  114. if fetch.connection_cache:
  115. def connect(self):
  116. """Connect to the host and port specified in __init__."""
  117. sock = fetch.connection_cache.get_connection(self.host, self.port)
  118. if sock:
  119. self.sock = sock
  120. else:
  121. self.sock = socket.create_connection((self.host, self.port),
  122. self.timeout, self.source_address)
  123. fetch.connection_cache.add_connection(self.host, self.port, self.sock)
  124. if self._tunnel_host:
  125. self._tunnel()
  126. class CacheHTTPHandler(urllib.request.HTTPHandler):
  127. def http_open(self, req):
  128. return self.do_open(HTTPConnectionCache, req)
  129. def do_open(self, http_class, req):
  130. """Return an addinfourl object for the request, using http_class.
  131. http_class must implement the HTTPConnection API from httplib.
  132. The addinfourl return value is a file-like object. It also
  133. has methods and attributes including:
  134. - info(): return a mimetools.Message object for the headers
  135. - geturl(): return the original request URL
  136. - code: HTTP status code
  137. """
  138. host = req.host
  139. if not host:
  140. raise urlllib2.URLError('no host given')
  141. h = http_class(host, timeout=req.timeout) # will parse host:port
  142. h.set_debuglevel(self._debuglevel)
  143. headers = dict(req.unredirected_hdrs)
  144. headers.update(dict((k, v) for k, v in list(req.headers.items())
  145. if k not in headers))
  146. # We want to make an HTTP/1.1 request, but the addinfourl
  147. # class isn't prepared to deal with a persistent connection.
  148. # It will try to read all remaining data from the socket,
  149. # which will block while the server waits for the next request.
  150. # So make sure the connection gets closed after the (only)
  151. # request.
  152. # Don't close connection when connection_cache is enabled,
  153. if fetch.connection_cache is None:
  154. headers["Connection"] = "close"
  155. else:
  156. headers["Connection"] = "Keep-Alive" # Works for HTTP/1.0
  157. headers = dict(
  158. (name.title(), val) for name, val in list(headers.items()))
  159. if req._tunnel_host:
  160. tunnel_headers = {}
  161. proxy_auth_hdr = "Proxy-Authorization"
  162. if proxy_auth_hdr in headers:
  163. tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
  164. # Proxy-Authorization should not be sent to origin
  165. # server.
  166. del headers[proxy_auth_hdr]
  167. h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
  168. try:
  169. h.request(req.get_method(), req.selector, req.data, headers)
  170. except socket.error as err: # XXX what error?
  171. # Don't close connection when cache is enabled.
  172. if fetch.connection_cache is None:
  173. h.close()
  174. raise urllib.error.URLError(err)
  175. else:
  176. try:
  177. r = h.getresponse(buffering=True)
  178. except TypeError: # buffering kw not supported
  179. r = h.getresponse()
  180. # Pick apart the HTTPResponse object to get the addinfourl
  181. # object initialized properly.
  182. # Wrap the HTTPResponse object in socket's file object adapter
  183. # for Windows. That adapter calls recv(), so delegate recv()
  184. # to read(). This weird wrapping allows the returned object to
  185. # have readline() and readlines() methods.
  186. # XXX It might be better to extract the read buffering code
  187. # out of socket._fileobject() and into a base class.
  188. r.recv = r.read
  189. # no data, just have to read
  190. r.read()
  191. class fp_dummy(object):
  192. def read(self):
  193. return ""
  194. def readline(self):
  195. return ""
  196. def close(self):
  197. pass
  198. resp = addinfourl(fp_dummy(), r.msg, req.get_full_url())
  199. resp.code = r.status
  200. resp.msg = r.reason
  201. # Close connection when server request it.
  202. if fetch.connection_cache is not None:
  203. if 'Connection' in r.msg and r.msg['Connection'] == 'close':
  204. fetch.connection_cache.remove_connection(h.host, h.port)
  205. return resp
  206. class HTTPMethodFallback(urllib.request.BaseHandler):
  207. """
  208. Fallback to GET if HEAD is not allowed (405 HTTP error)
  209. """
  210. def http_error_405(self, req, fp, code, msg, headers):
  211. fp.read()
  212. fp.close()
  213. newheaders = dict((k,v) for k,v in list(req.headers.items())
  214. if k.lower() not in ("content-length", "content-type"))
  215. return self.parent.open(urllib.request.Request(req.get_full_url(),
  216. headers=newheaders,
  217. origin_req_host=req.origin_req_host,
  218. unverifiable=True))
  219. """
  220. Some servers (e.g. GitHub archives, hosted on Amazon S3) return 403
  221. Forbidden when they actually mean 405 Method Not Allowed.
  222. """
  223. http_error_403 = http_error_405
  224. """
  225. Some servers (e.g. FusionForge) returns 406 Not Acceptable when they
  226. actually mean 405 Method Not Allowed.
  227. """
  228. http_error_406 = http_error_405
  229. class FixedHTTPRedirectHandler(urllib.request.HTTPRedirectHandler):
  230. """
  231. urllib2.HTTPRedirectHandler resets the method to GET on redirect,
  232. when we want to follow redirects using the original method.
  233. """
  234. def redirect_request(self, req, fp, code, msg, headers, newurl):
  235. newreq = urllib.request.HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, headers, newurl)
  236. newreq.get_method = lambda: req.get_method()
  237. return newreq
  238. exported_proxies = export_proxies(d)
  239. handlers = [FixedHTTPRedirectHandler, HTTPMethodFallback]
  240. if export_proxies:
  241. handlers.append(urllib.request.ProxyHandler())
  242. handlers.append(CacheHTTPHandler())
  243. # XXX: Since Python 2.7.9 ssl cert validation is enabled by default
  244. # see PEP-0476, this causes verification errors on some https servers
  245. # so disable by default.
  246. import ssl
  247. if hasattr(ssl, '_create_unverified_context'):
  248. handlers.append(urllib.request.HTTPSHandler(context=ssl._create_unverified_context()))
  249. opener = urllib.request.build_opener(*handlers)
  250. try:
  251. uri = ud.url.split(";")[0]
  252. r = urllib.request.Request(uri)
  253. r.get_method = lambda: "HEAD"
  254. if ud.user:
  255. import base64
  256. encodeuser = base64.b64encode(ud.user.encode('utf-8')).decode("utf-8")
  257. authheader = "Basic %s" % encodeuser
  258. r.add_header("Authorization", authheader)
  259. opener.open(r)
  260. except urllib.error.URLError as e:
  261. if try_again:
  262. logger.debug(2, "checkstatus: trying again")
  263. return self.checkstatus(fetch, ud, d, False)
  264. else:
  265. # debug for now to avoid spamming the logs in e.g. remote sstate searches
  266. logger.debug(2, "checkstatus() urlopen failed: %s" % e)
  267. return False
  268. return True
  269. def _parse_path(self, regex, s):
  270. """
  271. Find and group name, version and archive type in the given string s
  272. """
  273. m = regex.search(s)
  274. if m:
  275. pname = ''
  276. pver = ''
  277. ptype = ''
  278. mdict = m.groupdict()
  279. if 'name' in mdict.keys():
  280. pname = mdict['name']
  281. if 'pver' in mdict.keys():
  282. pver = mdict['pver']
  283. if 'type' in mdict.keys():
  284. ptype = mdict['type']
  285. bb.debug(3, "_parse_path: %s, %s, %s" % (pname, pver, ptype))
  286. return (pname, pver, ptype)
  287. return None
  288. def _modelate_version(self, version):
  289. if version[0] in ['.', '-']:
  290. if version[1].isdigit():
  291. version = version[1] + version[0] + version[2:len(version)]
  292. else:
  293. version = version[1:len(version)]
  294. version = re.sub('-', '.', version)
  295. version = re.sub('_', '.', version)
  296. version = re.sub('(rc)+', '.1000.', version)
  297. version = re.sub('(beta)+', '.100.', version)
  298. version = re.sub('(alpha)+', '.10.', version)
  299. if version[0] == 'v':
  300. version = version[1:len(version)]
  301. return version
  302. def _vercmp(self, old, new):
  303. """
  304. Check whether 'new' is newer than 'old' version. We use existing vercmp() for the
  305. purpose. PE is cleared in comparison as it's not for build, and PR is cleared too
  306. for simplicity as it's somehow difficult to get from various upstream format
  307. """
  308. (oldpn, oldpv, oldsuffix) = old
  309. (newpn, newpv, newsuffix) = new
  310. """
  311. Check for a new suffix type that we have never heard of before
  312. """
  313. if (newsuffix):
  314. m = self.suffix_regex_comp.search(newsuffix)
  315. if not m:
  316. bb.warn("%s has a possible unknown suffix: %s" % (newpn, newsuffix))
  317. return False
  318. """
  319. Not our package so ignore it
  320. """
  321. if oldpn != newpn:
  322. return False
  323. oldpv = self._modelate_version(oldpv)
  324. newpv = self._modelate_version(newpv)
  325. return bb.utils.vercmp(("0", oldpv, ""), ("0", newpv, ""))
  326. def _fetch_index(self, uri, ud, d):
  327. """
  328. Run fetch checkstatus to get directory information
  329. """
  330. f = tempfile.NamedTemporaryFile()
  331. agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/9.10 (karmic) Firefox/3.6.12"
  332. fetchcmd = self.basecmd
  333. fetchcmd += " -O " + f.name + " --user-agent='" + agent + "' '" + uri + "'"
  334. try:
  335. self._runwget(ud, d, fetchcmd, True)
  336. fetchresult = f.read()
  337. except bb.fetch2.BBFetchException:
  338. fetchresult = ""
  339. f.close()
  340. return fetchresult
  341. def _check_latest_version(self, url, package, package_regex, current_version, ud, d):
  342. """
  343. Return the latest version of a package inside a given directory path
  344. If error or no version, return ""
  345. """
  346. valid = 0
  347. version = ['', '', '']
  348. bb.debug(3, "VersionURL: %s" % (url))
  349. soup = BeautifulSoup(self._fetch_index(url, ud, d), "html.parser", parse_only=SoupStrainer("a"))
  350. if not soup:
  351. bb.debug(3, "*** %s NO SOUP" % (url))
  352. return ""
  353. for line in soup.find_all('a', href=True):
  354. bb.debug(3, "line['href'] = '%s'" % (line['href']))
  355. bb.debug(3, "line = '%s'" % (str(line)))
  356. newver = self._parse_path(package_regex, line['href'])
  357. if not newver:
  358. newver = self._parse_path(package_regex, str(line))
  359. if newver:
  360. bb.debug(3, "Upstream version found: %s" % newver[1])
  361. if valid == 0:
  362. version = newver
  363. valid = 1
  364. elif self._vercmp(version, newver) < 0:
  365. version = newver
  366. pupver = re.sub('_', '.', version[1])
  367. bb.debug(3, "*** %s -> UpstreamVersion = %s (CurrentVersion = %s)" %
  368. (package, pupver or "N/A", current_version[1]))
  369. if valid:
  370. return pupver
  371. return ""
  372. def _check_latest_version_by_dir(self, dirver, package, package_regex,
  373. current_version, ud, d):
  374. """
  375. Scan every directory in order to get upstream version.
  376. """
  377. version_dir = ['', '', '']
  378. version = ['', '', '']
  379. dirver_regex = re.compile("(?P<pfx>\D*)(?P<ver>(\d+[\.\-_])+(\d+))")
  380. s = dirver_regex.search(dirver)
  381. if s:
  382. version_dir[1] = s.group('ver')
  383. else:
  384. version_dir[1] = dirver
  385. dirs_uri = bb.fetch.encodeurl([ud.type, ud.host,
  386. ud.path.split(dirver)[0], ud.user, ud.pswd, {}])
  387. bb.debug(3, "DirURL: %s, %s" % (dirs_uri, package))
  388. soup = BeautifulSoup(self._fetch_index(dirs_uri, ud, d), "html.parser", parse_only=SoupStrainer("a"))
  389. if not soup:
  390. return version[1]
  391. for line in soup.find_all('a', href=True):
  392. s = dirver_regex.search(line['href'].strip("/"))
  393. if s:
  394. sver = s.group('ver')
  395. # When prefix is part of the version directory it need to
  396. # ensure that only version directory is used so remove previous
  397. # directories if exists.
  398. #
  399. # Example: pfx = '/dir1/dir2/v' and version = '2.5' the expected
  400. # result is v2.5.
  401. spfx = s.group('pfx').split('/')[-1]
  402. version_dir_new = ['', sver, '']
  403. if self._vercmp(version_dir, version_dir_new) <= 0:
  404. dirver_new = spfx + sver
  405. path = ud.path.replace(dirver, dirver_new, True) \
  406. .split(package)[0]
  407. uri = bb.fetch.encodeurl([ud.type, ud.host, path,
  408. ud.user, ud.pswd, {}])
  409. pupver = self._check_latest_version(uri,
  410. package, package_regex, current_version, ud, d)
  411. if pupver:
  412. version[1] = pupver
  413. version_dir = version_dir_new
  414. return version[1]
  415. def _init_regexes(self, package, ud, d):
  416. """
  417. Match as many patterns as possible such as:
  418. gnome-common-2.20.0.tar.gz (most common format)
  419. gtk+-2.90.1.tar.gz
  420. xf86-input-synaptics-12.6.9.tar.gz
  421. dri2proto-2.3.tar.gz
  422. blktool_4.orig.tar.gz
  423. libid3tag-0.15.1b.tar.gz
  424. unzip552.tar.gz
  425. icu4c-3_6-src.tgz
  426. genext2fs_1.3.orig.tar.gz
  427. gst-fluendo-mp3
  428. """
  429. # match most patterns which uses "-" as separator to version digits
  430. pn_prefix1 = "[a-zA-Z][a-zA-Z0-9]*([-_][a-zA-Z]\w+)*\+?[-_]"
  431. # a loose pattern such as for unzip552.tar.gz
  432. pn_prefix2 = "[a-zA-Z]+"
  433. # a loose pattern such as for 80325-quicky-0.4.tar.gz
  434. pn_prefix3 = "[0-9]+[-]?[a-zA-Z]+"
  435. # Save the Package Name (pn) Regex for use later
  436. pn_regex = "(%s|%s|%s)" % (pn_prefix1, pn_prefix2, pn_prefix3)
  437. # match version
  438. pver_regex = "(([A-Z]*\d+[a-zA-Z]*[\.\-_]*)+)"
  439. # match arch
  440. parch_regex = "-source|_all_"
  441. # src.rpm extension was added only for rpm package. Can be removed if the rpm
  442. # packaged will always be considered as having to be manually upgraded
  443. 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)"
  444. # match name, version and archive type of a package
  445. package_regex_comp = re.compile("(?P<name>%s?\.?v?)(?P<pver>%s)(?P<arch>%s)?[\.-](?P<type>%s$)"
  446. % (pn_regex, pver_regex, parch_regex, psuffix_regex))
  447. self.suffix_regex_comp = re.compile(psuffix_regex)
  448. # compile regex, can be specific by package or generic regex
  449. pn_regex = d.getVar('UPSTREAM_CHECK_REGEX')
  450. if pn_regex:
  451. package_custom_regex_comp = re.compile(pn_regex)
  452. else:
  453. version = self._parse_path(package_regex_comp, package)
  454. if version:
  455. package_custom_regex_comp = re.compile(
  456. "(?P<name>%s)(?P<pver>%s)(?P<arch>%s)?[\.-](?P<type>%s)" %
  457. (re.escape(version[0]), pver_regex, parch_regex, psuffix_regex))
  458. else:
  459. package_custom_regex_comp = None
  460. return package_custom_regex_comp
  461. def latest_versionstring(self, ud, d):
  462. """
  463. Manipulate the URL and try to obtain the latest package version
  464. sanity check to ensure same name and type.
  465. """
  466. package = ud.path.split("/")[-1]
  467. current_version = ['', d.getVar('PV'), '']
  468. """possible to have no version in pkg name, such as spectrum-fw"""
  469. if not re.search("\d+", package):
  470. current_version[1] = re.sub('_', '.', current_version[1])
  471. current_version[1] = re.sub('-', '.', current_version[1])
  472. return (current_version[1], '')
  473. package_regex = self._init_regexes(package, ud, d)
  474. if package_regex is None:
  475. bb.warn("latest_versionstring: package %s don't match pattern" % (package))
  476. return ('', '')
  477. bb.debug(3, "latest_versionstring, regex: %s" % (package_regex.pattern))
  478. uri = ""
  479. regex_uri = d.getVar("UPSTREAM_CHECK_URI")
  480. if not regex_uri:
  481. path = ud.path.split(package)[0]
  482. # search for version matches on folders inside the path, like:
  483. # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz
  484. dirver_regex = re.compile("(?P<dirver>[^/]*(\d+\.)*\d+([-_]r\d+)*)/")
  485. m = dirver_regex.search(path)
  486. if m:
  487. pn = d.getVar('PN')
  488. dirver = m.group('dirver')
  489. dirver_pn_regex = re.compile("%s\d?" % (re.escape(pn)))
  490. if not dirver_pn_regex.search(dirver):
  491. return (self._check_latest_version_by_dir(dirver,
  492. package, package_regex, current_version, ud, d), '')
  493. uri = bb.fetch.encodeurl([ud.type, ud.host, path, ud.user, ud.pswd, {}])
  494. else:
  495. uri = regex_uri
  496. return (self._check_latest_version(uri, package, package_regex,
  497. current_version, ud, d), '')