dom = minidom.parseString(xml)
btargets = get_elem(dom, "buildtargets")
- for btarget in btargets.getElementsByTagName("buildtarget"):
+ # load archs list
+ archs = {}
+ for arch_index, arch_value in \
+ enumerate(btargets.getElementsByTagName('archs')):
+ arch_list = []
+ for arch in arch_value.getElementsByTagName('arch'):
+ if arch.firstChild.data:
+ arch_list.append(arch.firstChild.data)
+ archs[arch_index] = arch_list
+ # load buildtarget
+ for btarget_index, btarget in \
+ enumerate(btargets.getElementsByTagName("buildtarget")):
target = {
- "name": btarget.getAttribute("name"),
- "archs": [],
- "repos": [],
- }
+ 'name': btarget.getAttribute("name"),
+ 'repos': [],
+ 'archs': archs.get(btarget_index)
+ }
try:
bconf = get_elem(btarget, "buildconf")
# Get archs
for repo in btarget.getElementsByTagName("repo"):
barch = repo.getAttribute("arch")
- if barch and barch not in target["archs"]:
- target["archs"].append(barch)
target["repos"].append((repo.getAttribute("type"), barch,
repo.firstChild.data))
"""Format build data as xml."""
content = '<?xml version="1.0"?><build version="1.0">'\
'<id>%s</id>' % self.build_id
- # list of repos
- content += '<repos>'
- archs = []
- for name, target in self.targets.iteritems():
- content += '<repo>%s</repo>' % name
- archs.extend(target['archs'])
- content += '</repos>'
-
- # list of architectures
- content += '<archs>'
- for arch in set(archs):
- content += '<arch>%s</arch>' % arch
- content += '</archs>'
# build targets
content += '<buildtargets>'
buildconf['checksum']['value'])
content += '</buildconf>'
+ # list of architectures
+ content += '<archs>'
+ for arch in set(target['archs']):
+ content += '<arch>%s</arch>' % arch
+ content += '</archs>'
+
# repos
for rtype, rarch, rpath in target["repos"]:
- if rarch:
- content += '<repo type="%s" arch="%s">%s</repo>' % (rtype,
- rarch,
- rpath)
- else:
- content += '<repo type="%s">%s</repo>' % (rtype, rpath)
+ if rtype == 'noarch':
+ rtype = 'binary'
+ target_repo_line = '<repo type="%s">%s</repo>' % (rtype, rpath)
+ if target_repo_line in content:
+ continue
+ content += target_repo_line
content += '</buildtarget>'
content += '</buildtargets></build>'
TEST_XML = """<?xml version="1.0" ?>
<build version="1.0">
<id>test.id</id>
- <repos>
- <repo>atom</repo>
- <repo>exynos</repo>
- </repos>
- <archs>
- <arch>x86_64</arch>
- <arch>armv7l</arch>
- <arch>i586</arch>
- </archs>
<buildtargets>
<buildtarget name="atom">
<buildconf>
<location href="3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8-build.conf"/>
<checksum type="sh256">3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8</checksum>
</buildconf>
- <repo arch="i586" type="binary">repos/atom/i586/packages</repo>
- <repo arch="i586" type="binary">repos/atom/i586/debug</repo>
- <repo arch="x86_64" type="binary">repos/atom/x86_64/packages</repo>
- <repo arch="x86_64" type="binary">repos/atom/x86_64/debug</repo>
+ <archs>
+ <arch>x86_64</arch>
+ <arch>i586</arch>
+ </archs>
+ <repo type="binary">repos/atom/packages</repo>
+ <repo type="debug">repos/atom/debug</repo>
<repo type="source">repos/atom/sources</repo>
</buildtarget>
<buildtarget name="exynos">
<location href="3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8-build.conf"/>
<checksum type="sh256">3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8</checksum>
</buildconf>
- <repo arch="armv7l" type="binary">repos/exynos/armv7l/packages</repo>
- <repo arch="armv7l" type="binary">repos/exynos/armv7l/debug</repo>
+ <archs>
+ <arch>armv7l</arch>
+ </archs>
+ <repo type="binary">repos/exynos/packages</repo>
+ <repo type="debug">repos/exynos/debug</repo>
<repo type="source">repos/exynos/sources</repo>
</buildtarget>
</buildtargets>
self.assertEqual(bdata.targets, OrderedDict(
[(u'atom',
{"repos":
- [(u'binary', u'i586', u'repos/atom/i586/packages'),
- (u'binary', u'i586', u'repos/atom/i586/debug'),
- (u'binary', u'x86_64', u'repos/atom/x86_64/packages'),
- (u'binary', u'x86_64', u'repos/atom/x86_64/debug'),
+ [(u'binary', '', u'repos/atom/packages'),
+ (u'debug', '', u'repos/atom/debug'),
(u'source', '', u'repos/atom/sources')],
'buildconf':
{'checksum': {'type': u'sh256',
'value': u'3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8'},
'location': u'3bd64bd5fa862d99dbc363ccb1557d137b5685bc3bfe9a86bcbf50767da5e2e8-build.conf'},
- 'name': u'atom', 'archs': [u'i586', u'x86_64']}),
+ 'name': u'atom', 'archs': [u'x86_64', u'i586']}),
(u'exynos',
{"repos":
- [(u'binary', u'armv7l', u'repos/exynos/armv7l/packages'),
- (u'binary', u'armv7l', u'repos/exynos/armv7l/debug'),
+ [(u'binary', '', u'repos/exynos/packages'),
+ (u'debug', '', u'repos/exynos/debug'),
(u'source', '', u'repos/exynos/sources')],
'buildconf':
{'checksum': {'type': u'sh256',
"location": 'build.conf'
},
"repos": [
- ("binary", "arm7vl", "repos/exynos/armv71/packages"),
- ("binary", "arm7vl", "repos/exynos/armv71/debug"),
+ ("binary", "arm7vl", "repos/exynos/packages"),
+ ("debug", None, "repos/exynos/debug"),
("source", None, "repos/exynos/sources")]
}
bdata = BuildData(build_id='test.id')
bdata.load(TEST_XML)
self.assertEqual(bdata.to_xml(), TEST_XML)
- self.assertEqual(len(bdata.to_xml(hreadable=False)), 1207)
+ self.assertEqual(len(bdata.to_xml(hreadable=False)), 962)
def test_save(self):