From c7fd83fdfca918a7cf0b416d341bf7687a11792f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 21 Oct 2013 10:49:29 +0200 Subject: apt/debfile.py: Pass strip_multi_arch=False to parse_depends. Patch by Michael, tests derived from the ones provided by the reporter. I included the test debs without the source package, as for our use case, all needed "source code" is included in the package itself anyway. Reported-By: Francois Gouget Closes: #717859 Closes: #717861 --- apt/debfile.py | 14 ++++---- debian/changelog | 4 +++ .../test_debs/testdep-allowed-any_1.0-1_i386.deb | Bin 0 -> 1128 bytes .../test_debs/testdep-same-arch_1.0-1_i386.deb | Bin 0 -> 1236 bytes tests/data/test_debs/var/lib/dpkg/status | 39 +++++++++++++++++++++ tests/test_debfile.py | 17 +++++++++ 6 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 tests/data/test_debs/testdep-allowed-any_1.0-1_i386.deb create mode 100644 tests/data/test_debs/testdep-same-arch_1.0-1_i386.deb diff --git a/apt/debfile.py b/apt/debfile.py index adf9b348..7f9cf9fc 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -102,6 +102,8 @@ class DebPackage(object): def _maybe_append_multiarch_suffix(self, pkgname, in_conflict_checking=False): # trivial cases + if ":" in pkgname: + return pkgname if not self._multiarch: return pkgname elif self._cache.is_virtual_package(pkgname): @@ -276,7 +278,7 @@ class DebPackage(object): """List of package names conflicting with this package.""" key = "Conflicts" try: - return apt_pkg.parse_depends(self._sections[key]) + return apt_pkg.parse_depends(self._sections[key], False) except KeyError: return [] @@ -287,7 +289,7 @@ class DebPackage(object): # find depends for key in "Depends", "Pre-Depends": try: - depends.extend(apt_pkg.parse_depends(self._sections[key])) + depends.extend(apt_pkg.parse_depends(self._sections[key], False)) except KeyError: pass return depends @@ -297,7 +299,7 @@ class DebPackage(object): """List of virtual packages which are provided by this package.""" key = "Provides" try: - return apt_pkg.parse_depends(self._sections[key]) + return apt_pkg.parse_depends(self._sections[key], False) except KeyError: return [] @@ -306,7 +308,7 @@ class DebPackage(object): """List of packages which are replaced by this package.""" key = "Replaces" try: - return apt_pkg.parse_depends(self._sections[key]) + return apt_pkg.parse_depends(self._sections[key], False) except KeyError: return [] @@ -499,7 +501,7 @@ class DebPackage(object): def satisfy_depends_str(self, dependsstr): """Satisfy the dependencies in the given string.""" - return self._satisfy_depends(apt_pkg.parse_depends(dependsstr)) + return self._satisfy_depends(apt_pkg.parse_depends(dependsstr, False)) def _satisfy_depends(self, depends): """Satisfy the dependencies.""" @@ -744,7 +746,7 @@ def _test(): s = DscSrcPackage(cache=cache) d = "libc6 (>= 2.3.2), libaio (>= 0.3.96) | libaio1 (>= 0.3.96)" - print s._satisfy_depends(apt_pkg.parse_depends(d)) + print s._satisfy_depends(apt_pkg.parse_depends(d, False)) if __name__ == "__main__": _test() diff --git a/debian/changelog b/debian/changelog index 81e30b64..39298b86 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,10 @@ python-apt (0.9.0) UNRELEASED; urgency=low - Do not set dir::etc::sourceparts to /tmp * apt, aptsources: - Only call init_config() if not already initialized (Closes: #686403) + * apt/debfile.py: + - Pass strip_multi_arch=False to parse_depends. Patch by Michael, tests + derived from the ones provided by the reporter. + Closes: #717859. Closes: #717861. [ Jeremy Bicha ] * data/templates/Ubuntu.info.in: add 'devel' series (Closes: #722961) diff --git a/tests/data/test_debs/testdep-allowed-any_1.0-1_i386.deb b/tests/data/test_debs/testdep-allowed-any_1.0-1_i386.deb new file mode 100644 index 00000000..c56f8192 Binary files /dev/null and b/tests/data/test_debs/testdep-allowed-any_1.0-1_i386.deb differ diff --git a/tests/data/test_debs/testdep-same-arch_1.0-1_i386.deb b/tests/data/test_debs/testdep-same-arch_1.0-1_i386.deb new file mode 100644 index 00000000..872f3b6f Binary files /dev/null and b/tests/data/test_debs/testdep-same-arch_1.0-1_i386.deb differ diff --git a/tests/data/test_debs/var/lib/dpkg/status b/tests/data/test_debs/var/lib/dpkg/status index f0c48151..5c2c48a0 100644 --- a/tests/data/test_debs/var/lib/dpkg/status +++ b/tests/data/test_debs/var/lib/dpkg/status @@ -51,3 +51,42 @@ Description: Debian configuration management system Debconf is a configuration management system for debian packages. Packages use Debconf to ask questions when they are installed. Python-Version: 2.6, 3.1 + +Package: testdep-same +Status: install ok installed +Source: testdep +Version: 1.0-1 +Architecture: amd64 +Maintainer: Francois Gouget +Installed-Size: 25 +Provides: testdep-virtual-same +Section: unknown +Priority: extra +Multi-Arch: same +Description: Multi-arch = same package, no dependency + This is a multiarch package that can only satisfy dependencies for the same + architecture. But multiple instances of this package can be co-installed, + one for each architecture. + . + Library and development packages typically fall into this category. + +Package: testdep-allowed +Status: install ok installed +Source: testdep +Version: 1.0-1 +Architecture: amd64 +Maintainer: Francois Gouget +Installed-Size: 25 +Provides: testdep-virtual-allowed +Section: unknown +Priority: extra +Multi-Arch: allowed +Description: Multi-arch = allowed package, no dependency + This is a multiarch package. By default it can only satisfy dependencies for + packages of the same architecture but that can be changed with ':any' + dependencies. + . + It can only be installed for one architecture at a time. Trying to install the + same package for another architecture will remove the first one. + . + Packages providing tools or shells typically fall into this category. diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 2ae73a45..3e933944 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -137,6 +137,23 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading deb = apt.debfile.DebPackage("./data/test_debs/data-tar-xz.deb") self.assertTrue("Package" in deb) + def test_multi_arch_allowed(self): + apt_pkg.config["APT::Architectures::"] = "i386" + apt_pkg.config["APT::Architectures::"] = "amd64" + apt_pkg.config["APT::Architecture"] = "amd64" + apt_pkg.init_system() + + allowed_any = apt.debfile.DebPackage("./data/test_debs/testdep-allowed-any_1.0-1_i386.deb") + self.assertTrue(allowed_any.check(), allowed_any._failure_string) + + def test_multi_arch_same(self): + apt_pkg.config["APT::Architectures::"] = "i386" + apt_pkg.config["APT::Architectures::"] = "amd64" + apt_pkg.config["APT::Architecture"] = "amd64" + apt_pkg.init_system() + same = apt.debfile.DebPackage("./data/test_debs/testdep-same-arch_1.0-1_i386.deb") + self.assertTrue(same.check(), same._failure_string) + if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) -- cgit v1.2.3