| 1 |
#!/usr/bin/python
|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
|
| 4 |
# Make sure tabs expand to 8 spaces in vim
|
| 5 |
# vim: expandtab
|
| 6 |
|
| 7 |
# Copyright: © 2002-2011 Raphaël Hertzog
|
| 8 |
# Copyright: © 2005 Jeroen van Wolffelaar
|
| 9 |
# Copyright: © 2007-2009 Stefano Zacchiroli
|
| 10 |
# This file is distributed under the terms of the General Public License
|
| 11 |
# version 2 or (at your option) any later version.
|
| 12 |
|
| 13 |
import os.path, sys, string, re, email, common, cPickle, yaml
|
| 14 |
import xml.dom
|
| 15 |
|
| 16 |
try:
|
| 17 |
from debian import deb822, debian_support
|
| 18 |
except: # Required to run on lenny
|
| 19 |
from debian_bundle import deb822, debian_support
|
| 20 |
|
| 21 |
from config import dir, odir, root
|
| 22 |
from common import hash_name
|
| 23 |
|
| 24 |
def read_font_reviews(fname):
|
| 25 |
y = yaml.load(file(fname), yaml.CLoader)
|
| 26 |
packages = {} # maps pkg to the font review for it
|
| 27 |
for pkg, data in y.iteritems():
|
| 28 |
if data.has_key('url'):
|
| 29 |
packages[pkg] = data['url']
|
| 30 |
return packages
|
| 31 |
|
| 32 |
def read_shortdesc(fname):
|
| 33 |
global binary2sources
|
| 34 |
source_descs = {} # source package -> (binary package -> short description)
|
| 35 |
for line in open(fname):
|
| 36 |
pkg, shortdesc = line.strip().split("\t", 1)
|
| 37 |
if not binary2sources.has_key(pkg):
|
| 38 |
continue
|
| 39 |
src = binary2sources[pkg]['current']
|
| 40 |
if src is None:
|
| 41 |
continue
|
| 42 |
if not source_descs.has_key(src):
|
| 43 |
source_descs[src] = {}
|
| 44 |
source_descs[src][pkg] = shortdesc
|
| 45 |
return source_descs
|
| 46 |
|
| 47 |
def read_bug_summary(fname):
|
| 48 |
global binary2sources
|
| 49 |
summary = {} # source package -> bug count
|
| 50 |
for line in open(fname):
|
| 51 |
pkg, count = line.split()
|
| 52 |
if not binary2sources.has_key(pkg):
|
| 53 |
continue
|
| 54 |
src = binary2sources[pkg]['current']
|
| 55 |
if src is None:
|
| 56 |
continue
|
| 57 |
if not summary.has_key(src):
|
| 58 |
summary[src] = 0
|
| 59 |
summary[src] += int(count)
|
| 60 |
return summary
|
| 61 |
|
| 62 |
def read_low_threshold_nmu(fname):
|
| 63 |
"""read low threshold NMU info"""
|
| 64 |
emails = []
|
| 65 |
if os.path.exists(fname):
|
| 66 |
f = open(fname)
|
| 67 |
devel_php_RE = \
|
| 68 |
re.compile(r'http://qa\.debian\.org/developer\.php\?login=([^\s&]+)')
|
| 69 |
word_RE = re.compile(r'^\w+$')
|
| 70 |
for line in f.readlines():
|
| 71 |
match = devel_php_RE.search(line)
|
| 72 |
while match: # look for several matches on the same line
|
| 73 |
email = None
|
| 74 |
login = match.group(1)
|
| 75 |
if word_RE.match(login):
|
| 76 |
email = login + '@debian.org'
|
| 77 |
elif login.find('@') >= 0:
|
| 78 |
email = login
|
| 79 |
if email:
|
| 80 |
emails.append(email)
|
| 81 |
line = line[match.end():]
|
| 82 |
match = devel_php_RE.search(line)
|
| 83 |
f.close()
|
| 84 |
return emails
|
| 85 |
|
| 86 |
def read_transitions(fname):
|
| 87 |
y = yaml.load(file(fname))
|
| 88 |
packages = {} # maps pkg to the _list_ of transitions they are involved in
|
| 89 |
for id, transition in y.iteritems():
|
| 90 |
for pkg in transition['packages']:
|
| 91 |
if not packages.has_key(pkg):
|
| 92 |
packages[pkg] = []
|
| 93 |
packages[pkg].append(id)
|
| 94 |
return packages
|
| 95 |
|
| 96 |
def read_piuparts(fname):
|
| 97 |
failures = {}
|
| 98 |
if os.path.exists(fname):
|
| 99 |
f = open(fname)
|
| 100 |
for line in f.readlines():
|
| 101 |
try:
|
| 102 |
src, outcome = map(lambda s: s.strip(), line.split(':'))
|
| 103 |
if outcome == "fail":
|
| 104 |
failures[src] = True
|
| 105 |
except ValueError:
|
| 106 |
pass
|
| 107 |
f.close()
|
| 108 |
return failures
|
| 109 |
|
| 110 |
def read_lintian_info(fname):
|
| 111 |
lintian = {} # maps source pkg names to pairs <errors_no, warnings_no>
|
| 112 |
for line in open(fname).readlines():
|
| 113 |
try:
|
| 114 |
(pkg, errors_no, warnings_no) = line.split()[:3]
|
| 115 |
lintian[pkg] = (int(errors_no), int(warnings_no))
|
| 116 |
except ValueError:
|
| 117 |
continue
|
| 118 |
return lintian
|
| 119 |
|
| 120 |
def read_logcheck_info(fname):
|
| 121 |
data = {} # maps source pkg names to pairs <errors_no, warnings_no>
|
| 122 |
for line in open(fname).readlines():
|
| 123 |
try:
|
| 124 |
(pkg, errors_no, warnings_no) = line.split('|')[:3]
|
| 125 |
data[pkg] = (int(errors_no), int(warnings_no))
|
| 126 |
except ValueError:
|
| 127 |
continue
|
| 128 |
return data
|
| 129 |
|
| 130 |
# parse textual files with lines like "field: value"
|
| 131 |
def read_mapping(fname):
|
| 132 |
f = open(fname)
|
| 133 |
for line in f.readlines():
|
| 134 |
items = map(string.strip, line.split(':'))
|
| 135 |
if len(items) == 2:
|
| 136 |
yield items
|
| 137 |
else:
|
| 138 |
sys.stderr.write("Incorrect 'field: value' data in %s: %s" % (fname, line))
|
| 139 |
f.close()
|
| 140 |
|
| 141 |
# read 822 dump of NEW queue content
|
| 142 |
def read_NEW(fname):
|
| 143 |
new_contents = {}
|
| 144 |
for stanza in deb822.Sources.iter_paragraphs(file(os.path.join(dir, 'new.822'))):
|
| 145 |
if stanza.has_key('source') and stanza.has_key('version') and \
|
| 146 |
stanza.has_key('queue'):
|
| 147 |
# store only the most recent version in NEW (ignore accepted)
|
| 148 |
if stanza['queue'] == 'new' and \
|
| 149 |
(not new_contents.has_key(stanza['source']) or \
|
| 150 |
debian_support.version_compare( \
|
| 151 |
new_contents[stanza['source']],
|
| 152 |
stanza['version']) < 0):
|
| 153 |
new_contents[stanza['source']] = stanza['version']
|
| 154 |
return new_contents
|
| 155 |
|
| 156 |
def read_l10n_status(fname):
|
| 157 |
l10n = {}
|
| 158 |
if os.path.exists(fname):
|
| 159 |
f = open(fname)
|
| 160 |
for line in f.readlines():
|
| 161 |
if line.startswith('#'):
|
| 162 |
continue
|
| 163 |
pkg, version, trans, url, todo = line.rstrip().split()
|
| 164 |
deb_trans, nondeb_trans = trans.strip('()').split(',')
|
| 165 |
l10n[pkg] = {'version': version,
|
| 166 |
'deb': deb_trans, 'nondeb': nondeb_trans,
|
| 167 |
'url': url, 'todo': todo}
|
| 168 |
f.close()
|
| 169 |
return l10n
|
| 170 |
|
| 171 |
# Initialization: fill binary <-> source maps
|
| 172 |
f = open(odir + "/sources_mapping")
|
| 173 |
source2binaries = cPickle.load(f) # maps a source package to its binaries
|
| 174 |
binary2sources = cPickle.load(f) # maps a binary package to its sources
|
| 175 |
f.close()
|
| 176 |
|
| 177 |
# Read all the bugs stats
|
| 178 |
bugs = {}
|
| 179 |
f = open(dir + "/bugs.txt")
|
| 180 |
while 1:
|
| 181 |
line = f.readline()
|
| 182 |
if not line: break #eof
|
| 183 |
line = line.strip()
|
| 184 |
(binary, stats) = line.split(None, 1)
|
| 185 |
try:
|
| 186 |
bugs[binary] = [ string.atoi(i) for i in stats.split() ]
|
| 187 |
except:
|
| 188 |
sys.stderr.write("Failed to parse bugs.txt stats for %s: %s\n" % (binary, stats))
|
| 189 |
f.close()
|
| 190 |
|
| 191 |
srcbugs = {}
|
| 192 |
f = open(dir + "/bugs-src.txt")
|
| 193 |
while 1:
|
| 194 |
line = f.readline()
|
| 195 |
if not line: break #eof
|
| 196 |
line = line.strip()
|
| 197 |
(pkg, stats) = line.split(":", 1)
|
| 198 |
try:
|
| 199 |
srcbugs[pkg] = [ string.atoi(i) for i in stats.replace("(", " ").replace(")", " ").split() ]
|
| 200 |
except:
|
| 201 |
sys.stderr.write("Failed to parse bugs-src.txt stats for %s: %s\n" % (pkg, stats))
|
| 202 |
f.close()
|
| 203 |
|
| 204 |
gift_bugs = read_bug_summary(os.path.join(dir, 'bugs.gift.txt'))
|
| 205 |
help_bugs = read_bug_summary(os.path.join(dir, 'bugs.help.txt'))
|
| 206 |
|
| 207 |
# Read all the PTS stats
|
| 208 |
pts = {}
|
| 209 |
f = open(dir + "/count.txt")
|
| 210 |
while 1:
|
| 211 |
line = f.readline()
|
| 212 |
if not line: break #eof
|
| 213 |
line = line.strip()
|
| 214 |
(binary, stats) = line.split(None, 1)
|
| 215 |
pts[binary] = stats
|
| 216 |
f.close()
|
| 217 |
|
| 218 |
# Read the lisf of packages with debcheck problems
|
| 219 |
debcheck = {}
|
| 220 |
for dist in ("oldstable", "stable", "testing", "unstable"):
|
| 221 |
debcheck[dist] = {}
|
| 222 |
f = open(dir + "/debcheck-" + dist)
|
| 223 |
while 1:
|
| 224 |
line = f.readline()
|
| 225 |
if not line: break #eof
|
| 226 |
debcheck[dist][line.strip()] = 1
|
| 227 |
f.close()
|
| 228 |
|
| 229 |
# Read the list of packages with override disparities
|
| 230 |
override = {}
|
| 231 |
for dist in ("unstable", "experimental"):
|
| 232 |
override[dist] = {}
|
| 233 |
f = open(dir + "/override-disparities." + dist)
|
| 234 |
for line in f:
|
| 235 |
if line[0] != '-':
|
| 236 |
source = line.strip()[:-1]
|
| 237 |
override[dist][source] = []
|
| 238 |
else:
|
| 239 |
override[dist][source].append(line.strip()[2:])
|
| 240 |
f.close()
|
| 241 |
|
| 242 |
# read the package localization status
|
| 243 |
l10n = read_l10n_status(os.path.join(dir, 'l10n-status.txt'))
|
| 244 |
|
| 245 |
# Read the current signature of other.xml files
|
| 246 |
sigs = {}
|
| 247 |
if os.path.exists(odir + "/other.sigs"):
|
| 248 |
f = open(odir + "/other.sigs", "r")
|
| 249 |
sigs = cPickle.load(f)
|
| 250 |
f.close()
|
| 251 |
|
| 252 |
# Read the wnpp information. [PvR]
|
| 253 |
wnpp = {}
|
| 254 |
if os.path.exists(dir + "/wnpp_rm"):
|
| 255 |
f = open(dir + "/wnpp_rm")
|
| 256 |
while 1:
|
| 257 |
line = f.readline()
|
| 258 |
if not line: break # eof
|
| 259 |
line = line.strip()
|
| 260 |
try:
|
| 261 |
(package, type, number) = line.split("|")[0].split()
|
| 262 |
except:
|
| 263 |
#too many badly formatted ITP... disable warning. --RH
|
| 264 |
#sys.stderr.write("Ignoring bad line '%s' in wnpp_rm\n" % line)
|
| 265 |
pass
|
| 266 |
wnpp[package[:-1]] = (type, number)
|
| 267 |
f.close()
|
| 268 |
|
| 269 |
# Read patches information [FG]
|
| 270 |
ubuntu_patches = {}
|
| 271 |
# this can be easily inserted into a new update_patches.py if it becomes too
|
| 272 |
# heavy to parse the file
|
| 273 |
if os.path.exists(dir + "/patches.ubuntu"):
|
| 274 |
f = open(dir + "/patches.ubuntu")
|
| 275 |
for line in f.readlines():
|
| 276 |
(package, rel_url) = line.split(' ', 2)
|
| 277 |
rel_url = rel_url.strip()
|
| 278 |
r = re.search("_(\S+).patch", line)
|
| 279 |
if not r:
|
| 280 |
continue
|
| 281 |
version = r.group(1)
|
| 282 |
ubuntu_patches[package] = (version, "http://patches.ubuntu.com/" + rel_url)
|
| 283 |
f.close()
|
| 284 |
|
| 285 |
ubuntu_versions = {}
|
| 286 |
if os.path.exists(dir + "/versions.ubuntu"):
|
| 287 |
f = open(dir + "/versions.ubuntu")
|
| 288 |
for line in f.readlines():
|
| 289 |
(package, version) = line.split(' ', 2)
|
| 290 |
version = version.strip()
|
| 291 |
ubuntu_versions[package] = (version, "https://launchpad.net/ubuntu/+source/" + package)
|
| 292 |
f.close()
|
| 293 |
|
| 294 |
ubuntu_bugs = {}
|
| 295 |
ubuntu_bugpatches = {}
|
| 296 |
if os.path.exists(dir + "/bugs.ubuntu"):
|
| 297 |
f = open(dir + "/bugs.ubuntu")
|
| 298 |
for line in f.readlines():
|
| 299 |
(package, ubugs, upatches) = line.split('|', 3)
|
| 300 |
ubugs = ubugs.strip()
|
| 301 |
upatches = upatches.strip()
|
| 302 |
ubuntu_bugs[package] = (ubugs, "https://bugs.launchpad.net/ubuntu/+source/" + package)
|
| 303 |
ubuntu_bugpatches[package] = (upatches, "https://bugs.launchpad.net/ubuntu/+source/" + package + "/+patches")
|
| 304 |
f.close()
|
| 305 |
|
| 306 |
# write lowThresholdNmu info to a (global, i.e. not per-package) file
|
| 307 |
#
|
| 308 |
# XXX this is sub-optimal, as the XSLT rendering of each package page will have
|
| 309 |
# to read the whole XML file each time. However, this can't be fixed here
|
| 310 |
# unless we have somewhere an additional map (in the spirit of sources.map)
|
| 311 |
# mapping source package names to maintainer emails
|
| 312 |
low_nmu_emails = read_low_threshold_nmu(dir + "/low_threshold_nmu.txt")
|
| 313 |
f = open(odir + "/low_threshold_nmu.emails.xml", 'w')
|
| 314 |
f.write("<emails>\n");
|
| 315 |
f.writelines(map(lambda s: " <email>%s</email>\n" % s, low_nmu_emails))
|
| 316 |
f.write("</emails>\n");
|
| 317 |
f.close()
|
| 318 |
|
| 319 |
# read the list of packages involved in transitions
|
| 320 |
transitions = read_transitions(os.path.join(dir, "transitions.yaml"))
|
| 321 |
|
| 322 |
piuparts = read_piuparts(os.path.join(dir, "piuparts-sid.txt"))
|
| 323 |
|
| 324 |
new_queue = read_NEW(os.path.join(dir, "new.822"))
|
| 325 |
|
| 326 |
# read QA lintian info
|
| 327 |
lintian = read_lintian_info(os.path.join(dir, "lintian.qa-list.txt"))
|
| 328 |
|
| 329 |
# read builddlogcheck info
|
| 330 |
logcheck = read_logcheck_info(os.path.join(dir, "logcheck.txt"))
|
| 331 |
|
| 332 |
# read the list of packages indexed by svnbuildstat.debian.net
|
| 333 |
svnbuildstat = {}
|
| 334 |
try:
|
| 335 |
f = open(os.path.join(dir, "svnbuildstat_list.txt"))
|
| 336 |
for pkgname in map(string.rstrip, f.readlines()):
|
| 337 |
svnbuildstat[pkgname] = True
|
| 338 |
f.close()
|
| 339 |
except:
|
| 340 |
pass # Silent failure
|
| 341 |
|
| 342 |
# read info gathered from watch file scanner
|
| 343 |
data = yaml.load(file(os.path.join(dir, "dehs.yaml")), yaml.CLoader)
|
| 344 |
dehs = {}
|
| 345 |
for entry in data:
|
| 346 |
pkgname = entry["package"]
|
| 347 |
if "status" in entry and "Newer version" in entry["status"]:
|
| 348 |
if pkgname not in dehs:
|
| 349 |
dehs[pkgname] = {}
|
| 350 |
dehs[pkgname]["newer"] = str(entry["upstream-version"])
|
| 351 |
dehs[pkgname]["url"] = entry["upstream-url"]
|
| 352 |
if "warnings" in entry:
|
| 353 |
if pkgname not in dehs:
|
| 354 |
dehs[pkgname] = {}
|
| 355 |
dehs[pkgname]["error"] = entry["warnings"]
|
| 356 |
|
| 357 |
# read list of unfixed security issues
|
| 358 |
security = {}
|
| 359 |
for pkgname, count in read_mapping(os.path.join(dir, "security_issues.txt")):
|
| 360 |
security[pkgname] = count
|
| 361 |
|
| 362 |
# read short descriptions
|
| 363 |
shortdescs = read_shortdesc(os.path.join(dir, "shortdesc.txt"))
|
| 364 |
|
| 365 |
font_reviews = read_font_reviews(os.path.join(dir, "debian-font-review.yaml"))
|
| 366 |
|
| 367 |
# Create the XML documents
|
| 368 |
while 1:
|
| 369 |
line = sys.stdin.readline()
|
| 370 |
if not line: break #eof
|
| 371 |
pkg = line.strip()
|
| 372 |
|
| 373 |
doc = xml.dom.getDOMImplementation('minidom').createDocument(None, "other", None)
|
| 374 |
root_elt = doc.documentElement
|
| 375 |
hash = hash_name(pkg)
|
| 376 |
|
| 377 |
# Add debcheck availability info
|
| 378 |
dc_sig = ""
|
| 379 |
elt = doc.createElement("debcheck")
|
| 380 |
for dist in ("oldstable", "stable", "testing", "unstable"):
|
| 381 |
if debcheck[dist].has_key(pkg):
|
| 382 |
elt.setAttribute(dist, "yes")
|
| 383 |
dc_sig += "y"
|
| 384 |
else:
|
| 385 |
elt.setAttribute(dist, "no")
|
| 386 |
dc_sig += "n"
|
| 387 |
root_elt.appendChild(elt)
|
| 388 |
|
| 389 |
# Add NEW queue versions, if any
|
| 390 |
if new_queue.has_key(pkg):
|
| 391 |
root_elt.setAttribute("new_version", new_queue[pkg])
|
| 392 |
new_queue_sig = 'y'
|
| 393 |
else:
|
| 394 |
new_queue_sig = 'n'
|
| 395 |
|
| 396 |
# Get PTS stats
|
| 397 |
elt = doc.createElement("pts")
|
| 398 |
elt.setAttribute("count", pts.get(pkg, "0"))
|
| 399 |
root_elt.appendChild(elt)
|
| 400 |
|
| 401 |
# Get BTS stats
|
| 402 |
elt = doc.createElement("bugs")
|
| 403 |
(s_rc, s_rc_m, s_normal, s_normal_m, s_wishlist, s_wishlist_m, s_fixed,
|
| 404 |
s_fixed_m, s_patch, s_patch_m) = \
|
| 405 |
srcbugs.get(pkg, [0,0,0,0,0,0,0,0,0,0])
|
| 406 |
try:
|
| 407 |
binlist = source2binaries[pkg]['merged']
|
| 408 |
except:
|
| 409 |
binlist = []
|
| 410 |
binlist.sort()
|
| 411 |
subsig = ""
|
| 412 |
for binary in binlist:
|
| 413 |
sub_elt = doc.createElement("item")
|
| 414 |
sub_elt.setAttribute("name", binary)
|
| 415 |
(rc, normal, wishlist, fixed, patch) = bugs.get(binary, [0,0,0,0,0])
|
| 416 |
sub_elt.setAttribute("rc", "%d" % rc)
|
| 417 |
sub_elt.setAttribute("normal", "%d" % normal)
|
| 418 |
sub_elt.setAttribute("wishlist", "%d" % wishlist)
|
| 419 |
sub_elt.setAttribute("fixed", "%d" % fixed)
|
| 420 |
sub_elt.setAttribute("patch", "%d" % patch)
|
| 421 |
all = rc + normal + wishlist + fixed
|
| 422 |
sub_elt.setAttribute("all", "%d" % all)
|
| 423 |
elt.appendChild(sub_elt)
|
| 424 |
if len(subsig):
|
| 425 |
subsig = "%s|%d|%d" % (subsig, all, patch)
|
| 426 |
else:
|
| 427 |
subsig = "%d|%d" % (all, patch)
|
| 428 |
|
| 429 |
elt.setAttribute("rc", "%d" % s_rc)
|
| 430 |
if s_rc != s_rc_m:
|
| 431 |
elt.setAttribute("rc_m", "%d" % s_rc_m)
|
| 432 |
elt.setAttribute("normal", "%d" % s_normal)
|
| 433 |
if s_normal != s_normal_m:
|
| 434 |
elt.setAttribute("normal_m", "%d" % s_normal_m)
|
| 435 |
elt.setAttribute("wishlist", "%d" % s_wishlist)
|
| 436 |
if s_wishlist != s_wishlist_m:
|
| 437 |
elt.setAttribute("wishlist_m", "%d" % s_wishlist_m)
|
| 438 |
elt.setAttribute("fixed", "%d" % s_fixed)
|
| 439 |
if s_fixed != s_fixed_m:
|
| 440 |
elt.setAttribute("fixed_m", "%d" % s_fixed_m)
|
| 441 |
elt.setAttribute("patch", "%d" % s_patch)
|
| 442 |
if s_patch != s_patch_m:
|
| 443 |
elt.setAttribute("patch_m", "%d" % s_patch_m)
|
| 444 |
s_all = s_fixed + s_wishlist + s_normal + s_rc
|
| 445 |
s_all_m = s_fixed_m + s_wishlist_m + s_normal_m + s_rc_m
|
| 446 |
elt.setAttribute("all", "%d" % s_all)
|
| 447 |
if s_all != s_all_m:
|
| 448 |
elt.setAttribute("all_m", "%d" % s_all_m)
|
| 449 |
root_elt.appendChild(elt)
|
| 450 |
if gift_bugs.has_key(pkg):
|
| 451 |
s_gift = gift_bugs[pkg]
|
| 452 |
else:
|
| 453 |
s_gift = 0
|
| 454 |
elt.setAttribute("gift", str(s_gift))
|
| 455 |
if help_bugs.has_key(pkg):
|
| 456 |
s_help = help_bugs[pkg]
|
| 457 |
else:
|
| 458 |
s_help = 0
|
| 459 |
elt.setAttribute("help", str(s_help))
|
| 460 |
|
| 461 |
# Get WNPP information. [PvR]
|
| 462 |
if wnpp.has_key(pkg):
|
| 463 |
(type, number) = wnpp[pkg]
|
| 464 |
elt = doc.createElement("wnpp")
|
| 465 |
elt.setAttribute("type", type)
|
| 466 |
elt.setAttribute("bugnumber", number)
|
| 467 |
root_elt.appendChild(elt)
|
| 468 |
root_elt.setAttribute("wnpp", "yes")
|
| 469 |
wnpp_sig = "%s%s" % (type,number)
|
| 470 |
else:
|
| 471 |
root_elt.setAttribute("wnpp", "no")
|
| 472 |
wnpp_sig = "n"
|
| 473 |
|
| 474 |
# Get override info [JvW]
|
| 475 |
override_elt = None
|
| 476 |
override_sig = []
|
| 477 |
for dist in [ 'unstable', 'experimental' ]:
|
| 478 |
if override[dist].has_key(pkg):
|
| 479 |
if not override_elt: override_elt = doc.createElement("override")
|
| 480 |
disparities = override[dist][pkg]
|
| 481 |
override_sig.append(disparities)
|
| 482 |
elt_g = doc.createElement("group")
|
| 483 |
elt_g.setAttribute("suite", dist)
|
| 484 |
for disp in disparities:
|
| 485 |
elt = doc.createTextNode(disp)
|
| 486 |
elt_disp = doc.createElement("disparity")
|
| 487 |
elt_disp.appendChild(elt)
|
| 488 |
elt_g.appendChild(elt_disp)
|
| 489 |
override_elt.appendChild(elt_g)
|
| 490 |
|
| 491 |
if override_elt:
|
| 492 |
root_elt.appendChild(override_elt)
|
| 493 |
root_elt.setAttribute("override", "yes")
|
| 494 |
else:
|
| 495 |
root_elt.setAttribute("override", "no")
|
| 496 |
|
| 497 |
# Add Ubuntu information
|
| 498 |
if ubuntu_versions.has_key(pkg):
|
| 499 |
elt = doc.createElement("ubuntu")
|
| 500 |
(version, url) = ubuntu_versions[pkg]
|
| 501 |
ubuntu_sig = "ubuntu/ " + version
|
| 502 |
elt.setAttribute("version", unicode(version, 'UTF8', 'replace'))
|
| 503 |
elt.setAttribute("url", unicode(url, 'UTF8', 'replace'))
|
| 504 |
if ubuntu_bugs.has_key(pkg):
|
| 505 |
elt.setAttribute("bugs", "yes")
|
| 506 |
elt_bugs = doc.createElement("bugs")
|
| 507 |
(count, url) = ubuntu_bugs[pkg]
|
| 508 |
ubuntu_sig += "ubuntubugs/" + count
|
| 509 |
elt_bugs.setAttribute("count", unicode(count, 'UTF8', 'replace'))
|
| 510 |
elt_bugs.setAttribute("url", unicode(url, 'UTF8', 'replace'))
|
| 511 |
elt.appendChild(elt_bugs)
|
| 512 |
if ubuntu_bugpatches[pkg][0] != "0":
|
| 513 |
elt.setAttribute("bugpatches", "yes")
|
| 514 |
elt_bugpatches = doc.createElement("bugpatches")
|
| 515 |
(count, url) = ubuntu_bugpatches[pkg]
|
| 516 |
ubuntu_sig += "ubuntubugpatches/" + count
|
| 517 |
elt_bugpatches.setAttribute("count", unicode(count, 'UTF8', 'replace'))
|
| 518 |
elt_bugpatches.setAttribute("url", unicode(url, 'UTF8', 'replace'))
|
| 519 |
elt.appendChild(elt_bugpatches)
|
| 520 |
if ubuntu_patches.has_key(pkg):
|
| 521 |
elt.setAttribute("patch", "yes")
|
| 522 |
elt_patch = doc.createElement("patch")
|
| 523 |
(version, url) = ubuntu_patches[pkg]
|
| 524 |
ubuntu_sig += "ubuntupatch/" + version
|
| 525 |
elt_patch.setAttribute("version", unicode(version, 'UTF8', 'replace'))
|
| 526 |
elt_patch.setAttribute("url", unicode(url, 'UTF8', 'replace'))
|
| 527 |
elt.appendChild(elt_patch)
|
| 528 |
root_elt.appendChild(elt)
|
| 529 |
root_elt.setAttribute("ubuntu", "yes")
|
| 530 |
else:
|
| 531 |
root_elt.setAttribute("ubuntu", "no")
|
| 532 |
ubuntu_sig = "n"
|
| 533 |
|
| 534 |
# Get DEHS information
|
| 535 |
if dehs.has_key(pkg):
|
| 536 |
elt = doc.createElement('dehs')
|
| 537 |
root_elt.appendChild(elt)
|
| 538 |
root_elt.setAttribute('dehs', 'yes')
|
| 539 |
dehs_sig = ''
|
| 540 |
if dehs[pkg].has_key('newer'):
|
| 541 |
elt.setAttribute('newer', dehs[pkg]['newer'])
|
| 542 |
elt.setAttribute('url', dehs[pkg]['url'])
|
| 543 |
dehs_sig += "newer/" + dehs[pkg]['newer']
|
| 544 |
if dehs[pkg].has_key('error'):
|
| 545 |
elt.setAttribute('error', dehs[pkg]['error'])
|
| 546 |
dehs_sig += "error"
|
| 547 |
else:
|
| 548 |
root_elt.setAttribute('dehs', 'no')
|
| 549 |
dehs_sig = 'n'
|
| 550 |
|
| 551 |
# add svnbuildstat info
|
| 552 |
if svnbuildstat.has_key(pkg):
|
| 553 |
elt = doc.createElement("svnbuildstat")
|
| 554 |
root_elt.setAttribute("svnbuildstat", "yes")
|
| 555 |
root_elt.appendChild(elt)
|
| 556 |
svnbuildstat_sig = "y"
|
| 557 |
else:
|
| 558 |
root_elt.setAttribute("svnbuildstat", "no")
|
| 559 |
svnbuildstat_sig = "n"
|
| 560 |
|
| 561 |
# add piuparts info
|
| 562 |
if piuparts.has_key(pkg):
|
| 563 |
root_elt.setAttribute("piuparts", "yes")
|
| 564 |
piuparts_sig = "y"
|
| 565 |
else:
|
| 566 |
root_elt.setAttribute("piuparts", "no")
|
| 567 |
piuparts_sig = "n"
|
| 568 |
|
| 569 |
# add localization info
|
| 570 |
if l10n.has_key(pkg):
|
| 571 |
elt = doc.createElement("i18n")
|
| 572 |
deb, nondeb = l10n[pkg]['deb'], l10n[pkg]['nondeb']
|
| 573 |
elt.setAttribute('deb', deb)
|
| 574 |
elt.setAttribute('nondeb', nondeb)
|
| 575 |
if not (set([deb, nondeb]) <= set(['-', '100'])):
|
| 576 |
# do not show l10n status when fully translated or nothing
|
| 577 |
# is translatable
|
| 578 |
elt.setAttribute('href', l10n[pkg]['url'])
|
| 579 |
if l10n[pkg]['todo'] == '1':
|
| 580 |
elt.setAttribute('todo', 'yes')
|
| 581 |
root_elt.setAttribute("i18n", "yes")
|
| 582 |
root_elt.appendChild(elt)
|
| 583 |
i18n_sig = (deb, nondeb, l10n[pkg]['todo'])
|
| 584 |
else:
|
| 585 |
root_elt.setAttribute("i18n", "no")
|
| 586 |
i18n_sig = ('-','-', 0)
|
| 587 |
|
| 588 |
# add transitions info
|
| 589 |
if transitions.has_key(pkg):
|
| 590 |
elt = doc.createElement("transitions")
|
| 591 |
for id in transitions[pkg]:
|
| 592 |
trans_elt = doc.createElement("transition")
|
| 593 |
trans_elt.setAttribute("name", id)
|
| 594 |
elt.appendChild(trans_elt)
|
| 595 |
root_elt.setAttribute("transitions", "yes")
|
| 596 |
root_elt.appendChild(elt)
|
| 597 |
transitions_sig = "y"
|
| 598 |
else:
|
| 599 |
root_elt.setAttribute("transitions", "no")
|
| 600 |
transitions_sig = "n"
|
| 601 |
|
| 602 |
# add lintian QA info
|
| 603 |
if lintian.has_key(pkg):
|
| 604 |
(errs, warns) = lintian[pkg]
|
| 605 |
elt = doc.createElement("lintian")
|
| 606 |
elt.setAttribute("errors", str(errs))
|
| 607 |
elt.setAttribute("warnings", str(warns))
|
| 608 |
root_elt.appendChild(elt)
|
| 609 |
root_elt.setAttribute("lintian", "yes")
|
| 610 |
lintian_sig = (errs, warns)
|
| 611 |
else:
|
| 612 |
root_elt.setAttribute("lintian", "no")
|
| 613 |
lintian_sig = (0, 0)
|
| 614 |
|
| 615 |
# add logcheck info
|
| 616 |
if logcheck.has_key(pkg):
|
| 617 |
(errs, warns) = logcheck[pkg]
|
| 618 |
elt = doc.createElement("logcheck")
|
| 619 |
elt.setAttribute("errors", str(errs))
|
| 620 |
elt.setAttribute("warnings", str(warns))
|
| 621 |
root_elt.appendChild(elt)
|
| 622 |
root_elt.setAttribute("logcheck", "yes")
|
| 623 |
logcheck_sig = (errs, warns)
|
| 624 |
else:
|
| 625 |
root_elt.setAttribute("logcheck", "no")
|
| 626 |
logcheck_sig = (0, 0)
|
| 627 |
|
| 628 |
# add short descriptions
|
| 629 |
elt = doc.createElement("descriptions")
|
| 630 |
root_elt.appendChild(elt)
|
| 631 |
if shortdescs.has_key(pkg):
|
| 632 |
for package, shortdesc in shortdescs[pkg].iteritems():
|
| 633 |
desc_elt = doc.createElement("shortdesc")
|
| 634 |
elt.appendChild(desc_elt)
|
| 635 |
desc_elt.setAttribute("package", package)
|
| 636 |
desc_text = doc.createTextNode(unicode(shortdesc, "UTF-8", "replace"))
|
| 637 |
desc_elt.appendChild(desc_text)
|
| 638 |
shortdesc_sig = str(shortdescs[pkg]).__hash__()
|
| 639 |
# XXX hash(str(...)) does not work: WTF?
|
| 640 |
else:
|
| 641 |
shortdesc_sig = ''.__hash__()
|
| 642 |
|
| 643 |
# Add font review links
|
| 644 |
if font_reviews.has_key(pkg):
|
| 645 |
elt = doc.createElement("fonts")
|
| 646 |
elt.setAttribute('href', font_reviews[pkg])
|
| 647 |
root_elt.setAttribute("fonts", "yes")
|
| 648 |
root_elt.appendChild(elt)
|
| 649 |
fonts_sig = font_reviews[pkg]
|
| 650 |
else:
|
| 651 |
root_elt.setAttribute("fonts", "no")
|
| 652 |
fonts_sig = ''
|
| 653 |
|
| 654 |
# Get security issues
|
| 655 |
if security.has_key(pkg):
|
| 656 |
root_elt.setAttribute('security', security[pkg])
|
| 657 |
sec_sig = security[pkg]
|
| 658 |
else:
|
| 659 |
root_elt.setAttribute('security', '0')
|
| 660 |
sec_sig = '0'
|
| 661 |
|
| 662 |
# TODO: try to do that signature checking before the creation of XML DOM
|
| 663 |
# Build the sig and check if anything changed
|
| 664 |
sig = (pts.get(pkg, "0"), dc_sig, wnpp_sig, override_sig, dehs_sig,
|
| 665 |
ubuntu_sig, s_rc, s_normal, s_wishlist, s_fixed, s_gift, s_help,
|
| 666 |
subsig, svnbuildstat_sig, transitions_sig, lintian_sig,
|
| 667 |
shortdesc_sig, piuparts_sig, new_queue_sig, i18n_sig,
|
| 668 |
fonts_sig, sec_sig, logcheck_sig)
|
| 669 |
if sigs.has_key(pkg) and sig == sigs[pkg] and \
|
| 670 |
os.path.isfile("%s/%s/%s/other.xml" % (odir, hash, pkg)):
|
| 671 |
continue
|
| 672 |
sigs[pkg] = sig
|
| 673 |
|
| 674 |
# Output the data to the XML file
|
| 675 |
try:
|
| 676 |
f = open("%s/%s/%s/other.xml" % (odir, hash, pkg), "w")
|
| 677 |
f.write(doc.toxml(encoding="UTF-8"))
|
| 678 |
f.close()
|
| 679 |
except Exception, msg:
|
| 680 |
sys.stderr.write("Output problem for " + pkg + "/other.xml (%s)\n" %
|
| 681 |
msg);
|
| 682 |
|
| 683 |
# Store the signatures
|
| 684 |
f = open(odir + "/other.sigs", "w")
|
| 685 |
cPickle.dump(sigs, f, 0)
|
| 686 |
f.close()
|
| 687 |
|