X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=dak%2Fexamine_package.py;h=38432b11df82052861fb4d83d718f3aeb16c6344;hb=581e335a6c23d9752d7b88b688537a0ef7072b0b;hp=617fc7ad77f6ed04f2bf437ab828e76eca87927d;hpb=7d54be11252ff02c378999fab7a6e873425f974b;p=dak.git
diff --git a/dak/examine_package.py b/dak/examine_package.py
index 617fc7ad..38432b11 100755
--- a/dak/examine_package.py
+++ b/dak/examine_package.py
@@ -42,6 +42,12 @@ to stdout. Those functions can be used in multithreaded parts of dak.
################################################################################
+# suppress some deprecation warnings in squeeze related to md5 module
+import warnings
+warnings.filterwarnings('ignore', \
+ "the md5 module is deprecated; use hashlib instead", \
+ DeprecationWarning)
+
import errno
import os
import re
@@ -54,7 +60,7 @@ import commands
import threading
from daklib import utils
-from daklib.dbconn import DBConn, get_binary_from_name_suite
+from daklib.dbconn import DBConn, get_component_by_package_suite
from daklib.regexes import html_escaping, re_html_escaping, re_version, re_spacestrip, \
re_contrib, re_nonfree, re_localhost, re_newlinespace, \
re_package, re_doc_directory
@@ -64,8 +70,8 @@ from daklib.regexes import html_escaping, re_html_escaping, re_version, re_space
Cnf = None
Cnf = utils.get_conf()
-changes_lock = threading.Lock()
-printed_copyrights = {}
+printed = threading.local()
+printed.copyrights = {}
package_relations = {} #: Store relations of packages for later output
# default is to not output html.
@@ -114,7 +120,8 @@ ansi_colours = {
'arch': "\033[32m",
'end': "\033[0m",
'bold': "\033[1m",
- 'maintainer': "\033[32m"}
+ 'maintainer': "\033[32m",
+ 'distro': "\033[1m\033[41m"}
html_colours = {
'main': ('',""),
@@ -122,7 +129,8 @@ html_colours = {
'nonfree': ('',""),
'arch': ('',""),
'bold': ('',""),
- 'maintainer': ('',"")}
+ 'maintainer': ('',""),
+ 'distro': ('',"")}
def colour_output(s, colour):
if use_html:
@@ -275,7 +283,7 @@ def read_control (filename):
return (control, control_keys, section, depends, recommends, arch, maintainer)
-def read_changes_or_dsc (suite, filename):
+def read_changes_or_dsc (suite, filename, session = None):
dsc = {}
dsc_file = utils.open_file(filename)
@@ -294,10 +302,13 @@ def read_changes_or_dsc (suite, filename):
for k in dsc.keys():
if k in ("build-depends","build-depends-indep"):
- dsc[k] = create_depends_string(suite, split_depends(dsc[k]))
+ dsc[k] = create_depends_string(suite, split_depends(dsc[k]), session)
elif k == "architecture":
if (dsc["architecture"] != "any"):
dsc['architecture'] = colour_output(dsc["architecture"], 'arch')
+ elif k == "distribution":
+ if dsc["distribution"] not in ('unstable', 'experimental'):
+ dsc['distribution'] = colour_output(dsc["distribution"], 'distro')
elif k in ("files","changes","description"):
if use_html:
dsc[k] = formatted_text(dsc[k], strip=True)
@@ -311,12 +322,12 @@ def read_changes_or_dsc (suite, filename):
filecontents = '\n'.join(map(lambda x: format_field(x,dsc[x.lower()]), keysinorder))+'\n'
return filecontents
-def create_depends_string (suite, depends_tree):
+def create_depends_string (suite, depends_tree, session = None):
result = ""
if suite == 'experimental':
- suite_where = "in ('experimental','unstable')"
+ suite_list = ['experimental','unstable']
else:
- suite_where = "= '%s'" % suite
+ suite_list = [suite]
comma_count = 1
for l in depends_tree:
@@ -328,17 +339,16 @@ def create_depends_string (suite, depends_tree):
result += " | "
# doesn't do version lookup yet.
- res = get_binary_from_name_suite(d['name'], suite_where)
- if res.rowcount > 0:
- i = res.fetchone()
-
+ component = get_component_by_package_suite(d['name'], suite_list, \
+ session = session)
+ if component is not None:
adepends = d['name']
if d['version'] != '' :
adepends += " (%s)" % (d['version'])
- if i[2] == "contrib":
+ if component == "contrib":
result += colour_output(adepends, "contrib")
- elif i[2] == "non-free":
+ elif component == "non-free":
result += colour_output(adepends, "nonfree")
else :
result += colour_output(adepends, "main")
@@ -369,7 +379,7 @@ def output_package_relations ():
package_relations.clear()
return foldable_output("Package relations", "relations", to_print)
-def output_deb_info(suite, filename, packagename):
+def output_deb_info(suite, filename, packagename, session = None):
(control, control_keys, section, depends, recommends, arch, maintainer) = read_control(filename)
if control == '':
@@ -379,10 +389,10 @@ def output_deb_info(suite, filename, packagename):
package_relations[packagename] = {}
for key in control_keys :
if key == 'Depends':
- field_value = create_depends_string(suite, depends)
+ field_value = create_depends_string(suite, depends, session)
package_relations[packagename][key] = field_value
elif key == 'Recommends':
- field_value = create_depends_string(suite, recommends)
+ field_value = create_depends_string(suite, recommends, session)
package_relations[packagename][key] = field_value
elif key == 'Section':
field_value = section
@@ -416,7 +426,7 @@ def do_lintian (filename):
return do_command("lintian --show-overrides --color always", filename, 1)
def get_copyright (deb_filename):
- global changes_lock, printed_copyrights
+ global printed
package = re_package.sub(r'\1', deb_filename)
o = os.popen("dpkg-deb -c %s | egrep 'usr(/share)?/doc/[^/]*/copyright' | awk '{print $6}' | head -n 1" % (deb_filename))
@@ -434,13 +444,11 @@ def get_copyright (deb_filename):
copyrightmd5 = md5.md5(cright).hexdigest()
res = ""
- changes_lock.acquire()
- if printed_copyrights.has_key(copyrightmd5) and printed_copyrights[copyrightmd5] != "%s (%s)" % (package, deb_filename):
+ if printed.copyrights.has_key(copyrightmd5) and printed.copyrights[copyrightmd5] != "%s (%s)" % (package, deb_filename):
res += formatted_text( "NOTE: Copyright is the same as %s.\n\n" % \
- (printed_copyrights[copyrightmd5]))
+ (printed.copyrights[copyrightmd5]))
else:
- printed_copyrights[copyrightmd5] = "%s (%s)" % (package, deb_filename)
- changes_lock.release()
+ printed.copyrights[copyrightmd5] = "%s (%s)" % (package, deb_filename)
return res+formatted_text(cright)
def get_readme_source (dsc_filename):
@@ -471,8 +479,8 @@ def get_readme_source (dsc_filename):
return res
-def check_dsc (suite, dsc_filename):
- (dsc) = read_changes_or_dsc(suite, dsc_filename)
+def check_dsc (suite, dsc_filename, session = None):
+ (dsc) = read_changes_or_dsc(suite, dsc_filename, session)
return foldable_output(dsc_filename, "dsc", dsc, norow=True) + \
"\n" + \
foldable_output("lintian check for %s" % dsc_filename,
@@ -481,7 +489,7 @@ def check_dsc (suite, dsc_filename):
foldable_output("README.source for %s" % dsc_filename,
"source-readmesource", get_readme_source(dsc_filename))
-def check_deb (suite, deb_filename):
+def check_deb (suite, deb_filename, session = None):
filename = os.path.basename(deb_filename)
packagename = filename.split('_')[0]
@@ -491,7 +499,7 @@ def check_deb (suite, deb_filename):
is_a_udeb = 0
result = foldable_output("control file for %s" % (filename), "binary-%s-control"%packagename,
- output_deb_info(suite, deb_filename, packagename), norow=True) + "\n"
+ output_deb_info(suite, deb_filename, packagename, session), norow=True) + "\n"
if is_a_udeb:
result += foldable_output("skipping lintian check for udeb",
@@ -544,11 +552,9 @@ def strip_pgp_signature (filename):
return contents
def display_changes(suite, changes_filename):
- global changes_lock, printed_copyrights
+ global printed
changes = read_changes_or_dsc(suite, changes_filename)
- changes_lock.acquire()
- printed_copyrights = {}
- changes_lock.release()
+ printed.copyrights = {}
return foldable_output(changes_filename, "changes", changes, norow=True)
def check_changes (changes_filename):