]> git.decadent.org.uk Git - dak.git/commitdiff
examine-package: lock access to printed_copyrights
authorTorsten Werner <twerner@debian.org>
Tue, 6 Jul 2010 20:38:48 +0000 (20:38 +0000)
committerTorsten Werner <twerner@debian.org>
Tue, 6 Jul 2010 20:38:48 +0000 (20:38 +0000)
FIXME: the global variable printed_copyrights is still broken...

Signed-off-by: Torsten Werner <twerner@debian.org>
dak/examine_package.py

index 2b92ca7816593a87753ca97ee3cf4f11045cc385..6a3c8046fdd6293a1dcf5c268ced4818df5116fe 100755 (executable)
@@ -51,6 +51,7 @@ import apt_pkg
 import apt_inst
 import shutil
 import commands
+import threading
 
 from daklib import utils
 from daklib.dbconn import DBConn, get_binary_from_name_suite
@@ -63,6 +64,7 @@ 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 = {}
 package_relations = {}           #: Store relations of packages for later output
 
@@ -415,6 +417,8 @@ def do_lintian (filename):
         return do_command("lintian --show-overrides --color always", filename, 1)
 
 def get_copyright (deb_filename):
+    global changes_lock, printed_copyrights
+
     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))
     cright = o.read()[:-1]
@@ -431,11 +435,13 @@ 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):
         res += formatted_text( "NOTE: Copyright is the same as %s.\n\n" % \
                                (printed_copyrights[copyrightmd5]))
     else:
         printed_copyrights[copyrightmd5] = "%s (%s)" % (package, deb_filename)
+    changes_lock.release()
     return res+formatted_text(cright)
 
 def get_readme_source (dsc_filename):
@@ -539,7 +545,11 @@ def strip_pgp_signature (filename):
     return contents
 
 def display_changes(suite, changes_filename):
+    global changes_lock, printed_copyrights
     changes = read_changes_or_dsc(suite, changes_filename)
+    changes_lock.acquire()
+    printed_copyrights = {}
+    changes_lock.release()
     return foldable_output(changes_filename, "changes", changes, norow=True)
 
 def check_changes (changes_filename):