1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#!/usr/bin/env python
# Copyright (C) 2009 Sebastian Pipping <sebastian@pipping.org>
# Licensed under GPL 2 or later
import xml.etree.ElementTree as ET
from ConfigParser import ConfigParser
import re
from sharedutils import * # local
OWNER_REGEX = re.compile('^([^<]+) (?:\([^)]+\) )?<([^ ]+@[^ ]+)>$')
NOT_AN_OVERLAY_MESSAGE = 'Skipping %s (not an overlay)'
gitosis_conf = ConfigParser()
gitosis_conf.read('gitosis.conf')
a = ET.parse(open('repositories.xml'))
repositories = a.getroot()
overlays_gentoo_org_dict = dict([[e.attrib['name'], e] for e in repositories])
for section_name in gitosis_conf.sections():
if section_name.startswith('repo '):
_repo_base = section_name[len('repo '):].strip()
if _repo_base.startswith('dev/'):
repo_name = _repo_base[len('dev/'):].strip()
owner_type = "person"
elif _repo_base.startswith('proj/'):
repo_name = _repo_base[len('proj/'):].strip()
owner_type = "project"
else:
print NOT_AN_OVERLAY_MESSAGE % repo_name
continue
if not gitosis_conf.has_option(section_name, 'gentoo-is-overlay') or \
not gitosis_conf.getboolean(section_name, 'gentoo-is-overlay'):
print NOT_AN_OVERLAY_MESSAGE % repo_name
continue
if repo_name in overlays_gentoo_org_dict:
print 'Updating %s' % repo_name
repo = overlays_gentoo_org_dict[repo_name]
# Keep due to poor descriptions in gitosis.conf atm
# Assume first <description> is english
_description = repo.find('description').text
# Clear
repo.attrib['status'] = 'official'
repo[:] = []
else:
print 'Adding %s' % repo_name
_description = gitosis_conf.get(section_name, 'description')
repo = ET.Element('repo', name=repo_name, status='official')
repositories.append(repo)
homepage = ET.Element('homepage')
homepage.text = 'http://git.overlays.gentoo.org/gitweb/?p=%s.git;a=summary' % _repo_base
description = ET.Element('description', lang='en')
description.text = _description
_owner = gitosis_conf.get(section_name, 'owner')
_owner_match = OWNER_REGEX.match(_owner)
owner = ET.Element('owner', type=owner_type)
owner_name = ET.Element('name')
owner_name.text = _owner_match.group(1)
owner_email = ET.Element('email')
owner_email.text = _owner_match.group(2)
owner[:] = [owner_email, owner_name]
repo[:] = [description, homepage, owner]
source_uris = (
'git://git.overlays.gentoo.org/%s.git' % _repo_base,
'http://git.overlays.gentoo.org/gitroot/%s.git' % _repo_base,
'git+ssh://git@git.overlays.gentoo.org/%s.git' % _repo_base,
)
for uri in source_uris:
source = ET.Element('source', type='git')
source.text = uri
repo.append(source)
feed_uris = (
'http://git.overlays.gentoo.org/gitweb/?p=%s.git;a=atom' % _repo_base,
'http://git.overlays.gentoo.org/gitweb/?p=%s.git;a=rss' % _repo_base,
)
for uri in feed_uris:
feed = ET.Element('feed')
feed.text = uri
repo.append(feed)
recurse_print(repo, 1)
indent(repositories)
a.write('repositories.xml')
|