| 1 |
#!/usr/bin/python2.2 |
#!/usr/bin/python |
| 2 |
|
# -*- coding: utf8 -*- |
| 3 |
|
|
|
# Make sure tabs expand to 8 spaces in vim |
|
| 4 |
# vim: expandtab |
# vim: expandtab |
| 5 |
|
|
| 6 |
# Copyright 2002 Raphaël Hertzog |
# Copyright 2002 Raphaël Hertzog |
| 7 |
# This file is distributed under the terms of the General Public License |
# This file is distributed under the terms of the General Public License |
| 8 |
# version 2 or (at your option) any later version. |
# version 2 or (at your option) any later version. |
| 9 |
|
|
| 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 |
| 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). |
| 108 |
else: |
else: |
| 109 |
text = doc.createTextNode(m[tag]) |
text = doc.createTextNode(m[tag]) |
| 110 |
child.appendChild(text) |
child.appendChild(text) |
| 111 |
|
# now compute derived information and store it in the xml |
| 112 |
|
# add 'parsed' version of VCS info |
| 113 |
|
if tag[:6] == 'x-vcs-' or tag[:4] == 'vcs-': |
| 114 |
|
if tag[0] == 'x': |
| 115 |
|
prefix_len = 6 |
| 116 |
|
else: |
| 117 |
|
prefix_len = 4 |
| 118 |
|
# e.g. tag[prefix_len:] would be 'svn' for 'x-vcs-svn'/'vcs-svn' |
| 119 |
|
# would be 'browser' for 'vcs-browser' (to be handled specially) |
| 120 |
|
repos_elt = list(root.getElementsByTagName('repository')) |
| 121 |
|
if repos_elt: # reuse existing repository element |
| 122 |
|
repos_elt = repos_elt[0] # invariant: at most 1 repository elt |
| 123 |
|
else: # create a new repository element |
| 124 |
|
repos_elt = doc.createElement('repository') |
| 125 |
|
root.appendChild(repos_elt) |
| 126 |
|
vcs_elt = doc.createElement('vcs') |
| 127 |
|
kind = tag[prefix_len:] |
| 128 |
|
if vcs_table.has_key(kind): |
| 129 |
|
kind = vcs_table[kind][0] |
| 130 |
|
vcs_elt.setAttribute('kind', kind) |
| 131 |
|
vcs_elt.setAttribute('url', m[tag]) |
| 132 |
|
repos_elt.appendChild(vcs_elt) |
| 133 |
# Print the DOM object to a file |
# Print the DOM object to a file |
| 134 |
try: |
try: |
| 135 |
f = open("%s/%s/%s/%s.xml" % (odir, hash, package, dist), "w") |
f = open("%s/%s/%s/%s.xml" % (odir, hash, package, dist), "w") |
| 138 |
except: |
except: |
| 139 |
sys.stderr.write("Output problem for " + m["package"] + "\n"); |
sys.stderr.write("Output problem for " + m["package"] + "\n"); |
| 140 |
|
|
| 141 |
def treat_sources_file(f, dist): |
def treat_sources_file(fname, dist): |
| 142 |
"""Scan the given Sources file and treat each Package entry""" |
"""Scan the given Sources file and treat each Package entry""" |
| 143 |
|
f = open(fname, "r") |
| 144 |
while 1: |
while 1: |
| 145 |
try: |
try: |
| 146 |
m = rfc822.Message(f) |
m = rfc822.Message(f) |
| 149 |
update_sources_info(m, dist) |
update_sources_info(m, dist) |
| 150 |
except EOFError: |
except EOFError: |
| 151 |
break |
break |
| 152 |
|
f.close() |
| 153 |
|
|
| 154 |
# Load the list of sources generated the last time |
# Load the list of sources generated the last time |
| 155 |
old_done = {} |
old_done = {} |
| 160 |
old_done = cPickle.load(f) |
old_done = cPickle.load(f) |
| 161 |
f.close() |
f.close() |
| 162 |
|
|
| 163 |
for comp in ["main", "contrib", "non-free"]: |
distros = ['oldstable', 'stable', 'testing', 'unstable', 'experimental'] |
| 164 |
for dist in ["oldstable", "stable", "testing", "unstable"]: |
distros.extend(['stable-proposed-updates', 'testing-proposed-updates']) |
| 165 |
f = open(dir + "/Sources_%s_%s" % (dist, comp), "r") |
distros.extend(['security-oldstable', 'security-stable']) |
| 166 |
treat_sources_file(f, dist) |
distros.extend(['volatile', 'mentors']) |
| 167 |
f.close() |
|
| 168 |
# Experimental |
for distro in distros: |
| 169 |
f = open(dir + "/Sources-experimental_" + comp, "r") |
for comp in ['main', 'contrib', 'non-free']: |
| 170 |
treat_sources_file(f, "experimental") |
treat_sources_file(os.path.join(dir, 'Sources-%s_%s' % (distro, comp)), |
| 171 |
f.close() |
distro) |
|
# s-p-u and t-p-u |
|
|
f = open(dir + "/Sources-spu_%s" % comp, "r") |
|
|
treat_sources_file(f, "s-p-u") |
|
|
f.close() |
|
|
f = open(dir + "/Sources-tpu_%s" % comp, "r") |
|
|
treat_sources_file(f, "t-p-u") |
|
|
f.close() |
|
|
# security |
|
|
f = open(dir + "/Sources-security-oldstable_%s" % comp, "r") |
|
|
treat_sources_file(f, "oldstable-security") |
|
|
f.close() |
|
|
f = open(dir + "/Sources-security-stable_%s" % comp, "r") |
|
|
treat_sources_file(f, "stable-security") |
|
|
f.close() |
|
|
#f = open(dir + "/Sources-security-testing_%s" % comp, "r") |
|
|
#treat_sources_file(f, "testing-security") |
|
|
#f.close() |
|
|
f = open(dir + "/Sources-secure-testing_%s" % comp, "r") |
|
|
treat_sources_file(f, "secure-testing") |
|
|
f.close() |
|
|
f = open(dir + "/Sources-volatile_%s" % comp, "r") |
|
|
treat_sources_file(f, "volatile") |
|
|
f.close() |
|
| 172 |
|
|
| 173 |
# Store the list of sources generated |
# Store the list of sources generated |
| 174 |
f = open(odir + "/sources_done", "w") |
f = open(odir + "/sources_done", "w") |