euscan: clean quirks and fix htop

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
This commit is contained in:
Corentin Chary 2011-08-03 11:54:45 +02:00
parent 142cfe0924
commit 5474d6f03e

65
euscan
View File

@ -45,13 +45,41 @@ from gentoolkit.eclean.search import (port_settings)
QUERY_OPTS = {"include_masked": True} QUERY_OPTS = {"include_masked": True}
BLACKLIST_PACKAGES = ['sys-kernel/usermode-sources', 'sys-kernel/xbox-sources', BLACKLIST_PACKAGES = [
'sys-kernel/cell-sources', 'sys-libs/libstdc++-v3'] # Compatibility package for running binaries linked against a pre gcc 3.4 libstdc++, won't be updated
'sys-libs/libstdc++-v3'
# These kernels are almost dead
'sys-kernel/usermode-sources',
'sys-kernel/xbox-sources',
'sys-kernel/cell-sources',
]
SCANDIR_BLACKLIST_URLS = ['mirror://rubygems/(.*)', 'mirror://gentoo/(.*)'] SCANDIR_BLACKLIST_URLS = [
'mirror://rubygems/(.*)', # Not browsable
'mirror://gentoo/(.*)' # Directory too big
]
BRUTEFORCE_BLACKLIST_PACKAGES = ['dev-util/patchelf', 'net-zope/plonepopoll'] BRUTEFORCE_BLACKLIST_PACKAGES = [
BRUTEFORCE_BLACKLIST_URLS = ['http://(.*)dockapps.org/download.php/id/(.*)', 'http://hydra.nixos.org/build/(.*)'] 'net-zope/plonepopoll' # infinite loop any http://plone.org/products/plonepopoll/releases/*/plonepopoll-2-6-1.tgz link will work
]
BRUTEFORCE_BLACKLIST_URLS = [
'http://(.*)dockapps.org/download.php/id/(.*)', # infinite loop
'http://hydra.nixos.org/build/(.*)' # infinite loop
]
def htop_vercmp(a, b):
def fixver(v):
if v in ['0.11', '0.12', '0.13']:
v = '0.1.' + v[3:]
print (v)
return v
return simple_vercmp(fixver(a), fixver(b))
VERSION_CMP_PACKAGE_QUIRKS = {
'sys-process/htop' : htop_vercmp
}
_v = r'((\d+)((\.\d+)*)([a-zA-Z]*?)(((-|_)(pre|p|beta|b|alpha|a|rc|r)\d*)*))' _v = r'((\d+)((\.\d+)*)([a-zA-Z]*?)(((-|_)(pre|p|beta|b|alpha|a|rc|r)\d*)*))'
@ -67,7 +95,7 @@ def cast_int_components(version):
pass pass
return version return version
def vercmp(a, b): def simple_vercmp(a, b):
if a == b: if a == b:
return 0 return 0
@ -86,6 +114,13 @@ def vercmp(a, b):
else: else:
return 1 return 1
def vercmp(package, a, b):
print (package, a, b)
if package in VERSION_CMP_PACKAGE_QUIRKS:
return VERSION_CMP_PACKAGE_QUIRKS[package](a, b)
print("fail")
return simple_vercmp(a, b)
def skipnightly(a, b): def skipnightly(a, b):
a = pkg_resources.parse_version(a) a = pkg_resources.parse_version(a)
b = pkg_resources.parse_version(b) b = pkg_resources.parse_version(b)
@ -220,6 +255,7 @@ def tryurl(fileurl, output, template):
if result: if result:
result = (fp.geturl(), fp.info()) result = (fp.geturl(), fp.info())
except urllib2.URLError: except urllib2.URLError:
result = None result = None
except IOError: except IOError:
@ -270,10 +306,11 @@ def generate_scan_paths(url):
path += chunk path += chunk
return steps return steps
def scan_directory_recursive(url, steps, vmin, vmax, output): def scan_directory_recursive(cpv, url, steps, vmin, vmax, output):
if not steps: if not steps:
return [] return []
cp, ver, rev = portage.pkgsplit(cpv)
url += steps[0][0] url += steps[0][0]
pattern = steps[0][1] pattern = steps[0][1]
@ -320,9 +357,9 @@ def scan_directory_recursive(url, steps, vmin, vmax, output):
versions = [] versions = []
for version, path in results: for version, path in results:
if vmin and vercmp(version, vmin) <= 0: if vmin and vercmp(cp, version, vmin) <= 0:
continue continue
if vmax and vercmp(version, vmax) >= 0: if vmax and vercmp(cp, version, vmax) >= 0:
continue continue
if skipnightly(vmin, version): if skipnightly(vmin, version):
@ -356,7 +393,7 @@ def scan_directory(cpv, fileurl, options, output, limit=None):
output.einfo("Scanning: %s" % template) output.einfo("Scanning: %s" % template)
steps = generate_scan_paths(template) steps = generate_scan_paths(template)
return scan_directory_recursive("", steps, ver, limit, output) return scan_directory_recursive(cpv, "", steps, ver, limit, output)
def brute_force(cpv, fileurl, options, output, limit=None): def brute_force(cpv, fileurl, options, output, limit=None):
if options["brute-force"] <= 0: if options["brute-force"] <= 0:
@ -377,6 +414,12 @@ def brute_force(cpv, fileurl, options, output, limit=None):
components = split_version(ver) components = split_version(ver)
versions = gen_versions(components, options["brute-force"]) versions = gen_versions(components, options["brute-force"])
""" Use the quirks to remove unwanted versions """
for v in versions:
if vercmp(catpkg, ver, join_version(v)) >= 0:
versions.remove(v)
output.einfo("Generating version from " + ver) output.einfo("Generating version from " + ver)
if not versions: if not versions:
@ -406,7 +449,7 @@ def brute_force(cpv, fileurl, options, output, limit=None):
vstring = join_version(components) vstring = join_version(components)
if limit and vercmp(vstring, limit) >= 0: if limit and vercmp(catpkg, vstring, limit) >= 0:
continue continue
url = url_from_template(template, vstring) url = url_from_template(template, vstring)