| 1 |
#!/usr/bin/python |
#!/usr/bin/python |
| 2 |
# -*- coding: utf8 -*- |
# -*- coding: utf-8 -*- |
| 3 |
|
|
| 4 |
# vim: expandtab |
# vim: expandtab |
| 5 |
|
|
| 11 |
from xml.dom import implementation, ext |
from xml.dom import implementation, ext |
| 12 |
|
|
| 13 |
from config import dir, odir |
from config import dir, odir |
| 14 |
from common import vcs_table |
from common import vcs_table, hash_name, DpkgVersion |
| 15 |
|
|
| 16 |
# address_from_string takes an address in RFC822 format |
# address_from_string takes an address in RFC822 format |
| 17 |
# and turns it into a tuple of the form (real name, email). |
# and turns it into a tuple of the form (real name, email). |
| 50 |
|
|
| 51 |
def update_sources_info(m, dist): |
def update_sources_info(m, dist): |
| 52 |
"""Update the XML information with the given Message (Package entry)""" |
"""Update the XML information with the given Message (Package entry)""" |
| 53 |
global odir, old_done, new_done, new_dist_map |
global odir, old_done, new_done |
| 54 |
package = m["Package"] |
package = m["Package"] |
| 55 |
hash = package[0] |
version = DpkgVersion(m["Version"]) |
| 56 |
if package[0:3] == "lib": |
hash = hash_name(package) |
| 57 |
hash = package[0:4] |
xml_ok = os.path.isfile("%s/%s/%s/%s.xml" % (odir, hash, package, dist)) |
| 58 |
# Check if the work has already been done |
# Check if the work has already been done |
| 59 |
key = "%s_%s_%s" % (m["Package"], m["Version"], dist) |
key = "%s_%s" % (m["Package"], dist) |
| 60 |
new_done[key] = 1 |
# Skip (duplicate) old entries |
| 61 |
new_dist_map["%s_%s" % (m["Package"], dist)] = 1 |
if old_done.has_key(key) and version < old_done[key] and xml_ok: |
| 62 |
if old_done.has_key(key) and os.path.isfile("%s/%s/%s/%s.xml" % (odir, hash, package, dist)): |
return |
| 63 |
|
if new_done.has_key(key) and version <= new_done[key] and xml_ok: |
| 64 |
|
return |
| 65 |
|
new_done[key] = version |
| 66 |
|
# Don't redo the work already done |
| 67 |
|
if old_done.has_key(key) and old_done[key] == version and xml_ok: |
| 68 |
return |
return |
| 69 |
# Make sure the directory exists |
# Make sure the directory exists |
| 70 |
if not os.path.isdir(odir + "/" + hash + "/" + package): |
if not os.path.isdir(odir + "/" + hash + "/" + package): |
| 82 |
child = doc.createElement(tag) |
child = doc.createElement(tag) |
| 83 |
root.appendChild(child) |
root.appendChild(child) |
| 84 |
if tag == "binary" or tag[0:5] == "build": |
if tag == "binary" or tag[0:5] == "build": |
| 85 |
for item in re.split(", ?", m[tag]): |
for item in re.split(",[ \n]*", m[tag]): |
| 86 |
# Take care of non-ascii, prevents troubles... |
# Take care of non-ascii, prevents troubles... |
| 87 |
text = doc.createTextNode(unicode(item,'ISO-8859-1','replace')) |
text = doc.createTextNode(unicode(item,'ISO-8859-1','replace')) |
| 88 |
item_elt = doc.createElement("item") |
item_elt = doc.createElement("item") |
| 159 |
# Load the list of sources generated the last time |
# Load the list of sources generated the last time |
| 160 |
old_done = {} |
old_done = {} |
| 161 |
new_done = {} |
new_done = {} |
|
new_dist_map = {} |
|
| 162 |
if os.path.exists(odir + "/sources_done"): |
if os.path.exists(odir + "/sources_done"): |
| 163 |
f = open(odir + "/sources_done", "r") |
f = open(odir + "/sources_done", "r") |
| 164 |
old_done = cPickle.load(f) |
old_done = cPickle.load(f) |
| 182 |
# Scan the old package/distribution that existed and check if they |
# Scan the old package/distribution that existed and check if they |
| 183 |
# still exist ... if they don't, remove the associated xml file. |
# still exist ... if they don't, remove the associated xml file. |
| 184 |
for key in old_done.keys(): |
for key in old_done.keys(): |
| 185 |
(p, v, d) = key.split("_", 2) |
(p, d) = key.split("_", 1) |
| 186 |
if not new_dist_map.has_key("%s_%s" % (p, d)): |
if not new_done.has_key(key): |
| 187 |
hash = p[0] |
hash = hash_name(p) |
|
if p[0:3] == "lib": |
|
|
hash = p[0:4] |
|
| 188 |
filename = "%s/%s/%s/%s.xml" % (odir, hash, p, d) |
filename = "%s/%s/%s/%s.xml" % (odir, hash, p, d) |
| 189 |
filenamerebuild = "%s/%s/%s/force-rebuild" % (odir, hash, p) |
filenamerebuild = "%s/%s/%s/force-rebuild" % (odir, hash, p) |
| 190 |
if os.path.exists(filename): |
if os.path.exists(filename): |