From: Luca Falavigna Date: Fri, 20 May 2011 10:01:51 +0000 (+0000) Subject: examine-package: display known virtual packages X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a410acd00cd521410f09efe098a39099711cf1f3;p=dak examine-package: display known virtual packages Dedicated to our beloved Haskell and OCaml folks, now we can process their packages quicker. It's their turn to find a more complicated way to define package dependencies, now :) Signed-off-by: Luca Falavigna --- diff --git a/dak/examine_package.py b/dak/examine_package.py index 38432b11..56408f0a 100755 --- a/dak/examine_package.py +++ b/dak/examine_package.py @@ -117,6 +117,7 @@ ansi_colours = { 'main': "\033[36m", 'contrib': "\033[33m", 'nonfree': "\033[31m", + 'provides': "\033[35m", 'arch': "\033[32m", 'end': "\033[0m", 'bold': "\033[1m", @@ -127,6 +128,7 @@ html_colours = { 'main': ('',""), 'contrib': ('',""), 'nonfree': ('',""), + 'provides': ('',""), 'arch': ('',""), 'bold': ('',""), 'maintainer': ('',""), @@ -322,6 +324,29 @@ def read_changes_or_dsc (suite, filename, session = None): filecontents = '\n'.join(map(lambda x: format_field(x,dsc[x.lower()]), keysinorder))+'\n' return filecontents +def get_provides(suite): + provides = set() + session = DBConn().session() + query = '''SELECT DISTINCT value + FROM binaries_metadata m + JOIN bin_associations b + ON b.bin = m.bin_id + WHERE key_id = ( + SELECT key_id + FROM metadata_keys + WHERE key = 'Provides' ) + AND b.suite = ( + SELECT id + FROM suite + WHERE suite_name = '%(suite)s')''' % \ + {'suite': suite} + for p in session.execute(query): + for e in p: + for i in e.split(','): + provides.add(i.strip()) + session.close() + return provides + def create_depends_string (suite, depends_tree, session = None): result = "" if suite == 'experimental': @@ -329,6 +354,7 @@ def create_depends_string (suite, depends_tree, session = None): else: suite_list = [suite] + provides = set() comma_count = 1 for l in depends_tree: if (comma_count >= 2): @@ -356,7 +382,12 @@ def create_depends_string (suite, depends_tree, session = None): adepends = d['name'] if d['version'] != '' : adepends += " (%s)" % (d['version']) - result += colour_output(adepends, "bold") + if not provides: + provides = get_provides(suite) + if d['name'] in provides: + result += colour_output(adepends, "provides") + else: + result += colour_output(adepends, "bold") or_count += 1 comma_count += 1 return result