debian/bin/gencontrol.py, debian/lib/python/debian_linux/debian.py,
debian/lib/python/debian_linux/gencontrol.py: Make version code object oriented. svn path=/dists/trunk/linux-2.6/; revision=8232
This commit is contained in:
parent
930fd36544
commit
c68949fa25
|
@ -13,7 +13,7 @@ class gencontrol(debian_linux.gencontrol.gencontrol):
|
|||
super(gencontrol, self).do_main_setup(vars, makeflags, extra)
|
||||
vars.update(self.config['image',])
|
||||
makeflags.update({
|
||||
'SOURCEVERSION': self.version['linux']['source'],
|
||||
'SOURCEVERSION': self.version.complete,
|
||||
})
|
||||
|
||||
def do_main_packages(self, packages, extra):
|
||||
|
@ -215,10 +215,10 @@ class gencontrol(debian_linux.gencontrol.gencontrol):
|
|||
unpatch = self.templates['patch.unpatch']
|
||||
|
||||
vars = {
|
||||
'home': '/usr/src/kernel-patches/all/%s/debian' % self.version['linux']['upstream'],
|
||||
'revisions': ' '.join([i['Version']['debian'] for i in self.changelog[::-1]]),
|
||||
'source': "%(upstream)s-%(debian)s" % self.version['linux'],
|
||||
'upstream': self.version['linux']['upstream'],
|
||||
'home': '/usr/src/kernel-patches/all/%s/debian' % self.version.linux_upstream,
|
||||
'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,
|
||||
}
|
||||
|
||||
apply = self.substitute(apply, vars)
|
||||
|
@ -228,16 +228,16 @@ class gencontrol(debian_linux.gencontrol.gencontrol):
|
|||
file('debian/bin/patch.unpatch', 'w').write(unpatch)
|
||||
|
||||
def process_changelog(self):
|
||||
in_changelog = read_changelog()
|
||||
act_upstream = in_changelog[0]['Version']['linux']['upstream']
|
||||
in_changelog = read_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']
|
||||
if self.version['linux']['modifier'] is not None:
|
||||
if self.version.linux_modifier is not None:
|
||||
self.abiname = ''
|
||||
else:
|
||||
self.abiname = '-%s' % self.config['abi',]['abiname']
|
||||
|
@ -258,15 +258,15 @@ class gencontrol(debian_linux.gencontrol.gencontrol):
|
|||
|
||||
def process_real_tree(self, in_entry, vars):
|
||||
entry = self.process_package(in_entry, vars)
|
||||
versions = [i['Version']['linux'] 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-%(version)s (= %(source)s)" % self.changelog[0]['Version']['linux'])
|
||||
value.append(' | '.join(["linux-source-%(version)s (= %(source)s)" % v for v in versions]))
|
||||
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['source'].replace('~', '-') for v in versions])
|
||||
value.extend(["linux-tree-%s" % v.complete.replace('~', '-') for v in versions])
|
||||
entry[i] = value
|
||||
return entry
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import itertools, os.path, re, utils
|
||||
|
||||
def read_changelog(dir = ''):
|
||||
def read_changelog(dir = '', version = None):
|
||||
r = re.compile(r"""
|
||||
^
|
||||
(
|
||||
|
@ -22,6 +22,8 @@ def read_changelog(dir = ''):
|
|||
)
|
||||
)
|
||||
""", re.VERBOSE)
|
||||
if version is None:
|
||||
version = Version
|
||||
f = file(os.path.join(dir, "debian/changelog"))
|
||||
entries = []
|
||||
while True:
|
||||
|
@ -36,58 +38,91 @@ def read_changelog(dir = ''):
|
|||
e = {}
|
||||
e['Distribution'] = match.group('header_distribution')
|
||||
e['Source'] = match.group('header_source')
|
||||
version = parse_version(match.group('header_version'))
|
||||
e['Version'] = version
|
||||
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
|
||||
|
||||
def parse_version(version):
|
||||
ret = {
|
||||
'complete': version,
|
||||
'upstream': version,
|
||||
'debian': None,
|
||||
'linux': None,
|
||||
}
|
||||
try:
|
||||
i = len(version) - version[::-1].index('-')
|
||||
except ValueError:
|
||||
return ret
|
||||
ret['upstream'] = version[:i-1]
|
||||
ret['debian'] = version[i:]
|
||||
try:
|
||||
ret['linux'] = parse_version_linux(version)
|
||||
except ValueError:
|
||||
pass
|
||||
return ret
|
||||
|
||||
def parse_version_linux(version):
|
||||
version_re = ur"""
|
||||
class Version(object):
|
||||
_version_rules = ur"""
|
||||
^
|
||||
(?P<source>
|
||||
(?P<version>
|
||||
(?P<major>\d+\.\d+)
|
||||
\.
|
||||
(
|
||||
(?P<epoch>
|
||||
\d+
|
||||
)
|
||||
(?:
|
||||
~
|
||||
(?P<modifier>
|
||||
.+?
|
||||
)
|
||||
)?
|
||||
(?:
|
||||
\.dfsg\.\d+
|
||||
)?
|
||||
:
|
||||
)?
|
||||
(?P<upstream>
|
||||
.+?
|
||||
)
|
||||
(
|
||||
-
|
||||
(?P<debian>[^-]+)
|
||||
)
|
||||
)?
|
||||
$
|
||||
"""
|
||||
match = re.match(version_re, version, re.X)
|
||||
if match is None:
|
||||
raise ValueError
|
||||
return match.groupdict()
|
||||
_version_re = re.compile(_version_rules, re.X)
|
||||
|
||||
def __init__(self, version):
|
||||
match = self._version_re.match(version)
|
||||
if match is None:
|
||||
raise RuntimeError, "Invalid debian version"
|
||||
self.complete = version
|
||||
self.epoch = None
|
||||
if match.group("epoch") is not None:
|
||||
self.epoch = int(match.group("epoch"))
|
||||
self.upstream = match.group("upstream")
|
||||
self.debian = match.group("debian")
|
||||
|
||||
if self.debian is not None:
|
||||
self.complete_noepoch = "%s-%s" % (self.upstream, self.debian)
|
||||
else:
|
||||
self.complete_noepoch = self.upstream
|
||||
|
||||
def __str__(self):
|
||||
return self.complete
|
||||
|
||||
class VersionLinux(Version):
|
||||
_version_linux_rules = ur"""
|
||||
^
|
||||
(?P<version>
|
||||
(?P<major>\d+\.\d+)
|
||||
\.
|
||||
\d+
|
||||
)
|
||||
(?:
|
||||
~
|
||||
(?P<modifier>
|
||||
.+?
|
||||
)
|
||||
)?
|
||||
(?:
|
||||
\.dfsg\.\d+
|
||||
)?
|
||||
-
|
||||
(?:[^-]+)
|
||||
$
|
||||
"""
|
||||
_version_linux_re = re.compile(_version_linux_rules, re.X)
|
||||
|
||||
def __init__(self, version):
|
||||
super(VersionLinux, self).__init__(version)
|
||||
match = self._version_linux_re.match(version)
|
||||
if match is None:
|
||||
raise RuntimeError, "Invalid debian linux version"
|
||||
d = match.groupdict()
|
||||
self.linux_major = d['major']
|
||||
self.linux_modifier = d['modifier']
|
||||
self.linux_version = d['version']
|
||||
if d['modifier'] is not None:
|
||||
self.linux_upstream = '-'.join((d['version'], d['modifier']))
|
||||
else:
|
||||
self.linux_upstream = d['version']
|
||||
|
||||
class package_description(object):
|
||||
__slots__ = "short", "long"
|
||||
|
||||
|
|
|
@ -60,9 +60,9 @@ class gencontrol(object):
|
|||
|
||||
def do_main_setup(self, vars, makeflags, extra):
|
||||
makeflags.update({
|
||||
'MAJOR': self.version['linux']['major'],
|
||||
'VERSION': self.version['linux']['version'],
|
||||
'UPSTREAMVERSION': self.version['linux']['upstream'],
|
||||
'MAJOR': self.version.linux_major,
|
||||
'VERSION': self.version.linux_version,
|
||||
'UPSTREAMVERSION': self.version.linux_upstream,
|
||||
'ABINAME': self.abiname,
|
||||
})
|
||||
|
||||
|
@ -239,10 +239,10 @@ class gencontrol(object):
|
|||
|
||||
def process_version_linux(self, version, abiname):
|
||||
return {
|
||||
'upstreamversion': version['linux']['upstream'],
|
||||
'version': version['linux']['version'],
|
||||
'source_upstream': version['upstream'],
|
||||
'major': version['linux']['major'],
|
||||
'upstreamversion': version.linux_upstream,
|
||||
'version': version.linux_version,
|
||||
'source_upstream': version.upstream,
|
||||
'major': version.linux_major,
|
||||
'abiname': abiname,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue