summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-12-08 20:03:15 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-12-08 20:03:15 +0100
commit2970a61bf162c15114f16ede822f02dc7968ac37 (patch)
tree0599e4661829e794e8e4f998f17db8d998c63e19 /apt
parent350bb4a03d6562ddba12fbb0a34610aac7706b3c (diff)
parent5416003d5acd3630bff5b48f69277b5e1d917f20 (diff)
downloadpython-apt-2970a61bf162c15114f16ede822f02dc7968ac37.tar.gz
* lp:~mvo/python-apt/debfile-multiarch:
- add multiarch support to the debfile.py code
Diffstat (limited to 'apt')
-rw-r--r--apt/debfile.py56
1 files changed, 51 insertions, 5 deletions
diff --git a/apt/debfile.py b/apt/debfile.py
index 17f1dbd9..160a4a72 100644
--- a/apt/debfile.py
+++ b/apt/debfile.py
@@ -55,6 +55,7 @@ class DebPackage(object):
self._need_pkgs = []
self._check_was_run = False
self._failure_string = ""
+ self._multiarch = None
if filename:
self.open(filename)
@@ -85,6 +86,35 @@ 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,
+ 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.architecture == "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.
@@ -98,6 +128,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):
@@ -133,6 +166,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):
@@ -205,6 +241,11 @@ 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, in_conflict_checking=True)
+
# check conflicts with virtual pkgs
if not depname in self._cache:
# FIXME: we have to check for virtual replaces here as
@@ -405,9 +446,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:
@@ -673,7 +719,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()
@@ -695,7 +741,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")