From cf026ec1840a0d858b48e35fa98b248323ab9d90 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Oct 2011 11:07:53 +0200 Subject: first cut of multiarch support, tests still fail though --- apt/debfile.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'apt') diff --git a/apt/debfile.py b/apt/debfile.py index 104b0814..1a9b471a 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -54,6 +54,7 @@ class DebPackage(object): self._sections = {} self._need_pkgs = [] self._failure_string = "" + self._multiarch = None if filename: self.open(filename) @@ -83,6 +84,14 @@ class DebPackage(object): self.filename)] 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 _is_or_group_satisfied(self, or_group): """Return True if at least one dependency of the or-group is satisfied. @@ -96,6 +105,9 @@ class DebPackage(object): ver = dep[1] oper = dep[2] + # multiarch + depname = self._maybe_append_multiarch_suffix(depname) + # check for virtual pkgs if not depname in self._cache: if self._cache.is_virtual_package(depname): @@ -131,6 +143,9 @@ class DebPackage(object): for dep in or_group: depname, ver, oper = dep + # multiarch + depname = self._maybe_append_multiarch_suffix(depname) + # if we don't have it in the cache, it may be virtual if not depname in self._cache: if not self._cache.is_virtual_package(depname): @@ -203,6 +218,10 @@ class DebPackage(object): ver = dep[1] oper = dep[2] + # 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) + # check conflicts with virtual pkgs if not depname in self._cache: # FIXME: we have to check for virtual replaces here as @@ -400,9 +419,14 @@ class DebPackage(object): return False arch = self._sections["Architecture"] if arch != "all" and arch != apt_pkg.config.find("APT::Architecture"): - self._dbg(1, "ERROR: Wrong architecture dude!") - self._failure_string = _("Wrong architecture '%s'") % arch - return False + if arch in apt_pkg.get_architectures(): + self._multiarch = arch + self.pkgname = "%s:%s" % (self.pkgname, self._multiarch) + self._dbg(1, "Found multiarch arch: '%s'" % arch) + else: + self._dbg(1, "ERROR: Wrong architecture dude!") + self._failure_string = _("Wrong architecture '%s'") % arch + return False # check version if self.compare_to_version_in_cache() == self.VERSION_OUTDATED: @@ -656,7 +680,7 @@ class DscSrcPackage(DebPackage): def _test(): """Test function""" from apt.cache import Cache - from apt.progress import DpkgInstallProgress + from apt.progress.base import InstallProgress cache = Cache() @@ -678,7 +702,7 @@ def _test(): print d.filelist print "Installing ..." - ret = d.install(DpkgInstallProgress()) + ret = d.install(InstallProgress()) print ret #s = DscSrcPackage(cache, "../tests/3ddesktop_0.2.9-6.dsc") -- cgit v1.2.3 From c96acf6d26beb8c2c2e6eb9a868a4ea6b053a9d4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Oct 2011 11:47:03 +0200 Subject: make the tests pass --- apt/debfile.py | 36 +++++++++++++++++++++++++++++------- tests/test_debfile_multiarch.py | 11 ++++++++--- 2 files changed, 37 insertions(+), 10 deletions(-) (limited to 'apt') 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__": -- cgit v1.2.3 From 5416003d5acd3630bff5b48f69277b5e1d917f20 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Oct 2011 12:14:29 +0200 Subject: apt/debfile.py: really check against architecture --- apt/debfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt') diff --git a/apt/debfile.py b/apt/debfile.py index 0e8bfcad..1d7a4a16 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -92,7 +92,7 @@ class DebPackage(object): return pkgname elif self._cache.is_virtual_package(pkgname): return pkgname - elif self._cache[pkgname].candidate == "all": + elif self._cache[pkgname].candidate.architecture == "all": return pkgname # now do the real multiarch checking multiarch_pkgname = "%s:%s" % (pkgname, self._multiarch) -- cgit v1.2.3