From 26b19f37f6b5c7357a856fcccfd459d567934085 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Mon, 21 Jun 2010 09:47:49 +0100 Subject: [PATCH] Remove leading "epoch:" from all version numbers --- tests/testdistro.py | 2 +- zeroinstall/injector/distro.py | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/testdistro.py b/tests/testdistro.py index 03a37c3..25b79eb 100755 --- a/tests/testdistro.py +++ b/tests/testdistro.py @@ -209,7 +209,7 @@ class TestDistro(BaseTest): self.assertEquals('x86_64', impl.machine) def testCleanVersion(self): - self.assertEquals('1', distro.try_cleanup_distro_version('1:0.3.1-1')) + self.assertEquals('0.3.1-1', distro.try_cleanup_distro_version('1:0.3.1-1')) self.assertEquals('0.3.1-1', distro.try_cleanup_distro_version('0.3.1-1ubuntu0')) self.assertEquals('0.3-post1-rc2', distro.try_cleanup_distro_version('0.3-post1-rc2')) self.assertEquals('0.3.1-2', distro.try_cleanup_distro_version('0.3.1-r2-r3')) diff --git a/zeroinstall/injector/distro.py b/zeroinstall/injector/distro.py index 36b78f6..7305ba0 100644 --- a/zeroinstall/injector/distro.py +++ b/zeroinstall/injector/distro.py @@ -120,6 +120,8 @@ def try_cleanup_distro_version(version): We do this by stripping off anything we can't parse. @return: the part we understood, or None if we couldn't parse anything @rtype: str""" + if ':' in version: + version = version.split(':')[1] # Skip 'epoch' match = re.match(_version_regexp, version) if match: version, revision = match.groups() @@ -333,9 +335,6 @@ class DebianDistribution(Distribution): if not line: continue version, debarch, status = line.split('\t', 2) if not status.endswith(' installed'): continue - if ':' in version: - # Debian's 'epoch' system - version = version.split(':', 1)[1] clean_version = try_cleanup_distro_version(version) if clean_version: return '%s\t%s' % (clean_version, canonical_machine(debarch.strip())) @@ -358,13 +357,14 @@ class DebianDistribution(Distribution): cached = self.apt_cache.get(package, None) if cached: - candidate_version, candidate_arch, candidate_size = cached + candidate_version = cached['version'] + candidate_arch = cached['arch'] if candidate_version and candidate_version != installed_version: impl = factory('package:deb:%s:%s' % (package, candidate_version)) impl.version = model.parse_version(candidate_version) if candidate_arch != '*': impl.machine = candidate_arch - impl.download_sources.append(model.DistributionSource(package, candidate_size)) + impl.download_sources.append(model.DistributionSource(package, cached['size'])) def get_score(self, disto_name): return int(disto_name == 'Debian') @@ -402,16 +402,13 @@ class DebianDistribution(Distribution): line = line.strip() if line.startswith('Version: '): version = line[9:] - if ':' in version: - # Debian's 'epoch' system - version = version.split(':', 1)[1] version = try_cleanup_distro_version(version) elif line.startswith('Architecture: '): arch = canonical_machine(line[14:].strip()) elif line.startswith('Size: '): size = int(line[6:].strip()) if version and arch: - cached = (version, arch, size) + cached = {'version': version, 'arch': arch, 'size': size} else: cached = None child.wait() -- 2.11.4.GIT