2011-08-31 15:38:32 +02:00
|
|
|
import re
|
|
|
|
import portage
|
|
|
|
import urllib2
|
|
|
|
import xml.dom.minidom
|
|
|
|
|
2012-05-23 16:30:43 +02:00
|
|
|
from euscan import helpers, output
|
|
|
|
|
|
|
|
HANDLER_NAME = "php"
|
2012-05-23 16:44:44 +02:00
|
|
|
CONFIDENCE = 100.0
|
2012-06-28 11:08:05 +02:00
|
|
|
PRIORITY = 100
|
2011-08-31 15:38:32 +02:00
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-08-31 15:38:32 +02:00
|
|
|
def can_handle(cpv, url):
|
|
|
|
if url.startswith('http://pear.php.net/get/'):
|
|
|
|
return True
|
|
|
|
if url.startswith('http://pecl.php.net/get/'):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-08-31 15:38:32 +02:00
|
|
|
def guess_package_and_channel(cp, url):
|
|
|
|
match = re.search('http://(.*)/get/(.*)-(.*).tgz', url)
|
|
|
|
|
|
|
|
if match:
|
|
|
|
host = match.group(1)
|
|
|
|
pkg = match.group(2)
|
|
|
|
else:
|
|
|
|
cat, pkg = cp.split("/")
|
|
|
|
|
|
|
|
return pkg, host
|
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-08-31 15:38:32 +02:00
|
|
|
def scan(cpv, url):
|
2012-04-20 17:27:16 +02:00
|
|
|
cp, ver, rev = portage.pkgsplit(cpv)
|
|
|
|
pkg, channel = guess_package_and_channel(cp, url)
|
2011-08-31 15:38:32 +02:00
|
|
|
|
|
|
|
orig_url = url
|
|
|
|
url = 'http://%s/rest/r/%s/allreleases.xml' % (channel, pkg.lower())
|
|
|
|
|
2012-05-23 16:30:43 +02:00
|
|
|
output.einfo("Using: " + url)
|
2011-08-31 15:38:32 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
fp = helpers.urlopen(url)
|
|
|
|
except urllib2.URLError:
|
|
|
|
return []
|
|
|
|
except IOError:
|
|
|
|
return []
|
|
|
|
|
2011-09-06 16:32:29 +02:00
|
|
|
if not fp:
|
|
|
|
return []
|
|
|
|
|
2011-08-31 15:38:32 +02:00
|
|
|
data = fp.read()
|
|
|
|
|
|
|
|
dom = xml.dom.minidom.parseString(data)
|
|
|
|
|
|
|
|
nodes = dom.getElementsByTagName("v")
|
|
|
|
ret = []
|
|
|
|
|
|
|
|
for node in nodes:
|
2012-04-19 15:36:44 +02:00
|
|
|
up_pv = node.childNodes[0].data
|
|
|
|
pv = helpers.gentoo_mangle_version(up_pv)
|
|
|
|
if helpers.version_filtered(cp, ver, pv):
|
2011-08-31 15:38:32 +02:00
|
|
|
continue
|
|
|
|
|
2012-04-19 15:36:44 +02:00
|
|
|
url = 'http://%s/get/%s-%s.tgz' % (channel, pkg, up_pv)
|
2011-08-31 15:38:32 +02:00
|
|
|
|
|
|
|
if url == orig_url:
|
|
|
|
continue
|
|
|
|
|
2012-05-23 16:44:44 +02:00
|
|
|
ret.append((url, pv, HANDLER_NAME, CONFIDENCE))
|
2011-08-31 15:38:32 +02:00
|
|
|
|
|
|
|
return ret
|
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-08-31 15:38:32 +02:00
|
|
|
def brute_force(cpv, url):
|
|
|
|
return []
|