diff options
Diffstat (limited to 'debian/lib/python/debian_linux/debian.py')
-rw-r--r-- | debian/lib/python/debian_linux/debian.py | 76 |
1 files changed, 55 insertions, 21 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), |