aboutsummaryrefslogtreecommitdiffstats
path: root/debian/lib/python/debian_linux
diff options
context:
space:
mode:
Diffstat (limited to 'debian/lib/python/debian_linux')
-rw-r--r--debian/lib/python/debian_linux/debian.py76
-rw-r--r--debian/lib/python/debian_linux/gencontrol.py3
2 files changed, 57 insertions, 22 deletions
diff --git a/debian/lib/python/debian_linux/debian.py b/debian/lib/python/debian_linux/debian.py
index 7b6e9ba101be..41817edb81ee 100644
--- a/debian/lib/python/debian_linux/debian.py
+++ b/debian/lib/python/debian_linux/debian.py
@@ -24,7 +24,6 @@ def read_changelog(dir = ''):
""", re.VERBOSE)
f = file(os.path.join(dir, "debian/changelog"))
entries = []
- act_upstream = None
while True:
line = f.readline()
if not line:
@@ -39,10 +38,6 @@ def read_changelog(dir = ''):
e['Source'] = match.group('header_source')
version = parse_version(match.group('header_version'))
e['Version'] = version
- if act_upstream is None:
- act_upstream = version['upstream']
- elif version['upstream'] != act_upstream:
- break
entries.append(e)
return entries
@@ -80,6 +75,9 @@ def parse_version_linux(version):
.+?
)
)?
+ (?:
+ \.dfsg\.\d+
+ )?
-
(?P<debian>[^-]+)
)
@@ -88,14 +86,7 @@ $
match = re.match(version_re, version, re.X)
if match is None:
raise ValueError
- ret = match.groupdict()
- if ret['modifier'] is not None:
- ret['upstream'] = '%s-%s' % (ret['version'], ret['modifier'])
- ret['source_upstream'] = '%s~%s' % (ret['version'], ret['modifier'])
- else:
- ret['upstream'] = ret['version']
- ret['source_upstream'] = ret['version']
- return ret
+ return match.groupdict()
class package_description(object):
__slots__ = "short", "long"
@@ -122,22 +113,60 @@ class package_description(object):
self.long.extend(str.split("\n.\n"))
class package_relation(object):
- __slots__ = "name", "version", "arches"
-
- _re = re.compile(r'^(\S+)(?: \(([^)]+)\))?(?: \[([^]]+)\])?$')
+ __slots__ = "name", "operator", "version", "arches"
+
+ _re = re.compile(r'^(\S+)(?: \((<<|<=|=|!=|>=|>>)\s*([^)]+)\))?(?: \[([^]]+)\])?$')
+
+ class _operator(object):
+ OP_LT = 1
+ OP_LE = 2
+ OP_EQ = 3
+ OP_NE = 4
+ OP_GE = 5
+ OP_GT = 6
+
+ operators = {
+ '<<': OP_LT,
+ '<=': OP_LE,
+ '=': OP_EQ,
+ '!=': OP_NE,
+ '>=': OP_GE,
+ '>>': OP_GT,
+ }
+ operators_neg = {
+ OP_LT: OP_GE,
+ OP_LE: OP_GT,
+ OP_EQ: OP_NE,
+ OP_NE: OP_EQ,
+ OP_GE: OP_LT,
+ OP_GT: OP_LE,
+ }
+ operators_text = dict([(b, a) for a, b in operators.iteritems()])
+
+ __slots__ = '_op',
+
+ def __init__(self, value):
+ self._op = self.operators[value]
+
+ def __neg__(self):
+ return self.__class__(self.operators_text[self.operators_neg[self._op]])
+
+ def __str__(self):
+ return self.operators_text[self._op]
def __init__(self, value = None):
if value is not None:
self.parse(value)
else:
self.name = None
+ self.operator = None
self.version = None
self.arches = []
def __str__(self):
ret = [self.name]
- if self.version is not None:
- ret.extend([' (', self.version, ')'])
+ if self.operator is not None and self.version is not None:
+ ret.extend([' (', str(self.operator), ' ', self.version, ')'])
if self.arches:
ret.extend([' [', ' '.join(self.arches), ']'])
return ''.join(ret)
@@ -156,9 +185,13 @@ class package_relation(object):
raise RuntimeError, "Can't parse dependency %s" % value
match = match.groups()
self.name = match[0]
- self.version = match[1]
- if match[2] is not None:
- self.arches = re.split('\s+', match[2])
+ if match[1] is not None:
+ self.operator = self._operator(match[1])
+ else:
+ self.operator = None
+ self.version = match[2]
+ if match[3] is not None:
+ self.arches = re.split('\s+', match[3])
else:
self.arches = []
@@ -252,6 +285,7 @@ class package(dict):
('Build-Depends', package_relation_list),
('Build-Depends-Indep', package_relation_list),
('Provides', package_relation_list),
+ ('Pre-Depends', package_relation_list),
('Depends', package_relation_list),
('Recommends', package_relation_list),
('Suggests', package_relation_list),
diff --git a/debian/lib/python/debian_linux/gencontrol.py b/debian/lib/python/debian_linux/gencontrol.py
index b8316dd56089..7fd2505d83d1 100644
--- a/debian/lib/python/debian_linux/gencontrol.py
+++ b/debian/lib/python/debian_linux/gencontrol.py
@@ -202,6 +202,7 @@ class gencontrol(object):
for in_item in in_groups:
item = package_relation()
item.name = self.substitute(in_item.name, vars)
+ item.operator = in_item.operator
if in_item.version is not None:
item.version = self.substitute(in_item.version, vars)
item.arches = in_item.arches
@@ -240,7 +241,7 @@ class gencontrol(object):
return {
'upstreamversion': version['linux']['upstream'],
'version': version['linux']['version'],
- 'source_upstream': version['linux']['source_upstream'],
+ 'source_upstream': version['upstream'],
'major': version['linux']['major'],
'abiname': abiname,
}