diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-10-21 11:47:03 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-10-21 11:47:03 +0200 |
| commit | c96acf6d26beb8c2c2e6eb9a868a4ea6b053a9d4 (patch) | |
| tree | e06b601553be1ce2681260bd9205b449d49d06e0 | |
| parent | cf026ec1840a0d858b48e35fa98b248323ab9d90 (diff) | |
| download | python-apt-c96acf6d26beb8c2c2e6eb9a868a4ea6b053a9d4.tar.gz | |
make the tests pass
| -rw-r--r-- | apt/debfile.py | 36 | ||||
| -rw-r--r-- | tests/test_debfile_multiarch.py | 11 |
2 files changed, 37 insertions, 10 deletions
diff --git a/apt/debfile.py b/apt/debfile.py index 1a9b471a..0e8bfcad 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -85,12 +85,33 @@ class DebPackage(object): return files # helper that will return a pkgname with a multiarch suffix if needed - def _maybe_append_multiarch_suffix(self, pkgname): - if (self._multiarch and - not self._cache.is_virtual_package(pkgname) and - self._cache[pkgname].candidate.architecture != "all"): - return "%s:%s" % (pkgname, self._multiarch) - return pkgname + def _maybe_append_multiarch_suffix(self, pkgname, + in_conflict_checking=False): + # trivial cases + if not self._multiarch: + return pkgname + elif self._cache.is_virtual_package(pkgname): + return pkgname + elif self._cache[pkgname].candidate == "all": + return pkgname + # now do the real multiarch checking + multiarch_pkgname = "%s:%s" % (pkgname, self._multiarch) + # the upper layers will handle this + if not multiarch_pkgname in self._cache: + return multiarch_pkgname + # now check the multiarch state + cand = self._cache[multiarch_pkgname].candidate._cand + #print pkgname, multiarch_pkgname, cand.multi_arch + # the default is to add the suffix, unless its a pkg that can satify + # foreign dependencies + if cand.multi_arch & cand.MULTI_ARCH_FOREIGN: + return pkgname + # for conflicts we need a special case here, any not multiarch enabled + # package has a implicit conflict + if (in_conflict_checking and + not (cand.multi_arch & cand.MULTI_ARCH_SAME)): + return pkgname + return multiarch_pkgname def _is_or_group_satisfied(self, or_group): """Return True if at least one dependency of the or-group is satisfied. @@ -220,7 +241,8 @@ class DebPackage(object): # FIXME: is this good enough? i.e. will apt always populate # the cache with conflicting pkgnames for our arch? - depname = self._maybe_append_multiarch_suffix(depname) + depname = self._maybe_append_multiarch_suffix( + depname, in_conflict_checking=True) # check conflicts with virtual pkgs if not depname in self._cache: diff --git a/tests/test_debfile_multiarch.py b/tests/test_debfile_multiarch.py index 1b468a45..db777692 100644 --- a/tests/test_debfile_multiarch.py +++ b/tests/test_debfile_multiarch.py @@ -21,14 +21,14 @@ import apt.debfile class TestDebfileMultiarch(unittest.TestCase): """ test the multiarch debfile """ - def test_multiarch_deb(self): + def test_multiarch_deb_check(self): if apt_pkg.get_architectures() != ["amd64", "i386"]: logging.warn("skipping test because running on a non-multiarch system") return deb = apt.debfile.DebPackage( "./data/test_debs/multiarch-test1_i386.deb") missing = deb.missing_deps - print missing + #print missing self.assertFalse("dpkg:i386" in missing) def test_multiarch_conflicts(self): @@ -39,7 +39,12 @@ class TestDebfileMultiarch(unittest.TestCase): deb = apt.debfile.DebPackage( "./data/test_debs/multiarch-test1_i386.deb", cache=cache) # this deb should now not be installable - self.assertFalse(deb.check()) + installable = deb.check() + #print deb._failure_string + self.assertFalse(installable) + self.assertEqual(deb._failure_string, + "Conflicts with the installed package 'lib3ds-1-3'") + if __name__ == "__main__": |
