debian/bin/gencontrol.py, debian/lib/python/debian_linux/debian.py:
Make changelog code object oriented. svn path=/dists/trunk/linux-2.6/; revision=8234
This commit is contained in:
parent
5be1182aea
commit
60506c6fef
|
@ -216,7 +216,7 @@ class gencontrol(debian_linux.gencontrol.gencontrol):
|
|||
|
||||
vars = {
|
||||
'home': '/usr/src/kernel-patches/all/%s/debian' % self.version.linux_upstream,
|
||||
'revisions': ' '.join([i['Version'].debian for i in self.changelog[::-1]]),
|
||||
'revisions': ' '.join([i.version.debian for i in self.changelog[::-1]]),
|
||||
'source': "%(linux_upstream)s-%(debian)s" % self.version.__dict__,
|
||||
'upstream': self.version.linux_upstream,
|
||||
}
|
||||
|
@ -228,15 +228,15 @@ class gencontrol(debian_linux.gencontrol.gencontrol):
|
|||
file('debian/bin/patch.unpatch', 'w').write(unpatch)
|
||||
|
||||
def process_changelog(self):
|
||||
in_changelog = read_changelog(version = VersionLinux)
|
||||
act_upstream = in_changelog[0]['Version'].linux_upstream
|
||||
in_changelog = Changelog(version = VersionLinux)
|
||||
act_upstream = in_changelog[0].version.linux_upstream
|
||||
changelog = []
|
||||
for i in in_changelog:
|
||||
if i['Version'].linux_upstream != act_upstream:
|
||||
if i.version.linux_upstream != act_upstream:
|
||||
break
|
||||
changelog.append(i)
|
||||
self.changelog = changelog
|
||||
self.version = self.changelog[0]['Version']
|
||||
self.version = self.changelog[0].version
|
||||
if self.version.linux_modifier is not None:
|
||||
self.abiname = ''
|
||||
else:
|
||||
|
@ -258,12 +258,12 @@ class gencontrol(debian_linux.gencontrol.gencontrol):
|
|||
|
||||
def process_real_tree(self, in_entry, vars):
|
||||
entry = self.process_package(in_entry, vars)
|
||||
versions = [i['Version'] for i in self.changelog[::-1]]
|
||||
versions = [i.version for i in self.changelog[::-1]]
|
||||
for i in (('Depends', 'Provides')):
|
||||
value = package_relation_list()
|
||||
value.extend(entry.get(i, []))
|
||||
if i == 'Depends':
|
||||
value.append("linux-patch-debian-%(linux_version)s (= %(complete)s)" % self.changelog[0]['Version'].__dict__)
|
||||
value.append("linux-patch-debian-%(linux_version)s (= %(complete)s)" % self.changelog[0].version.__dict__)
|
||||
value.append(' | '.join(["linux-source-%(linux_version)s (= %(complete)s)" % v.__dict__ for v in versions]))
|
||||
elif i == 'Provides':
|
||||
value.extend(["linux-tree-%s" % v.complete.replace('~', '-') for v in versions])
|
||||
|
|
|
@ -1,51 +1,51 @@
|
|||
import itertools, os.path, re, utils
|
||||
|
||||
def read_changelog(dir = '', version = None):
|
||||
r = re.compile(r"""
|
||||
class Changelog(list):
|
||||
_rules = r"""
|
||||
^
|
||||
(
|
||||
(?P<header>
|
||||
(?P<header_source>
|
||||
\w[-+0-9a-z.]+
|
||||
)
|
||||
\
|
||||
\(
|
||||
(?P<header_version>
|
||||
[^\(\)\ \t]+
|
||||
)
|
||||
\)
|
||||
\s+
|
||||
(?P<header_distribution>
|
||||
[-0-9a-zA-Z]+
|
||||
)
|
||||
\;
|
||||
(?P<source>
|
||||
\w[-+0-9a-z.]+
|
||||
)
|
||||
\
|
||||
\(
|
||||
(?P<version>
|
||||
[^\(\)\ \t]+
|
||||
)
|
||||
""", re.VERBOSE)
|
||||
if version is None:
|
||||
version = Version
|
||||
f = file(os.path.join(dir, "debian/changelog"))
|
||||
entries = []
|
||||
while True:
|
||||
line = f.readline()
|
||||
if not line:
|
||||
break
|
||||
line = line.strip('\n')
|
||||
match = r.match(line)
|
||||
if not match:
|
||||
continue
|
||||
if match.group('header'):
|
||||
e = {}
|
||||
e['Distribution'] = match.group('header_distribution')
|
||||
e['Source'] = match.group('header_source')
|
||||
try:
|
||||
e['Version'] = version(match.group('header_version'))
|
||||
except Exception:
|
||||
if not len(entries):
|
||||
raise
|
||||
e['Version'] = Version(match.group('header_version'))
|
||||
entries.append(e)
|
||||
return entries
|
||||
\)
|
||||
\s+
|
||||
(?P<distribution>
|
||||
[-0-9a-zA-Z]+
|
||||
)
|
||||
\;
|
||||
"""
|
||||
_re = re.compile(_rules, re.X)
|
||||
|
||||
class Entry(object):
|
||||
__slot__ = 'distribution', 'source', 'version'
|
||||
|
||||
def __init__(self, distribution, source, version):
|
||||
self.distribution, self.source, self.version = distribution, source, version
|
||||
|
||||
def __init__(self, dir = '', version = None):
|
||||
if version is None:
|
||||
version = Version
|
||||
f = file(os.path.join(dir, "debian/changelog"))
|
||||
while True:
|
||||
line = f.readline()
|
||||
if not line:
|
||||
break
|
||||
line = line.strip('\n')
|
||||
match = self._re.match(line)
|
||||
if not match:
|
||||
continue
|
||||
if match.group('version'):
|
||||
try:
|
||||
v = version(match.group('version'))
|
||||
except Exception:
|
||||
if not len(self):
|
||||
raise
|
||||
v = Version(match.group('version'))
|
||||
self.append(self.Entry(match.group('distribution'), match.group('source'), v))
|
||||
|
||||
class Version(object):
|
||||
_version_rules = ur"""
|
||||
|
|
Loading…
Reference in New Issue