diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-10-21 11:07:53 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-10-21 11:07:53 +0200 |
| commit | cf026ec1840a0d858b48e35fa98b248323ab9d90 (patch) | |
| tree | 3b7a82d9e8731d2877c0e3f70d9c64ea350bd73b | |
| parent | d7c8f470a236d70fa6ce8eb0e522702fee64ff5e (diff) | |
| download | python-apt-cf026ec1840a0d858b48e35fa98b248323ab9d90.tar.gz | |
first cut of multiarch support, tests still fail though
| -rw-r--r-- | apt/debfile.py | 34 | ||||
| -rw-r--r-- | tests/data/test_debs/multiarch-test1_i386.deb | bin | 0 -> 978 bytes | |||
| -rw-r--r-- | tests/test_debfile.py | 8 | ||||
| -rw-r--r-- | tests/test_debfile_multiarch.py | 46 |
4 files changed, 80 insertions, 8 deletions
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") diff --git a/tests/data/test_debs/multiarch-test1_i386.deb b/tests/data/test_debs/multiarch-test1_i386.deb Binary files differnew file mode 100644 index 00000000..439a9f46 --- /dev/null +++ b/tests/data/test_debs/multiarch-test1_i386.deb diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 951c2afe..72d5e0b0 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -17,8 +17,8 @@ sys.path.insert(0, get_library_dir()) import apt_pkg import apt.debfile -class TestDebfilee(unittest.TestCase): - """ test the apt cache """ +class TestDebfile(unittest.TestCase): + """ test the debfile """ TEST_DEBS = [ # conflicts with apt @@ -87,7 +87,7 @@ class TestDebfilee(unittest.TestCase): self.assertEqual(deb["Maintainer"], "Samuel Lidén Borell <samuel@slbdata.se>") - def testContent(self): + def test_content(self): # no python-debian for python3 yet, so fail gracefully try: import debian @@ -130,6 +130,8 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading # we need to support python2.6 self.assertTrue(raised) + + if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) unittest.main() diff --git a/tests/test_debfile_multiarch.py b/tests/test_debfile_multiarch.py new file mode 100644 index 00000000..1b468a45 --- /dev/null +++ b/tests/test_debfile_multiarch.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (C) 2010 Michael Vogt <mvo@ubuntu.com> +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. +"""Unit tests for verifying the correctness of DebPackage in apt.debfile.""" +import os +import logging +import unittest + +from test_all import get_library_dir +import sys +sys.path.insert(0, get_library_dir()) +import apt +import apt_pkg +import apt.debfile + +class TestDebfileMultiarch(unittest.TestCase): + """ test the multiarch debfile """ + + def test_multiarch_deb(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 + self.assertFalse("dpkg:i386" in missing) + + def test_multiarch_conflicts(self): + cache = apt.Cache() + # WARNING: this assumes that lib3ds-1-3 is a non-multiarch lib + # use "lib3ds-1-3" as a test to see if non-multiach lib conflicts work + cache["lib3ds-1-3"].mark_install() + deb = apt.debfile.DebPackage( + "./data/test_debs/multiarch-test1_i386.deb", cache=cache) + # this deb should now not be installable + self.assertFalse(deb.check()) + + +if __name__ == "__main__": + unittest.main() |
